* [PATCH] iommu/arm-smmu-v3: Add rmb after reading event queue prod_reg
@ 2020-09-28 8:32 Zhou Wang
2020-09-28 22:13 ` Will Deacon
0 siblings, 1 reply; 3+ messages in thread
From: Zhou Wang @ 2020-09-28 8:32 UTC (permalink / raw)
To: Will Deacon, Robin Murphy, Joerg Roedel, Jean-Philippe Brucker
Cc: iommu, linuxarm, linux-arm-kernel
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@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
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3: Add rmb after reading event queue prod_reg
2020-09-28 8:32 [PATCH] iommu/arm-smmu-v3: Add rmb after reading event queue prod_reg Zhou Wang
@ 2020-09-28 22:13 ` Will Deacon
2020-09-29 11:15 ` Zhou Wang
0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2020-09-28 22:13 UTC (permalink / raw)
To: Robin Murphy, Jean-Philippe Brucker, Joerg Roedel, Zhou Wang
Cc: Will Deacon, catalin.marinas, linuxarm, iommu, kernel-team,
linux-arm-kernel
On Mon, 28 Sep 2020 16:32:02 +0800, Zhou Wang wrote:
> 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.
Applied to will (for-joerg/arm-smmu/updates), thanks!
[1/1] iommu/arm-smmu-v3: Add rmb after reading event queue prod_reg
https://git.kernel.org/will/c/a76a37777f2c
(please note that I changed the patch to use readl() instead of an rmb()
in conjunction with the _relaxed() accessor, and then adjusted the cons
side to match in terms of DMB vs DSB).
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3: Add rmb after reading event queue prod_reg
2020-09-28 22:13 ` Will Deacon
@ 2020-09-29 11:15 ` Zhou Wang
0 siblings, 0 replies; 3+ messages in thread
From: Zhou Wang @ 2020-09-29 11:15 UTC (permalink / raw)
To: Will Deacon, Robin Murphy, Jean-Philippe Brucker, Joerg Roedel
Cc: catalin.marinas, iommu, kernel-team, linuxarm, linux-arm-kernel
On 2020/9/29 6:13, Will Deacon wrote:
> On Mon, 28 Sep 2020 16:32:02 +0800, Zhou Wang wrote:
>> 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.
>
> Applied to will (for-joerg/arm-smmu/updates), thanks!
>
> [1/1] iommu/arm-smmu-v3: Add rmb after reading event queue prod_reg
> https://git.kernel.org/will/c/a76a37777f2c
>
> (please note that I changed the patch to use readl() instead of an rmb()
> in conjunction with the _relaxed() accessor, and then adjusted the cons
> side to match in terms of DMB vs DSB).
Thanks for taking this patch!
Best,
Zhou
>
> Cheers,
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-29 11:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28 8:32 [PATCH] iommu/arm-smmu-v3: Add rmb after reading event queue prod_reg Zhou Wang
2020-09-28 22:13 ` Will Deacon
2020-09-29 11:15 ` Zhou Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).