* [PATCH 1/1] dmaengine: mxs-dma: switch from dma_coherent to dma_pool
@ 2024-02-19 15:57 Frank Li
2024-02-19 16:23 ` Fabio Estevam
0 siblings, 1 reply; 4+ messages in thread
From: Frank Li @ 2024-02-19 15:57 UTC (permalink / raw)
To: Vinod Koul, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, NXP Linux Team,
open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
open list
Cc: imx
From: Han Xu <han.xu@nxp.com>
Using dma_pool to manage dma descriptor memory.
Signed-off-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/dma/mxs-dma.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index cfb9962417ef6..a60bf7a22492d 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -24,6 +24,7 @@
#include <linux/of_dma.h>
#include <linux/list.h>
#include <linux/dma/mxs-dma.h>
+#include <linux/dmapool.h>
#include <asm/irq.h>
@@ -104,6 +105,7 @@ struct mxs_dma_ccw {
#define CCW_BLOCK_SIZE (4 * PAGE_SIZE)
#define NUM_CCW (int)(CCW_BLOCK_SIZE / sizeof(struct mxs_dma_ccw))
+#define CCW_BLOCK_ALGIN 32
struct mxs_dma_chan {
struct mxs_dma_engine *mxs_dma;
@@ -117,6 +119,7 @@ struct mxs_dma_chan {
enum dma_status status;
unsigned int flags;
bool reset;
+ struct dma_pool *ccw_pool;
#define MXS_DMA_SG_LOOP (1 << 0)
#define MXS_DMA_USE_SEMAPHORE (1 << 1)
};
@@ -398,9 +401,8 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
int ret;
- mxs_chan->ccw = dma_alloc_coherent(mxs_dma->dma_device.dev,
- CCW_BLOCK_SIZE,
- &mxs_chan->ccw_phys, GFP_KERNEL);
+ mxs_chan->ccw = dma_pool_zalloc(mxs_chan->ccw_pool, GFP_ATOMIC, &mxs_chan->ccw_phys);
+
if (!mxs_chan->ccw) {
ret = -ENOMEM;
goto err_alloc;
@@ -428,8 +430,7 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
err_clk:
free_irq(mxs_chan->chan_irq, mxs_dma);
err_irq:
- dma_free_coherent(mxs_dma->dma_device.dev, CCW_BLOCK_SIZE,
- mxs_chan->ccw, mxs_chan->ccw_phys);
+ dma_pool_free(mxs_chan->ccw_pool, mxs_chan->ccw, mxs_chan->ccw_phys);
err_alloc:
return ret;
}
@@ -443,8 +444,7 @@ static void mxs_dma_free_chan_resources(struct dma_chan *chan)
free_irq(mxs_chan->chan_irq, mxs_dma);
- dma_free_coherent(mxs_dma->dma_device.dev, CCW_BLOCK_SIZE,
- mxs_chan->ccw, mxs_chan->ccw_phys);
+ dma_pool_free(mxs_chan->ccw_pool, mxs_chan->ccw, mxs_chan->ccw_phys);
clk_disable_unprepare(mxs_dma->clk);
}
@@ -745,6 +745,7 @@ static int mxs_dma_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
const struct mxs_dma_type *dma_type;
struct mxs_dma_engine *mxs_dma;
+ struct dma_pool *ccw_pool;
int ret, i;
mxs_dma = devm_kzalloc(&pdev->dev, sizeof(*mxs_dma), GFP_KERNEL);
@@ -797,6 +798,15 @@ static int mxs_dma_probe(struct platform_device *pdev)
mxs_dma->pdev = pdev;
mxs_dma->dma_device.dev = &pdev->dev;
+ ccw_pool = dma_pool_create("ccw_pool", mxs_dma->dma_device.dev, CCW_BLOCK_SIZE,
+ CCW_BLOCK_ALGIN, 0);
+
+ for (i = 0; i < MXS_DMA_CHANNELS; i++) {
+ struct mxs_dma_chan *mxs_chan = &mxs_dma->mxs_chans[i];
+
+ mxs_chan->ccw_pool = ccw_pool;
+ }
+
/* mxs_dma gets 65535 bytes maximum sg size */
dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] dmaengine: mxs-dma: switch from dma_coherent to dma_pool
2024-02-19 15:57 [PATCH 1/1] dmaengine: mxs-dma: switch from dma_coherent to dma_pool Frank Li
@ 2024-02-19 16:23 ` Fabio Estevam
2024-02-20 17:38 ` Frank Li
0 siblings, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2024-02-19 16:23 UTC (permalink / raw)
To: Frank Li
Cc: Vinod Koul, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
NXP Linux Team, open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
open list, imx
On Mon, Feb 19, 2024 at 12:57 PM Frank Li <Frank.Li@nxp.com> wrote:
>
> From: Han Xu <han.xu@nxp.com>
>
> Using dma_pool to manage dma descriptor memory.
Please clearly describe the motivation for doing this.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] dmaengine: mxs-dma: switch from dma_coherent to dma_pool
2024-02-19 16:23 ` Fabio Estevam
@ 2024-02-20 17:38 ` Frank Li
2024-02-22 13:47 ` Vinod Koul
0 siblings, 1 reply; 4+ messages in thread
From: Frank Li @ 2024-02-20 17:38 UTC (permalink / raw)
To: Fabio Estevam
Cc: Vinod Koul, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
NXP Linux Team, open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
open list, imx
On Mon, Feb 19, 2024 at 01:23:22PM -0300, Fabio Estevam wrote:
> On Mon, Feb 19, 2024 at 12:57 PM Frank Li <Frank.Li@nxp.com> wrote:
> >
> > From: Han Xu <han.xu@nxp.com>
> >
> > Using dma_pool to manage dma descriptor memory.
>
> Please clearly describe the motivation for doing this.
This try to fix a cma_alloc failure. But it is not correct to use dma_pool.
let's work out a better method.
Frank
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] dmaengine: mxs-dma: switch from dma_coherent to dma_pool
2024-02-20 17:38 ` Frank Li
@ 2024-02-22 13:47 ` Vinod Koul
0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2024-02-22 13:47 UTC (permalink / raw)
To: Frank Li
Cc: Fabio Estevam, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
NXP Linux Team, open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
open list, imx
On 20-02-24, 12:38, Frank Li wrote:
> On Mon, Feb 19, 2024 at 01:23:22PM -0300, Fabio Estevam wrote:
> > On Mon, Feb 19, 2024 at 12:57 PM Frank Li <Frank.Li@nxp.com> wrote:
> > >
> > > From: Han Xu <han.xu@nxp.com>
> > >
> > > Using dma_pool to manage dma descriptor memory.
> >
> > Please clearly describe the motivation for doing this.
>
> This try to fix a cma_alloc failure. But it is not correct to use dma_pool.
> let's work out a better method.
Good one, but this should be in log :-)
>
> Frank
--
~Vinod
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-22 13:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-19 15:57 [PATCH 1/1] dmaengine: mxs-dma: switch from dma_coherent to dma_pool Frank Li
2024-02-19 16:23 ` Fabio Estevam
2024-02-20 17:38 ` Frank Li
2024-02-22 13:47 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox