lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260128-dma_ll_comlib-v1-6-1b1fa2c671f9@nxp.com>
Date: Wed, 28 Jan 2026 13:05:25 -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 06/12] dmaengine: Move fsl_edma_(alloc|free)_desc() to
 common library

Move fsl_edma_(alloc|free)_desc() to the common DMA link-list library and
rename them to vchan_dma_ll_(alloc|free)_desc().

Remove the "fsl_" prefix from local variables accordingly.

No functional change.

Signed-off-by: Frank Li <Frank.Li@....com>
---
 drivers/dma/fsl-edma-common.c | 47 +++----------------------------------------
 drivers/dma/fsl-edma-common.h |  1 -
 drivers/dma/fsl-edma-main.c   |  2 +-
 drivers/dma/ll-dma.c          | 43 +++++++++++++++++++++++++++++++++++++++
 drivers/dma/mcf-edma-main.c   |  2 +-
 drivers/dma/virt-dma.h        |  2 ++
 6 files changed, 50 insertions(+), 47 deletions(-)

diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c
index 1b5dcb4c333e7b9a0b1b3bd7964dcff94641bd79..20b954221c2e9b3b3a6849c1f0d4ca68efecb32e 100644
--- a/drivers/dma/fsl-edma-common.c
+++ b/drivers/dma/fsl-edma-common.c
@@ -221,19 +221,6 @@ static unsigned int fsl_edma_get_tcd_attr(enum dma_slave_buswidth src_addr_width
 	return dst_val | (src_val << 8);
 }
 
-void fsl_edma_free_desc(struct virt_dma_desc *vdesc)
-{
-	struct dma_ll_desc *fsl_desc;
-	int i;
-
-	fsl_desc = to_dma_ll_desc(vdesc);
-	for (i = 0; i < fsl_desc->n_its; i++)
-		dma_pool_free(to_virt_chan(vdesc->tx.chan)->ll.pool,
-			      fsl_desc->its[i].vaddr,
-			      fsl_desc->its[i].paddr);
-	kfree(fsl_desc);
-}
-
 int fsl_edma_terminate_all(struct dma_chan *chan)
 {
 	struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
@@ -546,34 +533,6 @@ void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan,
 	trace_edma_fill_tcd(fsl_chan, tcd);
 }
 
