kernel/dma: export dma_alloc_from_contiguous to modules
Subsystems (2)
PATCH 1/1 kernel/dma: export dma_alloc_from_contiguous to modules
From: Miles Chen <[email protected]>
This change exports dma_alloc_from_contiguous anddma_release_from_contiguous to modules.
Currently, we can add a reserve a memory node in dts files, make it a CMA memory by setting compatible = "shared-dma-pool",
and setup the dev->cma_area by using of_reserved_mem_device_init_by_idx().
Export dma_alloc_from_contiguous and dma_release_from_contiguous, so we can allocate/free from/to dev->cma_area in kernel modules.
--- kernel/dma/contiguous.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/dma/contiguous.c +2 -0
@@ -197,6 +197,7 @@ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,return cma_alloc (dev_get_cma_area (dev), count, align, no_warn); } +EXPORT_SYMBOL_GPL (dma_alloc_from_contiguous);/** * dma_release_from_contiguous() - release allocated pages
@@ -213,6 +214,7 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages, {return cma_release (dev_get_cma_area (dev), pages, count); } +EXPORT_SYMBOL_GPL (dma_release_from_contiguous);/* * Support for reserved memory regions defined in device tree
Signature · 1 line
2.18.0
Robin Murphy
reviewerQuoted 11 lines · On 11/07/2019 06:33, [email protected] wrote:
From: Miles Chen <[email protected]>
This change exports
dma_alloc_from_contiguousanddma_release_from_contiguousto modules.Currently, we can add a reserve a memory node in dts files, make it a CMA memory by setting compatible = "shared-dma-pool",
and setup thedev->cma_areaby usingof_reserved_mem_device_init_by_idx().Export
dma_alloc_from_contiguousanddma_release_from_contiguous, so we can allocate/free from/todev->cma_areain kernel modules.
As far as I understand, this was never intended for drivers to call directly. If a device has its own private CMA area, then regular dma_alloc_attrs() should allocate from that automatically; if that's not happening already, then there's a bug somewhere.
Robin.
Quoted 26 lines
Signed-off-by Miles Chen <[email protected]>--- kernel/dma/contiguous.c | 2 ++ 1 file changed, 2 insertions(+)kernel/dma/contiguous.c +2
-0@@ -197,6 +197,7 @@ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,return cma_alloc (dev_get_cma_area (dev), count, align, no_warn); } +EXPORT_SYMBOL_GPL (dma_alloc_from_contiguous);/** * dma_release_from_contiguous() - release allocated pages @@ -213,6 +214,7 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages, {return cma_release (dev_get_cma_area (dev), pages, count); } +EXPORT_SYMBOL_GPL (dma_release_from_contiguous);/* * Support for reserved memory regions defined in device tree
Quoted 10 lines · Robin Murphy
Quoted 9 lines · On 11/07/2019 06:33, [email protected] wrote:
From: Miles Chen <[email protected]>
This change exports
dma_alloc_from_contiguousanddma_release_from_contiguousto modules.Currently, we can add a reserve a memory node in dts files, make it a CMA memory by setting compatible = "shared-dma-pool",
and setup thedev->cma_areaby usingof_reserved_mem_device_init_by_idx().
Quoted 7 lines
Quoted 2 lines
Export
dma_alloc_from_contiguousanddma_release_from_contiguous, so we can allocate/free from/todev->cma_areain kernel modules.As far as I understand, this was never intended for drivers to call directly. If a device has its own private CMA area, then regular
dma_alloc_attrs()should allocate from that automatically; if that's not happening already, then there's a bug somewhere.
Agreed.
Quoted 13 lines · Robin Murphy
Quoted 11 lines · On 11/07/2019 06:33, [email protected] wrote:
From: Miles Chen <[email protected]>
This change exports
dma_alloc_from_contiguousanddma_release_from_contiguousto modules.Currently, we can add a reserve a memory node in dts files, make it a CMA memory by setting compatible = "shared-dma-pool",
and setup thedev->cma_areaby usingof_reserved_mem_device_init_by_idx().Export
dma_alloc_from_contiguousanddma_release_from_contiguous, so we can allocate/free from/todev->cma_areain kernel modules.
Quoted 6 lines
As far as I understand, this was never intended for drivers to call directly. If a device has its own private CMA area, then regular
dma_alloc_attrs()should allocate from that automatically; if that's not happening already, then there's a bug somewhere.Robin.
Thanks for your comment.
After using dma_direct_ops, dma_alloc_attrs() works fine now.
Miles
Quoted 27 lines
Quoted 27 lines
Signed-off-by Miles Chen <[email protected]>--- kernel/dma/contiguous.c | 2 ++ 1 file changed, 2 insertions(+)kernel/dma/contiguous.c +2
-0@@ -197,6 +197,7 @@ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,return cma_alloc (dev_get_cma_area (dev), count, align, no_warn); } +EXPORT_SYMBOL_GPL (dma_alloc_from_contiguous);/** * dma_release_from_contiguous() - release allocated pages @@ -213,6 +214,7 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages, {return cma_release (dev_get_cma_area (dev), pages, count); } +EXPORT_SYMBOL_GPL (dma_release_from_contiguous);/* * Support for reserved memory regions defined in device tree