Merge tag 'dma-mapping-4.20-1' of git://git.infradead.org/users/hch/dma-mapping
[muen/linux.git] / arch / arm64 / mm / dma-mapping.c
index 5a5d7990e98030bb9c144dd3d68f7a12aed8f969..d190612b8f33b2555ffe447bfa72421b34430c4c 100644 (file)
@@ -551,7 +551,7 @@ static void __iommu_sync_single_for_cpu(struct device *dev,
        if (dev_is_dma_coherent(dev))
                return;
 
-       phys = iommu_iova_to_phys(iommu_get_domain_for_dev(dev), dev_addr);
+       phys = iommu_iova_to_phys(iommu_get_dma_domain(dev), dev_addr);
        arch_sync_dma_for_cpu(dev, phys, size, dir);
 }
 
@@ -564,7 +564,7 @@ static void __iommu_sync_single_for_device(struct device *dev,
        if (dev_is_dma_coherent(dev))
                return;
 
-       phys = iommu_iova_to_phys(iommu_get_domain_for_dev(dev), dev_addr);
+       phys = iommu_iova_to_phys(iommu_get_dma_domain(dev), dev_addr);
        arch_sync_dma_for_device(dev, phys, size, dir);
 }
 
@@ -577,9 +577,9 @@ static dma_addr_t __iommu_map_page(struct device *dev, struct page *page,
        int prot = dma_info_to_prot(dir, coherent, attrs);
        dma_addr_t dev_addr = iommu_dma_map_page(dev, page, offset, size, prot);
 
-       if (!iommu_dma_mapping_error(dev, dev_addr) &&
-           (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
-               __iommu_sync_single_for_device(dev, dev_addr, size, dir);
+       if (!coherent && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
+           !iommu_dma_mapping_error(dev, dev_addr))
+               __dma_map_area(page_address(page) + offset, size, dir);
 
        return dev_addr;
 }