[PATCH] iommu/arm-smmu-v3: Add rmb after reading event queue prod_reg

Zhou Wang wangzhou1 at hisilicon.com
Mon Sep 28 04:32:02 EDT 2020


In arm_smmu_evtq_thread, reading event queue is from consumer pointer,
which has no address dependency on producer pointer, prog_reg(MMIO) and
event queue memory(Normal memory) can disorder. So the load for event queue
can be done before the load of prod_reg, then perhaps wrong event entry
value will be got.

Add rmb to make sure to get correct event queue entry value.

Signed-off-by: Zhou Wang <wangzhou1 at hisilicon.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 +++
 1 file changed, 3 insertions(+)

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 c192544..93c9077 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -819,6 +819,9 @@ static int queue_sync_prod_in(struct arm_smmu_queue *q)
 	int ret = 0;
 	u32 prod = readl_relaxed(q->prod_reg);
 
+	/* Ensure that reading event queue is after reading prod_reg */
+	rmb();
+
 	if (Q_OVF(prod) != Q_OVF(q->llq.prod))
 		ret = -EOVERFLOW;
 
-- 
2.8.1




More information about the linux-arm-kernel mailing list