[PATCH v2 1/3] dmaengine: fsl-dpaa2-qdma: Fix the size of dma pools

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In case of long format of qDMA command descriptor, there are one frame
descriptor, three entries in the frame list and two data entries. So the
size of dma_pool_create for these three fields should be the same with
the total size of entries respectively, or the contents may be overwritten
by the next allocated descriptor.

Signed-off-by: Guanhua Gao <guanhua.gao@xxxxxxx>
---
Change in v2:
 - Add comments for changes.
 - Update copyright year.

 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
index 4ec909e0b810..de3eff3f3de3 100644
--- a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
+++ b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-// Copyright 2019 NXP
+// Copyright 2019-2021 NXP
 
 #include <linux/init.h>
 #include <linux/module.h>
@@ -32,21 +32,29 @@ static int dpaa2_qdma_alloc_chan_resources(struct dma_chan *chan)
 	struct dpaa2_qdma_engine *dpaa2_qdma = dpaa2_chan->qdma;
 	struct device *dev = &dpaa2_qdma->priv->dpdmai_dev->dev;
 
+	/* dma pool for compound command descriptor */
 	dpaa2_chan->fd_pool = dma_pool_create("fd_pool", dev,
 					      sizeof(struct dpaa2_fd),
 					      sizeof(struct dpaa2_fd), 0);
 	if (!dpaa2_chan->fd_pool)
 		goto err;
 
-	dpaa2_chan->fl_pool = dma_pool_create("fl_pool", dev,
-					      sizeof(struct dpaa2_fl_entry),
-					      sizeof(struct dpaa2_fl_entry), 0);
+	/*
+	 * dma pool for descriptor entry, source data entry, and
+	 * destination data entry.
+	 */
+	dpaa2_chan->fl_pool =
+		dma_pool_create("fl_pool", dev,
+				 sizeof(struct dpaa2_fl_entry) * 3,
+				 sizeof(struct dpaa2_fl_entry), 0);
+
 	if (!dpaa2_chan->fl_pool)
 		goto err_fd;
 
+	/* dma pool for source descriptor and destination descriptor */
 	dpaa2_chan->sdd_pool =
 		dma_pool_create("sdd_pool", dev,
-				sizeof(struct dpaa2_qdma_sd_d),
+				sizeof(struct dpaa2_qdma_sd_d) * 2,
 				sizeof(struct dpaa2_qdma_sd_d), 0);
 	if (!dpaa2_chan->sdd_pool)
 		goto err_fl;
-- 
2.25.1




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux