From ab30d0f42cad6bdf54d53974ff77036877dd155b Mon Sep 17 00:00:00 2001 From: Sricharan R Date: Tue, 21 Apr 2015 20:00:37 +0530 Subject: [PATCH] arm64: mm: Fix a bug in iommu dma-mapping iommu_alloc_attrs and arm_iommu_mmap_attrs calls dma_pgprot with device type set to always 'coherent' which is wrong. Should be based on the device type. Signed-off-by: Sricharan R Signed-off-by: Stanimir Varbanov --- arch/arm64/mm/dma-mapping.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 8880a3cfd929..21ea0a367ec8 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -1313,7 +1313,8 @@ static void __iommu_free_atomic(struct device *dev, void *cpu_addr, static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs) { - pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL, true); + pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL, + is_device_dma_coherent(dev)); struct page **pages; void *addr = NULL; @@ -1365,7 +1366,8 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma, unsigned long usize = vma->vm_end - vma->vm_start; struct page **pages = __iommu_get_pages(cpu_addr, attrs); - vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot, true); + vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot, + is_device_dma_coherent(dev)); if (!pages) return -ENXIO; -- 2.39.5