Skip to contentSkip to conversation

irqchip/riscv-aplic: Process pending affinity changes on EOI

PATCH Superseded Troy Mitchell 2 participants 3 messages Nov 4 – Nov 10

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/riscv-aplic: Process pending affinity changes on EOI

IMSIC rejects an affinity change with -EBUSY while a previous vector move is still in flight, and the IRQ core then records the new mask as pending. The change is meant to be applied by irq_move_irq() in the IMSIC irq_ack callback, but APLIC MSI interrupts are handled by handle_fasteoi_irq(), which does not call irq_ack.

The pending change is therefore never applied. While it is pending, later affinity changes only update the pending mask, so the interrupt stays on its old CPU.

Call the parent's irq_ack from the EOI callback, before retriggering level sources so that they fire at the updated target.

Fixes 58d868b67a9a ("RISC-V: Select CONFIG_GENERIC_PENDING_IRQ")
---
 drivers/irqchip/irq-riscv-aplic-msi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/irqchip/irq-riscv-aplic-msi.c +5 -2
index fb8d1838609f..a10cc1fb50c2 100644
@@ -57,9 +57,12 @@ static void aplic_msi_irq_retrigger_level(struct irq_data *d)
 static void aplic_msi_irq_eoi(struct irq_data *d)
 {
 	/*
-	 * EOI handling is required only for level-triggered interrupts
-	 * when APLIC is in MSI mode.
+	 * The fasteoi flow does not call irq_ack. Let the IMSIC parent
+	 * process affinity moves deferred while its previous vector move
+	 * was still in flight. Both edge and level sources need this.
 	 */
+	irq_chip_ack_parent(d);
+
 	aplic_msi_irq_retrigger_level(d);
 }
 

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260909-aplic-affinity-fix-80a4b30bd03e

Best regards,

Signature · 1 line
Troy Mitchell <[email protected]>
maintainer
#1 lore raw
Quoted 5 lines · Troy Mitchell

IMSIC rejects an affinity change with -EBUSY while a previous vector move is still in flight, and the IRQ core then records the new mask as pending. The change is meant to be applied by irq_move_irq() in the IMSIC irq_ack callback, but APLIC MSI interrupts are handled by handle_fasteoi_irq(), which does not call irq_ack.

Which is a bug when the interrupt is edge type.

Edge type interrupts are fire and forget from the device point of view. So you want handle_edge_irq() for them, which issues the ack() _before_ the handler is invoked. Otherwise you can lose interrupts.

Thanks,

tglx

#2 lore raw
Quoted 7 lines · Thomas Gleixner
Quoted 5 lines · Troy Mitchell

IMSIC rejects an affinity change with -EBUSY while a previous vector move is still in flight, and the IRQ core then records the new mask as pending. The change is meant to be applied by irq_move_irq() in the IMSIC irq_ack callback, but APLIC MSI interrupts are handled by handle_fasteoi_irq(), which does not call irq_ack.

Quoted 5 lines

Which is a bug when the interrupt is edge type.

Edge type interrupts are fire and forget from the device point of view. So you want handle_edge_irq() for them, which issues the ack() _before_ the handler is invoked. Otherwise you can lose interrupts.

Right, I can reproduce the lost edge here. v2 will use handle_edge_irq() for edge sources and handle_fasteoi_ack_irq() for level sources.

Signature · 1 line
Troy Mitchell