Commit 17ac5247 authored by Christoph Hellwig's avatar Christoph Hellwig

dma-direct: use dma_direct_map_page to implement dma_direct_map_sg

No need to duplicate the mapping logic.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Tested-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Tested-by: default avatarTony Luck <tony.luck@intel.com>
parent 58dfd4ac
...@@ -217,6 +217,7 @@ static void dma_direct_sync_single_for_device(struct device *dev, ...@@ -217,6 +217,7 @@ static void dma_direct_sync_single_for_device(struct device *dev,
arch_sync_dma_for_device(dev, dma_to_phys(dev, addr), size, dir); arch_sync_dma_for_device(dev, dma_to_phys(dev, addr), size, dir);
} }
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE)
static void dma_direct_sync_sg_for_device(struct device *dev, static void dma_direct_sync_sg_for_device(struct device *dev,
struct scatterlist *sgl, int nents, enum dma_data_direction dir) struct scatterlist *sgl, int nents, enum dma_data_direction dir)
{ {
...@@ -229,6 +230,7 @@ static void dma_direct_sync_sg_for_device(struct device *dev, ...@@ -229,6 +230,7 @@ static void dma_direct_sync_sg_for_device(struct device *dev,
for_each_sg(sgl, sg, nents, i) for_each_sg(sgl, sg, nents, i)
arch_sync_dma_for_device(dev, sg_phys(sg), sg->length, dir); arch_sync_dma_for_device(dev, sg_phys(sg), sg->length, dir);
} }
#endif
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
...@@ -294,19 +296,13 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents, ...@@ -294,19 +296,13 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
struct scatterlist *sg; struct scatterlist *sg;
for_each_sg(sgl, sg, nents, i) { for_each_sg(sgl, sg, nents, i) {
BUG_ON(!sg_page(sg)); sg->dma_address = dma_direct_map_page(dev, sg_page(sg),
sg->offset, sg->length, dir, attrs);
sg_dma_address(sg) = phys_to_dma(dev, sg_phys(sg)); if (sg->dma_address == DMA_MAPPING_ERROR)
if (unlikely(dev && !dma_capable(dev, sg_dma_address(sg),
sg->length))) {
report_addr(dev, sg_dma_address(sg), sg->length);
return 0; return 0;
}
sg_dma_len(sg) = sg->length; sg_dma_len(sg) = sg->length;
} }
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
dma_direct_sync_sg_for_device(dev, sgl, nents, dir);
return nents; return nents;
} }
......
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