-static struct dma_ll_desc *
-fsl_edma_alloc_desc(struct fsl_edma_chan *fsl_chan, int sg_len)
-{
-	struct dma_ll_desc *fsl_desc;
-	int i;
-
-	fsl_desc = kzalloc(struct_size(fsl_desc, its, sg_len), GFP_NOWAIT);
-	if (!fsl_desc)
-		return NULL;
-
-	fsl_desc->n_its = sg_len;
-	for (i = 0; i < sg_len; i++) {
-		fsl_desc->its[i].vaddr = dma_pool_alloc(fsl_chan->vchan.ll.pool,
-							GFP_NOWAIT,
-							&fsl_desc->its[i].paddr);
-		if (!fsl_desc->its[i].vaddr)
-			goto err;
-	}
-	return fsl_desc;
-
-err:
-	while (--i >= 0)
-		dma_pool_free(fsl_chan->vchan.ll.pool, fsl_desc->its[i].vaddr,
-			      fsl_desc->its[i].paddr);
-	kfree(fsl_desc);
-	return NULL;
-}
-
 struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic(
 		struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
 		size_t period_len, enum dma_transfer_direction direction,
@@ -596,7 +555,7 @@ struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic(
 		return NULL;
 
 	sg_len = buf_len / period_len;
-	fsl_desc = fsl_edma_alloc_desc(fsl_chan, sg_len);
+	fsl_desc = vchan_dma_ll_alloc_desc(chan, sg_len);
 	if (!fsl_desc)
 		return NULL;
 	fsl_desc->iscyclic = true;
@@ -679,7 +638,7 @@ struct dma_async_tx_descriptor *fsl_edma_prep_slave_sg(
 	if (!fsl_edma_prep_slave_dma(fsl_chan, direction))
 		return NULL;
 
-	fsl_desc = fsl_edma_alloc_desc(fsl_chan, sg_len);
+	fsl_desc = vchan_dma_ll_alloc_desc(chan, sg_len);
 	if (!fsl_desc)
 		return NULL;
 	fsl_desc->iscyclic = false;
@@ -774,7 +733,7 @@ struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan,
 	src_bus_width = min_t(u32, DMA_SLAVE_BUSWIDTH_32_BYTES, 1 << (ffs(dma_src) - 1));
 	dst_bus_width = min_t(u32, DMA_SLAVE_BUSWIDTH_32_BYTES, 1 << (ffs(dma_dst) - 1));
 
-	fsl_desc = fsl_edma_alloc_desc(fsl_chan, 1);
+	fsl_desc = vchan_dma_ll_alloc_desc(chan, 1);
 	if (!fsl_desc)
 		return NULL;
 	fsl_desc->iscyclic = false;
diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h
index 56d219d57b852e0769cbead11fadac89913747e2..654d05f06b2c1817e68e7afaf9de3439285d2978 100644
--- a/drivers/dma/fsl-edma-common.h
+++ b/drivers/dma/fsl-edma-common.h
@@ -464,7 +464,6 @@ void fsl_edma_tx_chan_handler(struct fsl_edma_chan *fsl_chan);
 void fsl_edma_disable_request(struct fsl_edma_chan *fsl_chan);
 void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan,
 			unsigned int slot, bool enable);
-void fsl_edma_free_desc(struct virt_dma_desc *vdesc);
 int fsl_edma_terminate_all(struct dma_chan *chan);
 int fsl_edma_pause(struct dma_chan *chan);
 int fsl_edma_resume(struct dma_chan *chan);
diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c
index a753b7cbfa7a3369d17314bc5bc9139c9f8e5c27..354e4ac5e46c920dd66ec1479a64c75a609c186d 100644
--- a/drivers/dma/fsl-edma-main.c
+++ b/drivers/dma/fsl-edma-main.c
@@ -808,7 +808,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
 		fsl_chan->pm_state = RUNNING;
 		fsl_chan->srcid = 0;
 		fsl_chan->dma_dir = DMA_NONE;
-		fsl_chan->vchan.desc_free = fsl_edma_free_desc;
+		fsl_chan->vchan.desc_free = vchan_dma_ll_free_desc;
 
 		len = (drvdata->flags & FSL_EDMA_DRV_SPLIT_REG) ?
 				offsetof(struct fsl_edma3_ch_reg, tcd) : 0;
diff --git a/drivers/dma/ll-dma.c b/drivers/dma/ll-dma.c
index 3b6de65ae83c070d2ca588abf6bca2c49c1d7bd2..ff9eac43886255c18550c978184c0801456fefe9 100644
--- a/drivers/dma/ll-dma.c
+++ b/drivers/dma/ll-dma.c
@@ -53,6 +53,49 @@ void vchan_dma_ll_free(struct virt_dma_chan *vc)
 }
 EXPORT_SYMBOL_GPL(vchan_dma_ll_free);
 
+struct dma_ll_desc *vchan_dma_ll_alloc_desc(struct dma_chan *chan, u32 n)
+{
+	struct virt_dma_chan *vchan = to_virt_chan(chan);
+	struct dma_ll_desc *desc;
+	u32 i;
+
+	desc = kzalloc(struct_size(desc, its, n), GFP_NOWAIT);
+	if (!desc)
+		return NULL;
+
+	desc->n_its = n;
+
+	for (i = 0; i < n; i++) {
+		desc->its[i].vaddr = dma_pool_alloc(vchan->ll.pool, GFP_NOWAIT,
+						    &desc->its[i].paddr);
+		if (!desc->its[i].vaddr)
+			goto err;
+	}
+
+	return desc;
+
+err:
+	while (--i >= 0)
+		dma_pool_free(vchan->ll.pool, desc->its[i].vaddr,
+			      desc->its[i].paddr);
+	kfree(desc);
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(vchan_dma_ll_alloc_desc);
+
+void vchan_dma_ll_free_desc(struct virt_dma_desc *vdesc)
+{
+	struct dma_ll_desc *desc = to_dma_ll_desc(vdesc);
+	struct virt_dma_chan *vchan = to_virt_chan(vdesc->tx.chan);
+	int i;
+
+	for (i = 0; i < desc->n_its; i++)
+		dma_pool_free(vchan->ll.pool, desc->its[i].vaddr,
+			      desc->its[i].paddr);
+	kfree(desc);
+}
+EXPORT_SYMBOL_GPL(vchan_dma_ll_free_desc);
+
 int vchan_dma_ll_terminate_all(struct dma_chan *chan)
 {
 	struct virt_dma_chan *vchan = to_virt_chan(chan);
diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
index 9e1c6400c77be237684855759382d7b7bd2e6ea0..60c5b928ade74d36c8f4206777921544787f6cd8 100644
--- a/drivers/dma/mcf-edma-main.c
+++ b/drivers/dma/mcf-edma-main.c
@@ -196,7 +196,7 @@ static int mcf_edma_probe(struct platform_device *pdev)
 		mcf_chan->edma = mcf_edma;
 		mcf_chan->srcid = i;
 		mcf_chan->dma_dir = DMA_NONE;
-		mcf_chan->vchan.desc_free = fsl_edma_free_desc;
+		mcf_chan->vchan.desc_free = vchan_dma_ll_free_desc;
 		vchan_init(&mcf_chan->vchan, &mcf_edma->dma_dev);
 		mcf_chan->tcd = mcf_edma->membase + EDMA_TCD
 				+ i * sizeof(struct fsl_edma_hw_tcd);
diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h
index e3311be3d917ea1e0d5f4fb0e6781c7d0737c0a5..a15f9e318ca5ec7fd3c4e6fc6864ad3d1dc3eaa5 100644
--- a/drivers/dma/virt-dma.h
+++ b/drivers/dma/virt-dma.h
@@ -277,6 +277,8 @@ 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);
+struct dma_ll_desc *vchan_dma_ll_alloc_desc(struct dma_chan *chan, u32 n);
+void vchan_dma_ll_free_desc(struct virt_dma_desc *vdesc);
 int vchan_dma_ll_terminate_all(struct dma_chan *chan);
 #endif
 

-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