LF-251-2: dma: mxs-dma: switch from dma_coherent to dma_pool
create one dma_pool dedicate for all following dma_alloc and avoid keeping allocate available memories. Signed-off-by: Han Xu <han.xu@nxp.com>5.4-rM2-2.2.x-imx-squashed
parent
49fc3313af
commit
509289ed60
|
@ -26,6 +26,7 @@
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/dma/mxs-dma.h>
|
#include <linux/dma/mxs-dma.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
|
#include <linux/dmapool.h>
|
||||||
|
|
||||||
#include <asm/irq.h>
|
#include <asm/irq.h>
|
||||||
|
|
||||||
|
@ -121,6 +122,7 @@ struct mxs_dma_chan {
|
||||||
enum dma_status status;
|
enum dma_status status;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
bool reset;
|
bool reset;
|
||||||
|
struct dma_pool *ccw_pool;
|
||||||
#define MXS_DMA_SG_LOOP (1 << 0)
|
#define MXS_DMA_SG_LOOP (1 << 0)
|
||||||
#define MXS_DMA_USE_SEMAPHORE (1 << 1)
|
#define MXS_DMA_USE_SEMAPHORE (1 << 1)
|
||||||
};
|
};
|
||||||
|
@ -422,9 +424,10 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
|
||||||
struct device *dev = &mxs_dma->pdev->dev;
|
struct device *dev = &mxs_dma->pdev->dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mxs_chan->ccw = dma_alloc_coherent(mxs_dma->dma_device.dev,
|
mxs_chan->ccw = dma_pool_zalloc(mxs_chan->ccw_pool,
|
||||||
CCW_BLOCK_SIZE,
|
GFP_ATOMIC,
|
||||||
&mxs_chan->ccw_phys, GFP_KERNEL);
|
&mxs_chan->ccw_phys);
|
||||||
|
|
||||||
if (!mxs_chan->ccw) {
|
if (!mxs_chan->ccw) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err_alloc;
|
goto err_alloc;
|
||||||
|
@ -454,8 +457,8 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
|
||||||
err_clk:
|
err_clk:
|
||||||
free_irq(mxs_chan->chan_irq, mxs_dma);
|
free_irq(mxs_chan->chan_irq, mxs_dma);
|
||||||
err_irq:
|
err_irq:
|
||||||
dma_free_coherent(mxs_dma->dma_device.dev, CCW_BLOCK_SIZE,
|
dma_pool_free(mxs_chan->ccw_pool, mxs_chan->ccw,
|
||||||
mxs_chan->ccw, mxs_chan->ccw_phys);
|
mxs_chan->ccw_phys);
|
||||||
err_alloc:
|
err_alloc:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -470,8 +473,8 @@ static void mxs_dma_free_chan_resources(struct dma_chan *chan)
|
||||||
|
|
||||||
free_irq(mxs_chan->chan_irq, mxs_dma);
|
free_irq(mxs_chan->chan_irq, mxs_dma);
|
||||||
|
|
||||||
dma_free_coherent(mxs_dma->dma_device.dev, CCW_BLOCK_SIZE,
|
dma_pool_free(mxs_chan->ccw_pool, mxs_chan->ccw,
|
||||||
mxs_chan->ccw, mxs_chan->ccw_phys);
|
mxs_chan->ccw_phys);
|
||||||
|
|
||||||
pm_runtime_mark_last_busy(dev);
|
pm_runtime_mark_last_busy(dev);
|
||||||
pm_runtime_put_autosuspend(dev);
|
pm_runtime_put_autosuspend(dev);
|
||||||
|
@ -802,6 +805,7 @@ static int mxs_dma_probe(struct platform_device *pdev)
|
||||||
const struct mxs_dma_type *dma_type;
|
const struct mxs_dma_type *dma_type;
|
||||||
struct mxs_dma_engine *mxs_dma;
|
struct mxs_dma_engine *mxs_dma;
|
||||||
struct resource *iores;
|
struct resource *iores;
|
||||||
|
struct dma_pool *ccw_pool;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
mxs_dma = devm_kzalloc(&pdev->dev, sizeof(*mxs_dma), GFP_KERNEL);
|
mxs_dma = devm_kzalloc(&pdev->dev, sizeof(*mxs_dma), GFP_KERNEL);
|
||||||
|
@ -849,7 +853,6 @@ static int mxs_dma_probe(struct platform_device *pdev)
|
||||||
tasklet_init(&mxs_chan->tasklet, mxs_dma_tasklet,
|
tasklet_init(&mxs_chan->tasklet, mxs_dma_tasklet,
|
||||||
(unsigned long) mxs_chan);
|
(unsigned long) mxs_chan);
|
||||||
|
|
||||||
|
|
||||||
/* Add the channel to mxs_chan list */
|
/* Add the channel to mxs_chan list */
|
||||||
list_add_tail(&mxs_chan->chan.device_node,
|
list_add_tail(&mxs_chan->chan.device_node,
|
||||||
&mxs_dma->dma_device.channels);
|
&mxs_dma->dma_device.channels);
|
||||||
|
@ -864,6 +867,17 @@ static int mxs_dma_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
mxs_dma->dma_device.dev = &pdev->dev;
|
mxs_dma->dma_device.dev = &pdev->dev;
|
||||||
|
|
||||||
|
/* create the dma pool */
|
||||||
|
ccw_pool = dma_pool_create("ccw_pool",
|
||||||
|
mxs_dma->dma_device.dev,
|
||||||
|
CCW_BLOCK_SIZE, 32, 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 */
|
/* mxs_dma gets 65535 bytes maximum sg size */
|
||||||
mxs_dma->dma_device.dev->dma_parms = &mxs_dma->dma_parms;
|
mxs_dma->dma_device.dev->dma_parms = &mxs_dma->dma_parms;
|
||||||
dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
|
dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
|
||||||
|
|
Loading…
Reference in New Issue