Message ID | 20230711120807.1805186-2-maobibo@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp434393vqm; Tue, 11 Jul 2023 05:20:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlF/N+zyodbzSrDmxjHQyhkw7hgAEjRJ01kmIelPrmczMjbRjNMTHGwbs4qJDDsi3TXq9Z46 X-Received: by 2002:a05:6a20:483:b0:12e:6a31:37e1 with SMTP id 3-20020a056a20048300b0012e6a3137e1mr12139820pzc.61.1689078010486; Tue, 11 Jul 2023 05:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689078010; cv=none; d=google.com; s=arc-20160816; b=iClLyBtaOll+GmT51S+wFGXkQYnb9/dael9bKt2+rUV2RpWSRyQD6doHhXC5rrHnv0 diSyaUGNiXEcFbphmwVusJfIfFUPxtjP5eoS692VYU7dbiqF0ujYv7EcG9ZoQDKPQZ7P eL9PHDAIJay2U9zR0vvSqtJkiwXA6znRvI2Gwg/g0mdBfjM3bFgwtWRDCleTE2mgC7Ti oUdxvMIuJdDrHWvHf8MK5cDaqCxOvlFZHzt1Qb08+xreBEilL1tO3AG4ZsR2kpxxVCt8 IAaqoCdzF3c45xd0O6RlbO2nGLP8QzmlHwhHGZefp+3TXpQ0zCuZN9SGtzP9hZoC2leX jxZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DnkjJIu15w//EPnydfOrfv24PzJVWbYbAJLftusk9ng=; fh=WrELnb4ZUhcKoy8qr+86JwLN9Krfq2ED1i0xcLj9B70=; b=zFZZAZ2OP39508LlOQZHKP9S2F4agm8j7NtIHa8mHBoa1wawGC5KzzCG7vi0ibRgEU Sn9PiACp3V3VIpbQ+hLOtO0NrLX2tW9TbTMV7dc8Da1boichYwASEUTrhErrHK5GI5qW dduE1sxldyxnA46VKZhcGJQ+ta4vgCjTJW4ex97h4v+r3coim/8WEYEX6A191CtxhZJJ 1Pc+LU1M50Ebx59ejSZ7ocS8SnMt9WNBMgAPU/IudJgkpf4SP/YM9S1C3tVHuIr/Z5Et c+qdMeff6fJSW5YeZsU1CtPMRKdhiSutQXOxcDpH0SPnqdUVtkZPWuq+bGsZowQ8jUCe DDNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r24-20020a638f58000000b0055731f11410si1225175pgn.470.2023.07.11.05.19.58; Tue, 11 Jul 2023 05:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230351AbjGKMIQ (ORCPT <rfc822;gnulinuxfreebsd@gmail.com> + 99 others); Tue, 11 Jul 2023 08:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbjGKMIM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 11 Jul 2023 08:08:12 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A538FE67; Tue, 11 Jul 2023 05:08:09 -0700 (PDT) Received: from loongson.cn (unknown [10.2.9.158]) by gateway (Coremail) with SMTP id _____8BxHOsoRq1kiH8DAA--.4850S3; Tue, 11 Jul 2023 20:08:08 +0800 (CST) Received: from kvm-1-158.loongson.cn (unknown [10.2.9.158]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxfSMnRq1k+6goAA--.1095S3; Tue, 11 Jul 2023 20:08:08 +0800 (CST) From: Bibo Mao <maobibo@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Marc Zyngier <maz@kernel.org> Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jianmin Lv <lvjianmin@loongson.cn>, loongson-kernel@lists.loongnix.cn Subject: [PATCH v3 1/2] irqchip/loongson-eiointc: Fix return value checking of eiointc_index Date: Tue, 11 Jul 2023 20:08:06 +0800 Message-Id: <20230711120807.1805186-2-maobibo@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230711120807.1805186-1-maobibo@loongson.cn> References: <20230711120807.1805186-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8DxfSMnRq1k+6goAA--.1095S3 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW7uw4Duw48Zr45uFWkAF4fJFc_yoW8Xr15pF W7AFZF9w15Ga4xurZ2kF48JryYywn3t3y7K3yxJay7Xan8Jw1DJr4rA3Wqyr1IkrW7uFy2 gF4rXFWUC3Z8AwcCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Yb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVWxJr0_GcWln4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12 xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r12 6r1DMcIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64 vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_ Jrv_JF1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAI cVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42 IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIev Ja73UjIFyTuYvjxUc0eHDUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771126663889535779 X-GMAIL-MSGID: 1771126663889535779 |
Series |
irqchip/loongson-eiointc: Add simple irq routing method
|
|
Commit Message
maobibo
July 11, 2023, 12:08 p.m. UTC
Return value of function eiointc_index is int, however it is converted
into uint32_t and then compared smaller than zero. This causes logic
problem. There is eioint initialization problem on qemu virt-machine
where there is only one eioint node and more than 4 vcpus. Nodemap of
eioint is 1, and external device intr can only be routed to vcpu 0-3, the
other vcpus can not response any external device interrupts and only local
processor interrupts like ipi/timer can work.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
drivers/irqchip/irq-loongson-eiointc.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
Comments
On 11/7/23 14:08, Bibo Mao wrote: > Return value of function eiointc_index is int, however it is converted > into uint32_t and then compared smaller than zero. This causes logic > problem. There is eioint initialization problem on qemu virt-machine > where there is only one eioint node and more than 4 vcpus. Nodemap of > eioint is 1, and external device intr can only be routed to vcpu 0-3, the > other vcpus can not response any external device interrupts and only local > processor interrupts like ipi/timer can work. > > Signed-off-by: Bibo Mao <maobibo@loongson.cn> > --- > drivers/irqchip/irq-loongson-eiointc.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) Fixes: dd281e1a1a93 ("irqchip: Add Loongson Extended I/O interrupt controller support") Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
On Tue, Jul 11, 2023 at 8:08 PM Bibo Mao <maobibo@loongson.cn> wrote: > > Return value of function eiointc_index is int, however it is converted > into uint32_t and then compared smaller than zero. This causes logic > problem. There is eioint initialization problem on qemu virt-machine > where there is only one eioint node and more than 4 vcpus. Nodemap of > eioint is 1, and external device intr can only be routed to vcpu 0-3, the > other vcpus can not response any external device interrupts and only local > processor interrupts like ipi/timer can work. I'm sorry but there are still spelling problems... "eio", "eio intc", "eioint" should all be "eiointc". Huacai > > Signed-off-by: Bibo Mao <maobibo@loongson.cn> > --- > drivers/irqchip/irq-loongson-eiointc.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c > index 92d8aa28bdf5..1c5a5b59f199 100644 > --- a/drivers/irqchip/irq-loongson-eiointc.c > +++ b/drivers/irqchip/irq-loongson-eiointc.c > @@ -144,12 +144,14 @@ static int eiointc_router_init(unsigned int cpu) > int i, bit; > uint32_t data; > uint32_t node = cpu_to_eio_node(cpu); > - uint32_t index = eiointc_index(node); > + int index = eiointc_index(node); > > - if (index < 0) { > - pr_err("Error: invalid nodemap!\n"); > - return -1; > - } > + /* > + * qemu virt-machine has only one eio intc and more than four cpus > + * irq from eio can only be routed to cpu 0-3 on virt machine > + */ > + if (index < 0) > + return 0; > > if ((cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0) { > eiointc_enable(); > -- > 2.27.0 >
在 2023/7/11 23:06, Huacai Chen 写道: > On Tue, Jul 11, 2023 at 8:08 PM Bibo Mao <maobibo@loongson.cn> wrote: >> >> Return value of function eiointc_index is int, however it is converted >> into uint32_t and then compared smaller than zero. This causes logic >> problem. There is eioint initialization problem on qemu virt-machine >> where there is only one eioint node and more than 4 vcpus. Nodemap of >> eioint is 1, and external device intr can only be routed to vcpu 0-3, the >> other vcpus can not response any external device interrupts and only local >> processor interrupts like ipi/timer can work. > I'm sorry but there are still spelling problems... > "eio", "eio intc", "eioint" should all be "eiointc". Sure, thanks for pointing it out, will modify in next version. Regards Bibo Mao > > Huacai > >> >> Signed-off-by: Bibo Mao <maobibo@loongson.cn> >> --- >> drivers/irqchip/irq-loongson-eiointc.c | 12 +++++++----- >> 1 file changed, 7 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c >> index 92d8aa28bdf5..1c5a5b59f199 100644 >> --- a/drivers/irqchip/irq-loongson-eiointc.c >> +++ b/drivers/irqchip/irq-loongson-eiointc.c >> @@ -144,12 +144,14 @@ static int eiointc_router_init(unsigned int cpu) >> int i, bit; >> uint32_t data; >> uint32_t node = cpu_to_eio_node(cpu); >> - uint32_t index = eiointc_index(node); >> + int index = eiointc_index(node); >> >> - if (index < 0) { >> - pr_err("Error: invalid nodemap!\n"); >> - return -1; >> - } >> + /* >> + * qemu virt-machine has only one eio intc and more than four cpus >> + * irq from eio can only be routed to cpu 0-3 on virt machine >> + */ >> + if (index < 0) >> + return 0; >> >> if ((cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0) { >> eiointc_enable(); >> -- >> 2.27.0 >>
On Tue, 11 Jul 2023 13:08:06 +0100, Bibo Mao <maobibo@loongson.cn> wrote: > > Return value of function eiointc_index is int, however it is converted > into uint32_t and then compared smaller than zero. This causes logic > problem. There is eioint initialization problem on qemu virt-machine > where there is only one eioint node and more than 4 vcpus. Nodemap of > eioint is 1, and external device intr can only be routed to vcpu 0-3, the > other vcpus can not response any external device interrupts and only local > processor interrupts like ipi/timer can work. > > Signed-off-by: Bibo Mao <maobibo@loongson.cn> > --- > drivers/irqchip/irq-loongson-eiointc.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c > index 92d8aa28bdf5..1c5a5b59f199 100644 > --- a/drivers/irqchip/irq-loongson-eiointc.c > +++ b/drivers/irqchip/irq-loongson-eiointc.c > @@ -144,12 +144,14 @@ static int eiointc_router_init(unsigned int cpu) > int i, bit; > uint32_t data; > uint32_t node = cpu_to_eio_node(cpu); > - uint32_t index = eiointc_index(node); > + int index = eiointc_index(node); > > - if (index < 0) { > - pr_err("Error: invalid nodemap!\n"); > - return -1; > - } > + /* > + * qemu virt-machine has only one eio intc and more than four cpus > + * irq from eio can only be routed to cpu 0-3 on virt machine > + */ > + if (index < 0) > + return 0; > > if ((cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0) { > eiointc_enable(); This sort of thing really needs a Fixes: tag. Thanks, M.
在 2023/7/12 16:56, Marc Zyngier 写道: > On Tue, 11 Jul 2023 13:08:06 +0100, > Bibo Mao <maobibo@loongson.cn> wrote: >> >> Return value of function eiointc_index is int, however it is converted >> into uint32_t and then compared smaller than zero. This causes logic >> problem. There is eioint initialization problem on qemu virt-machine >> where there is only one eioint node and more than 4 vcpus. Nodemap of >> eioint is 1, and external device intr can only be routed to vcpu 0-3, the >> other vcpus can not response any external device interrupts and only local >> processor interrupts like ipi/timer can work. >> >> Signed-off-by: Bibo Mao <maobibo@loongson.cn> >> --- >> drivers/irqchip/irq-loongson-eiointc.c | 12 +++++++----- >> 1 file changed, 7 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c >> index 92d8aa28bdf5..1c5a5b59f199 100644 >> --- a/drivers/irqchip/irq-loongson-eiointc.c >> +++ b/drivers/irqchip/irq-loongson-eiointc.c >> @@ -144,12 +144,14 @@ static int eiointc_router_init(unsigned int cpu) >> int i, bit; >> uint32_t data; >> uint32_t node = cpu_to_eio_node(cpu); >> - uint32_t index = eiointc_index(node); >> + int index = eiointc_index(node); >> >> - if (index < 0) { >> - pr_err("Error: invalid nodemap!\n"); >> - return -1; >> - } >> + /* >> + * qemu virt-machine has only one eio intc and more than four cpus >> + * irq from eio can only be routed to cpu 0-3 on virt machine >> + */ >> + if (index < 0) >> + return 0; >> >> if ((cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0) { >> eiointc_enable(); > > This sort of thing really needs a Fixes: tag. Sure, will add Fixes tag. I am a newbie to lkml, thanks for kindly pointing it out :) Regards Bibo Mao > > Thanks, > > M. >
diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c index 92d8aa28bdf5..1c5a5b59f199 100644 --- a/drivers/irqchip/irq-loongson-eiointc.c +++ b/drivers/irqchip/irq-loongson-eiointc.c @@ -144,12 +144,14 @@ static int eiointc_router_init(unsigned int cpu) int i, bit; uint32_t data; uint32_t node = cpu_to_eio_node(cpu); - uint32_t index = eiointc_index(node); + int index = eiointc_index(node); - if (index < 0) { - pr_err("Error: invalid nodemap!\n"); - return -1; - } + /* + * qemu virt-machine has only one eio intc and more than four cpus + * irq from eio can only be routed to cpu 0-3 on virt machine + */ + if (index < 0) + return 0; if ((cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0) { eiointc_enable();