Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/jcore: Fix lost per-cpu interrupts

The J-Core AIC does not have separate interrupt numbers reserved for
cpu-local vs global interrupts. Instead, the driver requesting the irq
is expected to know whether its device uses per-cpu interrupts or not.
Previously it was assumed that handle_simple_irq could work for both
cases, but it intentionally drops interrupts for an irq number that
already has a handler running. This resulted in the timer interrupt
for one cpu being lost when multiple cpus' timers were set for
approximately the same expiration time, leading to stalls. In theory
the same could also happen with IPIs.

To solve the problem, instead of registering handle_simple_irq as the
handler, register a wrapper function which checks whether the irq to
be handled was requested as per-cpu or not, and passes it to
handle_simple_irq or handle_percpu_irq accordingly.

Fixes: 981b58f66cfc ("irqchip/jcore-aic: Add J-Core AIC driver")
Signed-off-by: Rich Felker <dalias@libc.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: linux-sh@vger.kernel.org
Link: http://lkml.kernel.org/r/f18cec30bc17e3f52e478dd9f6714bfab02f227f.1476390724.git.dalias@libc.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Rich Felker and committed by
Thomas Gleixner
c024f06b c0ca8df7

+19 -1
+19 -1
drivers/irqchip/irq-jcore-aic.c
··· 25 25 26 26 static struct irq_chip jcore_aic; 27 27 28 + /* 29 + * The J-Core AIC1 and AIC2 are cpu-local interrupt controllers and do 30 + * not distinguish or use distinct irq number ranges for per-cpu event 31 + * interrupts (timer, IPI). Since information to determine whether a 32 + * particular irq number should be treated as per-cpu is not available 33 + * at mapping time, we use a wrapper handler function which chooses 34 + * the right handler at runtime based on whether IRQF_PERCPU was used 35 + * when requesting the irq. 36 + */ 37 + 38 + static void handle_jcore_irq(struct irq_desc *desc) 39 + { 40 + if (irqd_is_per_cpu(irq_desc_get_irq_data(desc))) 41 + handle_percpu_irq(desc); 42 + else 43 + handle_simple_irq(desc); 44 + } 45 + 28 46 static int jcore_aic_irqdomain_map(struct irq_domain *d, unsigned int irq, 29 47 irq_hw_number_t hwirq) 30 48 { 31 49 struct irq_chip *aic = d->host_data; 32 50 33 - irq_set_chip_and_handler(irq, aic, handle_simple_irq); 51 + irq_set_chip_and_handler(irq, aic, handle_jcore_irq); 34 52 35 53 return 0; 36 54 }