From ff4d461fdaed36db9e6acfe3aabb7b418b0608c2 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 18 Feb 2025 11:14:05 +0200 Subject: [PATCH] mpfs_irq.c: Interrupt claim must be cleared before disabling the source From Polarfire SoC TRM: 6.5.8 Interrupt Completion To signal the completion of executing an interrupt handler, the processor core writes the received interrupt ID 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 ignored. The last paragraph clearly states that IRQ completion does not work for sources that have been disabled -> must ACK the completion before disable. Signed-off-by: Ville Juven --- arch/risc-v/src/mpfs/mpfs_irq.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/risc-v/src/mpfs/mpfs_irq.c b/arch/risc-v/src/mpfs/mpfs_irq.c index 36b48c7d59a..b9a7e4a4ebe 100644 --- a/arch/risc-v/src/mpfs/mpfs_irq.c +++ b/arch/risc-v/src/mpfs/mpfs_irq.c @@ -133,13 +133,22 @@ void up_disable_irq(int irq) uintptr_t claim_address = mpfs_plic_get_claimbase(riscv_cpuid_to_hartid(i)); + /* Clear any already claimed IRQ (this must be done BEFORE + * disabling the interrupt source): + * + * To signal the completion of executing an interrupt handler, the + * processor core writes the received interrupt ID 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 ignored. + */ + + putreg32(extirq, claim_address); + /* Clear enable bit for the irq */ modifyreg32(iebase + (4 * (extirq / 32)), 1 << (extirq % 32), 0); - - /* Clear any already claimed IRQ */ - - putreg32(extirq, claim_address); } } }