From: Cho KyongHo Date: Wed, 4 Jan 2017 08:23:19 +0000 (+0900) Subject: [COMMON] iommu/exynos: force non-shareable for non-cached buffers X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a27e16698983f186f53e49fd8f6858501d922bfb;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [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 --- 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",