From a27e16698983f186f53e49fd8f6858501d922bfb Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Wed, 4 Jan 2017 17:23:19 +0900 Subject: [PATCH] [COMMON] iommu/exynos: force non-shareable for non-cached buffers exynos_iovmm_map_userptr() migrates the given userspace mapping to the device virtual address space. If the given mapping is uncached or writecombine, cache lines that are allocated to some part of the given range can be stale. Therefore the mapping is not cached, the mapping to the System MMU page table should also be non-shareable. Change-Id: I748ae92525c916d580cb55f9deeb9c43f03a6386 Signe-off-by: Cho KyongHo --- drivers/iommu/exynos-iovmm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iommu/exynos-iovmm.c b/drivers/iommu/exynos-iovmm.c index 178d942d8b34..cb7454ccafd9 100644 --- a/drivers/iommu/exynos-iovmm.c +++ b/drivers/iommu/exynos-iovmm.c @@ -521,6 +521,13 @@ dma_addr_t exynos_iovmm_map_userptr(struct device *dev, unsigned long vaddr, if (!!(vma->vm_flags & VM_PFNMAP)) prot |= IOMMU_PFNMAP; + /* non-cached user mapping should be treated as non-shareable mapping */ + if ((pgprot_val(pgprot_writecombine(vma->vm_page_prot)) == + pgprot_val(vma->vm_page_prot)) || + (pgprot_val(pgprot_noncached(vma->vm_page_prot)) == + pgprot_val(vma->vm_page_prot))) + prot &= ~IOMMU_CACHE; + while (eaddr > vma->vm_end) { if (!!(vma->vm_flags & VM_PFNMAP)) { dev_err(dev, "%s: non-linear pfnmap is not supported\n", -- 2.20.1