[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260128-dma_ll_comlib-v1-5-1b1fa2c671f9@nxp.com>
Date: Wed, 28 Jan 2026 13:05:24 -0500
From: Frank Li <Frank.Li@....com>
To: Vinod Koul <vkoul@...nel.org>
Cc: linux-kernel@...r.kernel.org, dmaengine@...r.kernel.org,
imx@...ts.linux.dev, joy.zou@....com, Frank Li <Frank.Li@....com>
Subject: [PATCH RFC 05/12] dmaengine: Add DMA pool allocation in
vchan_dma_ll_init() and API vchan_dma_ll_free()
Add DMA pool allocation in vchan_dma_ll_init() and API vchan_dma_ll_free().
Update fsl-edma to remove its local DMA pool create/free logic, as this is
now handled by the common library.
No functional change.
Signed-off-by: Frank Li <Frank.Li@....com>
---
drivers/dma/fsl-edma-common.c | 11 ++---------
drivers/dma/ll-dma.c | 17 +++++++++++++++++
drivers/dma/virt-dma.h | 1 +
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c
index 17a8e28037f5e61d4aafbd7f32bde407ecc01a4d..1b5dcb4c333e7b9a0b1b3bd7964dcff94641bd79 100644
--- a/drivers/dma/fsl-edma-common.c
+++ b/drivers/dma/fsl-edma-common.c
@@ -856,12 +856,6 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
if (ret)
return ret;
- fsl_chan->vchan.ll.pool =
- dma_pool_create("tcd_pool", chan->device->dev,
- fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_TCD64 ?
- sizeof(struct fsl_edma_hw_tcd64) : sizeof(struct fsl_edma_hw_tcd),
- 32, 0);
-
if (fsl_chan->txirq)
ret = request_irq(fsl_chan->txirq, fsl_chan->irq_handler, IRQF_SHARED,
fsl_chan->chan_name, fsl_chan);
@@ -882,7 +876,7 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
if (fsl_chan->txirq)
free_irq(fsl_chan->txirq, fsl_chan);
err_txirq:
- dma_pool_destroy(fsl_chan->vchan.ll.pool);
+ vchan_dma_ll_free(&fsl_chan->vchan);
clk_disable_unprepare(fsl_chan->clk);
return ret;
@@ -910,8 +904,7 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan)
free_irq(fsl_chan->errirq, fsl_chan);
vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
- dma_pool_destroy(fsl_chan->vchan.ll.pool);
- fsl_chan->vchan.ll.pool = NULL;
+ vchan_dma_ll_free(&fsl_chan->vchan);
fsl_chan->is_sw = false;
fsl_chan->srcid = 0;
fsl_chan->is_remote = false;
diff --git a/drivers/dma/ll-dma.c b/drivers/dma/ll-dma.c
index 3845cca7926eb71f008cb98d8c622cb28a2369a5..3b6de65ae83c070d2ca588abf6bca2c49c1d7bd2 100644
--- a/drivers/dma/ll-dma.c
+++ b/drivers/dma/ll-dma.c
@@ -17,6 +17,7 @@
*/
#include <linux/cleanup.h>
#include <linux/device.h>
+#include <linux/dmapool.h>
#include <linux/dmaengine.h>
#include <linux/module.h>
#include <linux/spinlock.h>
@@ -32,10 +33,26 @@ int vchan_dma_ll_init(struct virt_dma_chan *vc,
vc->ll.ops = ops;
+ vc->ll.pool = dma_pool_create(dev_name(vc->chan.device->dev),
+ vc->chan.device->dev, size, align,
+ boundary);
+ if (!vc->ll.pool) {
+ dev_err(&vc->chan.dev->device,
+ "Unable to allocate descriptor pool\n");
+ return -ENOMEM;
+ }
+
return 0;
}
EXPORT_SYMBOL_GPL(vchan_dma_ll_init);
+void vchan_dma_ll_free(struct virt_dma_chan *vc)
+{
+ dma_pool_destroy(vc->ll.pool);
+ vc->ll.pool = NULL;
+}
+EXPORT_SYMBOL_GPL(vchan_dma_ll_free);
+
int vchan_dma_ll_terminate_all(struct dma_chan *chan)
{
struct virt_dma_chan *vchan = to_virt_chan(chan);
diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h
index 82f3f8244f6eca036a027c9a4c9339fcb87e8d2c..e3311be3d917ea1e0d5f4fb0e6781c7d0737c0a5 100644
--- a/drivers/dma/virt-dma.h
+++ b/drivers/dma/virt-dma.h
@@ -276,6 +276,7 @@ static inline struct dma_ll_desc *to_dma_ll_desc(struct virt_dma_desc *vdesc)
int vchan_dma_ll_init(struct virt_dma_chan *vc,
const struct dma_linklist_ops *ops, size_t size,
size_t align, size_t boundary);
+void vchan_dma_ll_free(struct virt_dma_chan *vc);
int vchan_dma_ll_terminate_all(struct dma_chan *chan);
#endif
--
2.34.1
Powered by blists - more mailing lists