Skip to content

Commit 69ea463

Browse files
guoren83Marc Zyngier
authored andcommitted
irqchip/sifive-plic: Fixup EOI failed when masked
When using "devm_request_threaded_irq(,,,,IRQF_ONESHOT,,)" in a driver, only the first interrupt is handled, and following interrupts are never delivered (initially reported in [1]). That's because the RISC-V PLIC cannot EOI masked interrupts, as explained in the description of Interrupt Completion in the PLIC spec [2]: <quote> 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. </quote> Re-enable the interrupt before completion if it has been masked during the handling, and remask it afterwards. [1] http://lists.infradead.org/pipermail/linux-riscv/2021-July/007441.html [2] https://github.com/riscv/riscv-plic-spec/blob/8bc15a35d07c9edf7b5d23fec9728302595ffc4d/riscv-plic.adoc Fixes: bb0fed1 ("irqchip/sifive-plic: Switch to fasteoi flow") Reported-by: Vincent Pelletier <[email protected]> Tested-by: Nikita Shubin <[email protected]> Signed-off-by: Guo Ren <[email protected]> Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]> [maz: amended commit message] Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1cbb418 commit 69ea463

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/irqchip/irq-sifive-plic.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ static void plic_irq_eoi(struct irq_data *d)
163163
{
164164
struct plic_handler *handler = this_cpu_ptr(&plic_handlers);
165165

166-
writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM);
166+
if (irqd_irq_masked(d)) {
167+
plic_irq_unmask(d);
168+
writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM);
169+
plic_irq_mask(d);
170+
} else {
171+
writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM);
172+
}
167173
}
168174

169175
static struct irq_chip plic_chip = {

0 commit comments

Comments
 (0)