Flushing the TLB before updating translation entries creates a race
condition and can lead to stale TLB entries if a translation request
arrives between flushing the TLB and updating the translation entries.
As there's no requirement to flush the TLB before updating the entries,
flush it after only.

Signed-off-by: Laurent Pinchart <[email protected]>
---
 drivers/iommu/omap-iommu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index cb1e1de..fedd303 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -662,10 +662,11 @@ int omap_iopgtable_store_entry(struct omap_iommu *obj, 
struct iotlb_entry *e)
 {
        int err;
 
-       flush_iotlb_page(obj, e->da);
        err = iopgtable_store_entry_core(obj, e);
-       if (!err)
+       if (!err) {
+               flush_iotlb_page(obj, e->da);
                prefetch_iotlb_entry(obj, e);
+       }
        return err;
 }
 EXPORT_SYMBOL_GPL(omap_iopgtable_store_entry);
-- 
1.8.3.2

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to