[PATCH 8/8] iommu/qcom: Document why sec_ptbl allocated flag needs no locking
From: Mukesh Ojha
Date: Tue Jun 23 2026 - 08:22:13 EST
qcom_iommu_sec_ptbl_init() uses a function-static bool to track whether
the secure page table has been initialized, with no locking around it.
Only one IOMMU device per SoC has secure context banks (the others have
only non-secure context banks), and platform devices probe serially since
the driver does not set PROBE_PREFER_ASYNCHRONOUS. Concurrent calls to
this function are therefore not reachable. Add a comment to make the
absence of locking intentional rather than an oversight.
Signed-off-by: Mukesh Ojha <mukesh.ojha@xxxxxxxxxxxxxxxx>
---
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
index 0df8c2af8eed..bcf5ab049aed 100644
--- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
@@ -624,7 +624,11 @@ static int qcom_iommu_sec_ptbl_init(struct device *dev)
void *cpu_addr;
dma_addr_t paddr;
unsigned long attrs;
- static bool allocated = false;
+ /*
+ * Only one IOMMU device per SoC has secure context banks, and
+ * platform devices probe serially, so no locking is needed here.
+ */
+ static bool allocated;
int ret;
if (allocated)
@@ -651,15 +655,12 @@ static int qcom_iommu_sec_ptbl_init(struct device *dev)
ret = qcom_scm_iommu_secure_ptbl_init(paddr, psize, spare);
if (ret) {
dev_err(dev, "failed to init iommu pgtable (%d)\n", ret);
- goto free_mem;
+ dma_free_attrs(dev, psize, cpu_addr, paddr, attrs);
+ return ret;
}
allocated = true;
return 0;
-
-free_mem:
- dma_free_attrs(dev, psize, cpu_addr, paddr, attrs);
- return ret;
}
static int get_asid(const struct device_node *np)
--
2.53.0