Skip to content

Commit 3053a2c

Browse files
cwabbott0willdeacon
authored andcommitted
iommu/arm-smmu: Move handing of RESUME to the context fault handler
The upper layer fault handler is now expected to handle everything required to retry the transaction or dump state related to it, since we enable threaded IRQs. This means that we can take charge of writing RESUME, making sure that we always write it after writing FSR as recommended by the specification. The iommu handler should write -EAGAIN if a transaction needs to be retried. This avoids tricky cross-tree changes in drm/msm, since it never wants to retry the transaction and it already returns 0 from its fault handler. Therefore it will continue to correctly terminate the transaction without any changes required. devcoredumps from drm/msm will temporarily be broken until it is fixed to collect devcoredumps inside its fault handler, but fixing that first would actually be worse because MMU-500 ignores writes to RESUME unless all fields of FSR (except SS of course) are clear and raises an interrupt when only SS is asserted. Right now, things happen to work most of the time if we collect a devcoredump, because RESUME is written asynchronously in the fault worker after the fault handler clears FSR and finishes, although there will be some spurious faults, but if this is changed before this commit fixes the FSR/RESUME write order then SS will never be cleared, the interrupt will never be cleared, and the whole system will hang every time a fault happens. It will therefore help bisectability if this commit goes first. I've changed the TBU path to also accept -EAGAIN and do the same thing, while keeping the old -EBUSY behavior. Although the old path was broken because you'd get a storm of interrupts due to returning IRQ_NONE that would eventually result in the interrupt being disabled, and I think it was dead code anyway, so it should eventually be deleted. Note that drm/msm never uses TBU so this is untested. Signed-off-by: Connor Abbott <cwabbott0@gmail.com> Link: https://lore.kernel.org/r/20250520-msm-gpu-fault-fixes-next-v8-2-fce6ee218787@gmail.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 1650620 commit 3053a2c

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ irqreturn_t qcom_smmu_context_fault(int irq, void *dev)
406406
arm_smmu_print_context_fault_info(smmu, idx, &cfi);
407407

408408
arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_FSR, cfi.fsr);
409+
410+
if (cfi.fsr & ARM_SMMU_CB_FSR_SS) {
411+
arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_RESUME,
412+
ret == -EAGAIN ? 0 : ARM_SMMU_RESUME_TERMINATE);
413+
}
414+
409415
return IRQ_HANDLED;
410416
}
411417

@@ -416,6 +422,9 @@ irqreturn_t qcom_smmu_context_fault(int irq, void *dev)
416422
if (!tmp || tmp == -EBUSY) {
417423
ret = IRQ_HANDLED;
418424
resume = ARM_SMMU_RESUME_TERMINATE;
425+
} else if (tmp == -EAGAIN) {
426+
ret = IRQ_HANDLED;
427+
resume = 0;
419428
} else {
420429
phys_addr_t phys_atos = qcom_smmu_verify_fault(smmu_domain, cfi.iova, cfi.fsr);
421430

drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,6 @@ static void qcom_adreno_smmu_set_stall(const void *cookie, bool enabled)
120120
qsmmu->stall_enabled &= ~BIT(cfg->cbndx);
121121
}
122122

123-
static void qcom_adreno_smmu_resume_translation(const void *cookie, bool terminate)
124-
{
125-
struct arm_smmu_domain *smmu_domain = (void *)cookie;
126-
struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
127-
struct arm_smmu_device *smmu = smmu_domain->smmu;
128-
u32 reg = 0;
129-
130-
if (terminate)
131-
reg |= ARM_SMMU_RESUME_TERMINATE;
132-
133-
arm_smmu_cb_write(smmu, cfg->cbndx, ARM_SMMU_CB_RESUME, reg);
134-
}
135-
136123
static void qcom_adreno_smmu_set_prr_bit(const void *cookie, bool set)
137124
{
138125
struct arm_smmu_domain *smmu_domain = (void *)cookie;
@@ -337,7 +324,6 @@ static int qcom_adreno_smmu_init_context(struct arm_smmu_domain *smmu_domain,
337324
priv->set_ttbr0_cfg = qcom_adreno_smmu_set_ttbr0_cfg;
338325
priv->get_fault_info = qcom_adreno_smmu_get_fault_info;
339326
priv->set_stall = qcom_adreno_smmu_set_stall;
340-
priv->resume_translation = qcom_adreno_smmu_resume_translation;
341327
priv->set_prr_bit = NULL;
342328
priv->set_prr_addr = NULL;
343329

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,12 @@ static irqreturn_t arm_smmu_context_fault(int irq, void *dev)
474474
arm_smmu_print_context_fault_info(smmu, idx, &cfi);
475475

476476
arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_FSR, cfi.fsr);
477+
478+
if (cfi.fsr & ARM_SMMU_CB_FSR_SS) {
479+
arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_RESUME,
480+
ret == -EAGAIN ? 0 : ARM_SMMU_RESUME_TERMINATE);
481+
}
482+
477483
return IRQ_HANDLED;
478484
}
479485

0 commit comments

Comments
 (0)