All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/sifive-plic: Fix frozen interrupt due to affinity setting
@ 2026-02-12 11:41 Nam Cao
  2026-03-24  6:07 ` patchwork-bot+linux-riscv
  0 siblings, 1 reply; 2+ messages in thread
From: Nam Cao @ 2026-02-12 11:41 UTC (permalink / raw)
  To: Thomas Gleixner, Paul Walmsley, Samuel Holland, Marc Zyngier,
	Anup Patel, linux-kernel, linux-riscv
  Cc: Nam Cao

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 problem 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
jnstantly.

Fix 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>
---
 drivers/irqchip/irq-sifive-plic.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index 210a57959637..1565aab895bc 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -164,8 +164,13 @@ static void plic_irq_disable(struct irq_data *d)
 static void plic_irq_eoi(struct irq_data *d)
 {
 	struct plic_handler *handler = this_cpu_ptr(&plic_handlers);
+	u32 __iomem *reg;
+	bool enabled;
+
+	reg = handler->enable_base + (d->hwirq / 32) * sizeof(u32);
+	enabled = readl(reg) & BIT(d->hwirq % 32);
 
-	if (unlikely(irqd_irq_disabled(d))) {
+	if (unlikely(!enabled)) {
 		plic_toggle(handler, d->hwirq, 1);
 		writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM);
 		plic_toggle(handler, d->hwirq, 0);
-- 
2.47.3


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] irqchip/sifive-plic: Fix frozen interrupt due to affinity setting
  2026-02-12 11:41 [PATCH] irqchip/sifive-plic: Fix frozen interrupt due to affinity setting Nam Cao
@ 2026-03-24  6:07 ` patchwork-bot+linux-riscv
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-03-24  6:07 UTC (permalink / raw)
  To: Nam Cao; +Cc: linux-riscv, tglx, pjw, samuel.holland, maz, anup, linux-kernel

Hello:

This patch was applied to riscv/linux.git (for-next)
by Thomas Gleixner <tglx@kernel.org>:

On Thu, 12 Feb 2026 12:41:25 +0100 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - irqchip/sifive-plic: Fix frozen interrupt due to affinity setting
    https://git.kernel.org/riscv/c/1072020685f4

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-24  6:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12 11:41 [PATCH] irqchip/sifive-plic: Fix frozen interrupt due to affinity setting Nam Cao
2026-03-24  6:07 ` patchwork-bot+linux-riscv

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.