From 4d765249313f2b46c2c19f02d76f9031e93e2bce Mon Sep 17 00:00:00 2001 From: Liam Mark Date: Mon, 19 Sep 2016 13:27:27 -0700 Subject: [PATCH] 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 --- drivers/iommu/msm_dma_iommu_mapping.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/msm_dma_iommu_mapping.c b/drivers/iommu/msm_dma_iommu_mapping.c index 334f4e95c068..97cb02d6adae 100644 --- a/drivers/iommu/msm_dma_iommu_mapping.c +++ b/drivers/iommu/msm_dma_iommu_mapping.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -216,10 +217,13 @@ static inline int __msm_dma_map_sg(struct device *dev, struct scatterlist *sg, 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);