[PATCH v3 07/13] iommu/arm-smmu-v3: Disable the queue IRQs before disabling the SMMU
Nicolin Chen
nicolinc at nvidia.com
Mon Aug 31 17:33:32 PDT 2026
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.
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 <nicolinc at nvidia.com>
---
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 64540cfb73244..d45d97f356cf0 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -4907,8 +4907,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");
}
@@ -4931,12 +4933,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;
}
}
@@ -4964,8 +4971,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);
@@ -4992,10 +5001,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);
@@ -5142,18 +5163,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
More information about the linux-arm-kernel
mailing list