summaryrefslogtreecommitdiff
path: root/kernel/dma/direct.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-12-03 13:14:09 +0300
committerChristoph Hellwig <hch@lst.de>2018-12-13 23:06:16 +0300
commit17ac524719f3fc88c1a90528f4789e4b4f618512 (patch)
tree74b15a90304fbfabbd20fff234cf966bf8095add /kernel/dma/direct.c
parent58dfd4ac022037c6a562e92fc6d2a778819b2162 (diff)
downloadlinux-17ac524719f3fc88c1a90528f4789e4b4f618512.tar.xz
dma-direct: use dma_direct_map_page to implement dma_direct_map_sg
No need to duplicate the mapping logic. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Tested-by: Jesper Dangaard Brouer <brouer@redhat.com> Tested-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'kernel/dma/direct.c')
-rw-r--r--kernel/dma/direct.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index edb24f94ea1e..d45306473c90 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -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);
}
+#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE)
static void dma_direct_sync_sg_for_device(struct device *dev,
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,
for_each_sg(sgl, sg, nents, i)
arch_sync_dma_for_device(dev, sg_phys(sg), sg->length, dir);
}
+#endif
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
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,
struct scatterlist *sg;
for_each_sg(sgl, sg, nents, i) {
- BUG_ON(!sg_page(sg));
-
- sg_dma_address(sg) = phys_to_dma(dev, sg_phys(sg));
- if (unlikely(dev && !dma_capable(dev, sg_dma_address(sg),
- sg->length))) {
- report_addr(dev, sg_dma_address(sg), sg->length);
+ sg->dma_address = dma_direct_map_page(dev, sg_page(sg),
+ sg->offset, sg->length, dir, attrs);
+ if (sg->dma_address == DMA_MAPPING_ERROR)
return 0;
- }
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;
}