summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/io-pgtable-arm.c
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2017-06-23 13:02:38 +0200
committerWill Deacon <will.deacon@arm.com>2017-06-23 18:58:02 +0200
commit77f3445866c39d8866b31d8d9fa47c7c20938e05 (patch)
treed0cfcf5e936c1e3d584dfbd641003f6a04f95260 /drivers/iommu/io-pgtable-arm.c
parentiommu/io-pgtable: depend on !GENERIC_ATOMIC64 when using COMPILE_TEST with LPAE (diff)
downloadlinux-77f3445866c39d8866b31d8d9fa47c7c20938e05.tar.xz
linux-77f3445866c39d8866b31d8d9fa47c7c20938e05.zip
iommu/io-pgtable-arm: Use dma_wmb() instead of wmb() when publishing table
When writing a new table entry, we must ensure that the contents of the table is made visible to the SMMU page table walker before the updated table entry itself. This is currently achieved using wmb(), which expands to an expensive and unnecessary DSB instruction. Ideally, we'd just use cmpxchg64_release when writing the table entry, but this doesn't have memory ordering semantics on !SMP systems. Instead, use dma_wmb(), which emits DMB OSHST. Strictly speaking, this does more than we require (since it targets the outer-shareable domain), but it's likely to be significantly faster than the DSB approach. Reported-by: Linu Cherian <linu.cherian@cavium.com> Suggested-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/iommu/io-pgtable-arm.c')
-rw-r--r--drivers/iommu/io-pgtable-arm.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index 52700fa958c2..b182039862c5 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -331,8 +331,12 @@ static arm_lpae_iopte arm_lpae_install_table(arm_lpae_iopte *table,
if (cfg->quirks & IO_PGTABLE_QUIRK_ARM_NS)
new |= ARM_LPAE_PTE_NSTABLE;
- /* Ensure the table itself is visible before its PTE can be */
- wmb();
+ /*
+ * Ensure the table itself is visible before its PTE can be.
+ * Whilst we could get away with cmpxchg64_release below, this
+ * doesn't have any ordering semantics when !CONFIG_SMP.
+ */
+ dma_wmb();
old = cmpxchg64_relaxed(ptep, curr, new);