// SPDX-License-Identifier: GPL-2.0
/*
- * lib/dma-noop.c
- *
- * DMA operations that map to physical addresses without flushing memory.
+ * DMA operations that map physical memory directly without using an IOMMU or
+ * flushing caches.
*/
#include <linux/export.h>
#include <linux/mm.h>
-#include <linux/dma-mapping.h>
+#include <linux/dma-direct.h>
#include <linux/scatterlist.h>
#include <linux/pfn.h>
ret = (void *)__get_free_pages(gfp, get_order(size));
if (ret)
- *dma_handle = virt_to_phys(ret) - PFN_PHYS(dev->dma_pfn_offset);
+ *dma_handle = phys_to_dma(dev, virt_to_phys(ret));
return ret;
}
unsigned long offset, size_t size, enum dma_data_direction dir,
unsigned long attrs)
{
- return page_to_phys(page) + offset - PFN_PHYS(dev->dma_pfn_offset);
+ return phys_to_dma(dev, page_to_phys(page)) + offset;
}
static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
struct scatterlist *sg;
for_each_sg(sgl, sg, nents, i) {
- dma_addr_t offset = PFN_PHYS(dev->dma_pfn_offset);
- void *va;
-
BUG_ON(!sg_page(sg));
- va = sg_virt(sg);
- sg_dma_address(sg) = (dma_addr_t)virt_to_phys(va) - offset;
+
+ sg_dma_address(sg) = phys_to_dma(dev, sg_phys(sg));
sg_dma_len(sg) = sg->length;
}