[COMMON] iommu/exynos: force non-shareable for non-cached buffers
authorCho KyongHo <pullip.cho@samsung.com>
Wed, 4 Jan 2017 08:23:19 +0000 (17:23 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:20 +0000 (19:45 +0900)
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 <pullip.cho@samsung.com>
drivers/iommu/exynos-iovmm.c

index 178d942d8b3426b251bf1a301b4b8e4a68e5693c..cb7454ccafd9a2a5c1ebceeb6f6627ecfa2f5e45 100644 (file)
@@ -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",