diff mbox series

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

Message ID 20230713032243.2046205-2-maobibo@loongson.cn (mailing list archive)
State Superseded
Headers show
Series irqchip/loongson-eiointc: Add simple irq routing method | expand

Commit Message

Bibo Mao July 13, 2023, 3:22 a.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 eiointc initialization problem on qemu virt-machine
where there is only one eiointc node and more than 4 vcpus. Nodemap of
eiointc 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.

Fixes: dd281e1a1a93 ("irqchip: Add Loongson Extended I/O interrupt controller support")
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 drivers/irqchip/irq-loongson-eiointc.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c
index 92d8aa28bdf5..603d323b8f8b 100644
--- a/drivers/irqchip/irq-loongson-eiointc.c
+++ b/drivers/irqchip/irq-loongson-eiointc.c
@@ -144,12 +144,15 @@  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 eiointc and more than four cpus.
+	 * Irq from eiointc can only be routed to cpu 0-3, cpus except 0-3
+	 * need not initialize eiointc on virt-machine
+	 */
+	if (index < 0)
+		return 0;
 
 	if ((cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0) {
 		eiointc_enable();