[PATCH v3 06/10] i3c: mipi-i3c-hci: Split the core IRQ handling into its own function

Billy Tsai billy_tsai at aspeedtech.com
Wed Dec 2 19:07:31 PST 2026


i3c_hci_irq_handler() takes the per-device lock, checks irq_inactive to
rule out a shared IRQ meant for a different device, then services
INTR_STATUS. A controller whose interrupts route through a
vendor-specific summary register instead needs that same INTR_STATUS
handling from its own handler, which has already taken the lock and
identified the interrupt as its own through the summary register, not
through irq_inactive or IRQ sharing.

Split the INTR_STATUS handling into i3c_hci_core_irq(), callable with
the lock already held, and have i3c_hci_irq_handler() do the locking,
the irq_inactive check, and the per-I/O-mode dispatch around a call to
it exactly as before.

Signed-off-by: Billy Tsai <billy_tsai at aspeedtech.com>
---
 drivers/i3c/master/mipi-i3c-hci/core.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index da77384e985c..3aa1c445cbf2 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -826,22 +826,12 @@ static const struct i3c_master_controller_ops i3c_hci_ops = {
 	.set_dev_nack_retry	= i3c_hci_set_dev_nack_retry,
 };
 
-static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)
+static irqreturn_t i3c_hci_core_irq(struct i3c_hci *hci)
+__must_hold(&hci->lock)
 {
-	struct i3c_hci *hci = dev_id;
 	irqreturn_t result = IRQ_NONE;
 	u32 val;
 
-	guard(spinlock)(&hci->lock);
-
-	/*
-	 * The IRQ can be shared, so the handler may be called when the IRQ is
-	 * due to a different device. That could happen when runtime suspended,
-	 * so exit immediately if IRQs are not expected for this device.
-	 */
-	if (hci->irq_inactive)
-		return IRQ_NONE;
-
 	val = reg_read(INTR_STATUS);
 	reg_write(INTR_STATUS, val);
 	dev_dbg(&hci->master.dev, "INTR_STATUS %#x", val);
@@ -864,6 +854,26 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)
 		dev_warn_once(&hci->master.dev,
 			      "unexpected INTR_STATUS %#x\n", val);
 
+	return result;
+}
+
+static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)
+{
+	irqreturn_t result = IRQ_NONE;
+	struct i3c_hci *hci = dev_id;
+
+	guard(spinlock)(&hci->lock);
+
+	/*
+	 * The IRQ can be shared, so the handler may be called when the IRQ is
+	 * due to a different device. That could happen when runtime suspended,
+	 * so exit immediately if IRQs are not expected for this device.
+	 */
+	if (hci->irq_inactive)
+		return IRQ_NONE;
+
+	result = i3c_hci_core_irq(hci);
+
 	if (hci->io->irq_handler(hci))
 		result = IRQ_HANDLED;
 

-- 
2.34.1




More information about the linux-arm-kernel mailing list