Merge branch 'nvme-5.2-rc-next' of git://git.infradead.org/nvme into for-linus
[sfrench/cifs-2.6.git] / arch / arm64 / mm / dma-mapping.c
index 78c0a72f822c0a2b0e05b1394e9ca8b982ceb62b..674860e3e478f3015d21b39bd9669a39efdc2be6 100644 (file)
@@ -249,6 +249,11 @@ static int __iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
        if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret))
                return ret;
 
+       if (!is_vmalloc_addr(cpu_addr)) {
+               unsigned long pfn = page_to_pfn(virt_to_page(cpu_addr));
+               return __swiotlb_mmap_pfn(vma, pfn, size);
+       }
+
        if (attrs & DMA_ATTR_FORCE_CONTIGUOUS) {
                /*
                 * DMA_ATTR_FORCE_CONTIGUOUS allocations are always remapped,
@@ -272,6 +277,11 @@ static int __iommu_get_sgtable(struct device *dev, struct sg_table *sgt,
        unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
        struct vm_struct *area = find_vm_area(cpu_addr);
 
+       if (!is_vmalloc_addr(cpu_addr)) {
+               struct page *page = virt_to_page(cpu_addr);
+               return __swiotlb_get_sgtable_page(sgt, page, size);
+       }
+
        if (attrs & DMA_ATTR_FORCE_CONTIGUOUS) {
                /*
                 * DMA_ATTR_FORCE_CONTIGUOUS allocations are always remapped,