iommu: msm: add barrier call on coherent lazy map

When clients of the lazy APIs enable IO coherency they will
skip their cache maintenance code.
However before passing a coherent buffer to the device for
DMA a barrier call must still be made to ensure the caches
are up to date.

Add this barrier call to the lazy map function when
IO coherency is enabled.

Change-Id: I3fc065f8aeff705283211e59bd641d81b4e74067
Signed-off-by: Liam Mark <lmark@codeaurora.org>
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
diff --git a/drivers/iommu/msm_dma_iommu_mapping.c b/drivers/iommu/msm_dma_iommu_mapping.c
index 958f300..07e5236 100644
--- a/drivers/iommu/msm_dma_iommu_mapping.c
+++ b/drivers/iommu/msm_dma_iommu_mapping.c
@@ -17,6 +17,7 @@
 #include <linux/rbtree.h>
 #include <linux/mutex.h>
 #include <linux/err.h>
+#include <asm/barrier.h>
 
 #include <linux/msm_dma_iommu_mapping.h>
 
@@ -205,10 +206,13 @@
 		sg->dma_length = iommu_map->sgl.dma_length;
 
 		kref_get(&iommu_map->ref);
-		/*
-		 * Need to do cache operations here based on "dir" in the
-		 * future if we go with coherent mappings.
-		 */
+		if (is_device_dma_coherent(dev))
+			/*
+			 * Ensure all outstanding changes for coherent
+			 * buffers are applied to the cache before any
+			 * DMA occurs.
+			 */
+			dmb(ish);
 		ret = nents;
 	}
 	mutex_unlock(&iommu_meta->lock);