[v2,1/2] irqchip/loongson-eiointc: Fix return value checking of eiointc_index

Message ID 20230706022849.1272591-2-maobibo@loongson.cn
State New
Headers
Series irqchip/loongson-eiointc: Add simple irq routing method |

Commit Message

maobibo July 6, 2023, 2:28 a.m. UTC
  return value of function eiointc_index is int, however it is
converted uint32_t when used. This causes logic problem when
checking return value. There is eioi initial problem on qemu
virt-machine where there is only one eioi node and more than 4
vcpus, external device intr can only be routed to vcpu 0-3.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 drivers/irqchip/irq-loongson-eiointc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
  

Comments

Huacai Chen July 11, 2023, 1:59 a.m. UTC | #1
On Thu, Jul 6, 2023 at 10:28 AM Bibo Mao <maobibo@loongson.cn> wrote:
>
> return value of function eiointc_index is int, however it is
'return' -> 'Return'.

> converted uint32_t when used. This causes logic problem when
> checking return value. There is eioi initial problem on qemu
'eioi' -> 'eiointc'.

Huacai

> virt-machine where there is only one eioi node and more than 4
> vcpus, external device intr can only be routed to vcpu 0-3.

>
> 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
>
  
maobibo July 11, 2023, 2:43 a.m. UTC | #2
Huacai,

Thanks for reviewing my patch.
I reply inline.

在 2023/7/11 09:59, Huacai Chen 写道:
> On Thu, Jul 6, 2023 at 10:28 AM Bibo Mao <maobibo@loongson.cn> wrote:
>>
>> return value of function eiointc_index is int, however it is
> 'return' -> 'Return'.
Will do.

> 
>> converted uint32_t when used. This causes logic problem when
>> checking return value. There is eioi initial problem on qemu
> 'eioi' -> 'eiointc'.
Will do in next version.

Regards
Bibo Mao
> 
> Huacai
> 
>> virt-machine where there is only one eioi node and more than 4
>> vcpus, external device intr can only be routed to vcpu 0-3.
> 
>>
>> 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
>>
  

Patch

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();