[PATCH v4 08/15] iommu/arm-smmu-v3: Disable the queue IRQs before disabling the SMMU
From: Nicolin Chen <hidden>
Date: 2026-09-10 23:17:55
Also in:
linux-iommu, linux-pci, lkml
Subsystem:
arm smmu drivers, iommu subsystem, the rest · Maintainers:
Will Deacon, Joerg Roedel, Linus Torvalds
The EVTQ, PRIQ and combined IRQ handlers are threaded and issue commands of their own, e.g. a CMDQ_OP_PRI_RESP for a page request. Disabling the SMMU while one is in flight hands that command to a queue consuming nothing, so its poll waits out a full timeout. Two paths disable the SMMU while those IRQs are still requested: a failing arm_smmu_device_reset() returns to a probe that disables the device itself, and arm_smmu_disable_action() covers an unbind or any later probe failure. Both can run after arm_smmu_setup_irqs() requested the IRQs. Disable those IRQs first in both paths, so that no handler is left running once the SMMU goes down. arm_smmu_device_shutdown() needs no change of its own here, since it already just calls arm_smmu_disable_action(). Also clear an IRQ number when its request fails or is skipped for a missing ARM_SMMU_FEAT_PRI, keeping disable_irq() to the IRQs that this driver truly owns. Note that the IOPF queue needs no such care of its own, as devres frees the IRQs before running the release action of that queue, which came earlier in arm_smmu_init_queues(). Assisted-by: Claude:claude-opus-5 Signed-off-by: Nicolin Chen <redacted> --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 36 ++++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 815847c2d7b43..bd7615ce69581 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c@@ -4906,8 +4906,10 @@ static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu) arm_smmu_evtq_thread, IRQF_ONESHOT, "arm-smmu-v3-evtq", smmu); - if (ret < 0) + if (ret < 0) { dev_warn(smmu->dev, "failed to enable evtq irq\n"); + smmu->evtq.q.irq = 0; + } } else { dev_warn(smmu->dev, "no evtq irq - events will not be reported!\n"); }
@@ -4930,12 +4932,17 @@ static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu) IRQF_ONESHOT, "arm-smmu-v3-priq", smmu); - if (ret < 0) + if (ret < 0) { dev_warn(smmu->dev, "failed to enable priq irq\n"); + smmu->priq.q.irq = 0; + } } else { dev_warn(smmu->dev, "no priq irq - PRI will be broken\n"); } + } else { + /* An unrequested IRQ (e.g. set by DT) must not be disabled */ + smmu->priq.q.irq = 0; } }
@@ -4963,8 +4970,10 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) arm_smmu_combined_irq_thread, IRQF_ONESHOT, "arm-smmu-v3-combined-irq", smmu); - if (ret < 0) + if (ret < 0) { dev_warn(smmu->dev, "failed to enable combined irq\n"); + smmu->combined_irq = 0; + } } else arm_smmu_setup_unique_irqs(smmu);
@@ -4991,10 +5000,22 @@ static int arm_smmu_device_disable(struct arm_smmu_device *smmu) return ret; } +/* Quiesce the queue IRQ threads, e.g. before disabling the SMMU */ +static void arm_smmu_disable_irqs(struct arm_smmu_device *smmu) +{ + if (smmu->combined_irq) + disable_irq(smmu->combined_irq); + if (smmu->evtq.q.irq) + disable_irq(smmu->evtq.q.irq); + if (smmu->priq.q.irq) + disable_irq(smmu->priq.q.irq); +} + static void arm_smmu_disable_action(void *data) { struct arm_smmu_device *smmu = data; + arm_smmu_disable_irqs(smmu); if (smmu->impl_ops && smmu->impl_ops->device_disable) smmu->impl_ops->device_disable(smmu); arm_smmu_device_disable(smmu);
@@ -5141,18 +5162,23 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu) ARM_SMMU_CR0ACK); if (ret) { dev_err(smmu->dev, "failed to enable SMMU interface\n"); - return ret; + goto err_disable_irqs; } if (smmu->impl_ops && smmu->impl_ops->device_reset) { ret = smmu->impl_ops->device_reset(smmu); if (ret) { dev_err(smmu->dev, "failed to reset impl\n"); - return ret; + goto err_disable_irqs; } } return 0; + +err_disable_irqs: + /* The probe error path cannot tell if the IRQs were requested */ + arm_smmu_disable_irqs(smmu); + return ret; } #define IIDR_IMPLEMENTER_ARM 0x43b
--
2.43.0