diff options
author | Christoph Hellwig <hch@lst.de> | 2019-08-06 15:01:50 +0300 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2019-09-04 11:13:18 +0200 |
commit | f9f3232a7d0ab73a33d11f4056c5823010f03d55 (patch) | |
tree | 021c07b01f104492a5d049a885bc8fb931839c34 /kernel/dma | |
parent | 14451467014b4c8aff6570b44b6d0ee68cd49bc0 (diff) | |
download | lwn-f9f3232a7d0ab73a33d11f4056c5823010f03d55.tar.gz lwn-f9f3232a7d0ab73a33d11f4056c5823010f03d55.zip |
dma-mapping: explicitly wire up ->mmap and ->get_sgtable
While the default ->mmap and ->get_sgtable implementations work for the
majority of our dma_map_ops impementations they are inherently safe
for others that don't use the page allocator or CMA and/or use their
own way of remapping not covered by the common code. So remove the
defaults if these methods are not wired up, but instead wire up the
default implementations for all safe instances.
Fixes: e1c7e324539a ("dma-mapping: always provide the dma_map_ops based implementation")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'kernel/dma')
-rw-r--r-- | kernel/dma/mapping.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index a136932b8e6d..c8b4e46407ba 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -153,11 +153,12 @@ int dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, { const struct dma_map_ops *ops = get_dma_ops(dev); - if (!dma_is_direct(ops) && ops->get_sgtable) - return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size, - attrs); - return dma_common_get_sgtable(dev, sgt, cpu_addr, dma_addr, size, - attrs); + if (dma_is_direct(ops)) + return dma_common_get_sgtable(dev, sgt, cpu_addr, dma_addr, + size, attrs); + if (!ops->get_sgtable) + return -ENXIO; + return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size, attrs); } EXPORT_SYMBOL(dma_get_sgtable_attrs); @@ -240,9 +241,12 @@ int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, { const struct dma_map_ops *ops = get_dma_ops(dev); - if (!dma_is_direct(ops) && ops->mmap) - return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs); - return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size, attrs); + if (dma_is_direct(ops)) + return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size, + attrs); + if (!ops->mmap) + return -ENXIO; + return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs); } EXPORT_SYMBOL(dma_mmap_attrs); |