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

Configure Feed

Select the types of activity you want to include in your feed.

irqchip/sifive-plic: Fix frozen interrupt due to affinity setting

PLIC ignores interrupt completion message for disabled interrupt, explained
by the specification:

The PLIC signals it has completed executing an interrupt handler by
writing the interrupt ID it received from the claim to the
claim/complete register. The PLIC does not check whether the completion
ID is the same as the last claim ID for that target. If the completion
ID does not match an interrupt source that is currently enabled for
the target, the completion is silently ignored.

This caused problems in the past, because an interrupt can be disabled
while still being handled and plic_irq_eoi() had no effect. That was fixed
by checking if the interrupt is disabled, and if so enable it, before
sending the completion message. That check is done with irqd_irq_disabled().

However, that is not sufficient because the enable bit for the handling
hart can be zero despite irqd_irq_disabled(d) being false. This can happen
when affinity setting is changed while a hart is still handling the
interrupt.

This problem is easily reproducible by dumping a large file to uart (which
generates lots of interrupts) and at the same time keep changing the uart
interrupt's affinity setting. The uart port becomes frozen almost
instantaneously.

Fix this by checking PLIC's enable bit instead of irqd_irq_disabled().

Fixes: cc9f04f9a84f ("irqchip/sifive-plic: Implement irq_set_affinity() for SMP host")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260212114125.3148067-1-namcao@linutronix.de

authored by

Nam Cao and committed by
Thomas Gleixner
10720206 97029699

+6 -1
+6 -1
drivers/irqchip/irq-sifive-plic.c
··· 172 172 static void plic_irq_eoi(struct irq_data *d) 173 173 { 174 174 struct plic_handler *handler = this_cpu_ptr(&plic_handlers); 175 + u32 __iomem *reg; 176 + bool enabled; 175 177 176 - if (unlikely(irqd_irq_disabled(d))) { 178 + reg = handler->enable_base + (d->hwirq / 32) * sizeof(u32); 179 + enabled = readl(reg) & BIT(d->hwirq % 32); 180 + 181 + if (unlikely(!enabled)) { 177 182 plic_toggle(handler, d->hwirq, 1); 178 183 writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM); 179 184 plic_toggle(handler, d->hwirq, 0);