[tip: irq/drivers] irqchip/riscv-aplic: Apply pending affinity changes for level MSI sources

From: tip-bot2 for Troy Mitchell

Date: Tue Dec 01 2026 - 04:15:34 EST


The following commit has been merged into the irq/drivers branch of tip:

Commit-ID: a87b931d61f827534fe20730120a5b97d2a4ed53
Gitweb: https://git.kernel.org/tip/a87b931d61f827534fe20730120a5b97d2a4ed53
Author: Troy Mitchell <troy.mitchell@xxxxxxxxx>
AuthorDate: Thu, 12 Nov 2026 08:14:43
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Tue, 01 Dec 2026 10:10:44 +01:00

irqchip/riscv-aplic: Apply pending affinity changes for level MSI sources

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 applied by irq_move_irq() in the IMSIC irq_ack
callback, but level-triggered APLIC MSI interrupts are handled by
handle_fasteoi_irq(), which never calls 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.

Use handle_fasteoi_ack_irq() for level-triggered sources. It acks the
interrupt before invoking the handler, so a pending affinity change is
applied on the next interrupt, and the EOI retrigger then targets the
new CPU.

Fixes: 58d868b67a9a ("RISC-V: Select CONFIG_GENERIC_PENDING_IRQ")
Signed-off-by: Troy Mitchell <troy.mitchell@xxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://patch.msgid.link/20261112-aplic-affinity-fix-v3-2-943d25cfbfad@xxxxxxxxx
---
drivers/irqchip/Kconfig | 1 +
drivers/irqchip/irq-riscv-aplic-msi.c | 7 +++++--
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 90daedb..aafd2e6 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -645,6 +645,7 @@ config RISCV_APLIC_MSI
bool
depends on RISCV_APLIC
select GENERIC_MSI_IRQ
+ select IRQ_FASTEOI_HIERARCHY_HANDLERS
default RISCV_APLIC

config RISCV_IMSIC
diff --git a/drivers/irqchip/irq-riscv-aplic-msi.c b/drivers/irqchip/irq-riscv-aplic-msi.c
index 5aa9607..7a8e569 100644
--- a/drivers/irqchip/irq-riscv-aplic-msi.c
+++ b/drivers/irqchip/irq-riscv-aplic-msi.c
@@ -75,13 +75,16 @@ static int aplic_msi_irq_set_type(struct irq_data *d, unsigned int type)
* acknowledged before the handler runs. The edge flow handler also
* replays an interrupt which arrives while the previous one is
* still being handled on another CPU after an affinity change.
+ *
+ * Level-triggered sources use the fasteoi flow, but still need the
+ * ack so that the IMSIC parent applies deferred affinity changes.
*/
if (type & IRQ_TYPE_EDGE_BOTH) {
irq_set_chip_handler_name_locked(d, irq_data_get_irq_chip(d),
handle_edge_irq, "edge");
} else {
irq_set_chip_handler_name_locked(d, irq_data_get_irq_chip(d),
- handle_fasteoi_irq, "fasteoi");
+ handle_fasteoi_ack_irq, "fasteoi");
}

/*
@@ -182,7 +185,7 @@ static const struct msi_domain_template aplic_msi_template = {
.info = {
.bus_token = DOMAIN_BUS_WIRED_TO_MSI,
.flags = MSI_FLAG_USE_DEV_FWNODE,
- .handler = handle_fasteoi_irq,
+ .handler = handle_fasteoi_ack_irq,
.handler_name = "fasteoi",
},
};