Commit 8668b38c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

sparc/iommu: move per-page flushing into __sbus_iommu_map_page

This prepares for reusing __sbus_iommu_map_page in the map_sg path.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b8205942
...@@ -207,7 +207,7 @@ static u32 iommu_get_one(struct device *dev, phys_addr_t paddr, int npages) ...@@ -207,7 +207,7 @@ static u32 iommu_get_one(struct device *dev, phys_addr_t paddr, int npages)
} }
static dma_addr_t __sbus_iommu_map_page(struct device *dev, struct page *page, static dma_addr_t __sbus_iommu_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t len) unsigned long offset, size_t len, bool per_page_flush)
{ {
void *vaddr = page_address(page) + offset; void *vaddr = page_address(page) + offset;
unsigned long off = (unsigned long)vaddr & ~PAGE_MASK; unsigned long off = (unsigned long)vaddr & ~PAGE_MASK;
...@@ -216,6 +216,16 @@ static dma_addr_t __sbus_iommu_map_page(struct device *dev, struct page *page, ...@@ -216,6 +216,16 @@ static dma_addr_t __sbus_iommu_map_page(struct device *dev, struct page *page,
/* XXX So what is maxphys for us and how do drivers know it? */ /* XXX So what is maxphys for us and how do drivers know it? */
if (!len || len > 256 * 1024) if (!len || len > 256 * 1024)
return DMA_MAPPING_ERROR; return DMA_MAPPING_ERROR;
if (per_page_flush) {
unsigned long p = (unsigned long)vaddr & PAGE_MASK;
while (p < (unsigned long)vaddr + len) {
flush_page_for_dma(p);
p += PAGE_SIZE;
}
}
return iommu_get_one(dev, virt_to_phys(vaddr), npages) + off; return iommu_get_one(dev, virt_to_phys(vaddr), npages) + off;
} }
...@@ -224,22 +234,14 @@ static dma_addr_t sbus_iommu_map_page_gflush(struct device *dev, ...@@ -224,22 +234,14 @@ static dma_addr_t sbus_iommu_map_page_gflush(struct device *dev,
enum dma_data_direction dir, unsigned long attrs) enum dma_data_direction dir, unsigned long attrs)
{ {
flush_page_for_dma(0); flush_page_for_dma(0);
return __sbus_iommu_map_page(dev, page, offset, len); return __sbus_iommu_map_page(dev, page, offset, len, false);
} }
static dma_addr_t sbus_iommu_map_page_pflush(struct device *dev, static dma_addr_t sbus_iommu_map_page_pflush(struct device *dev,
struct page *page, unsigned long offset, size_t len, struct page *page, unsigned long offset, size_t len,
enum dma_data_direction dir, unsigned long attrs) enum dma_data_direction dir, unsigned long attrs)
{ {
void *vaddr = page_address(page) + offset; return __sbus_iommu_map_page(dev, page, offset, len, true);
unsigned long p = ((unsigned long)vaddr) & PAGE_MASK;
while (p < (unsigned long)vaddr + len) {
flush_page_for_dma(p);
p += PAGE_SIZE;
}
return __sbus_iommu_map_page(dev, page, offset, len);
} }
static int __sbus_iommu_map_sg(struct device *dev, struct scatterlist *sgl, static int __sbus_iommu_map_sg(struct device *dev, struct scatterlist *sgl,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment