From 89174b5e014070ad39cff5b17749718c4e02f602 Mon Sep 17 00:00:00 2001 From: Robin Gong Date: Fri, 24 Mar 2017 16:46:52 +0800 Subject: [PATCH] MLK-14514-2 dma: sdma: use dma_pool_free instead of dma_free_coherent Some drivers may call terminate dma channel in interrupt, thus we'd better use dma_poo_free.(Documentation/DMA-API-HOWTO.txt) Signed-off-by: Robin Gong --- drivers/dma/imx-sdma.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index d8c8bad15df0..662a4919f4dd 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -347,6 +348,7 @@ struct sdma_channel { u32 bd_size_sum; bool src_dualfifo; bool dst_dualfifo; + struct dma_pool *bd_pool; }; #define IMX_DMA_SG_LOOP BIT(0) @@ -1197,8 +1199,8 @@ static int sdma_alloc_bd(struct sdma_desc *desc) &desc->bd_phys); if (!desc->bd) { desc->bd_iram = false; - desc->bd = dma_alloc_coherent(desc->sdmac->sdma->dev, bd_size, - &desc->bd_phys, GFP_ATOMIC); + desc->bd = dma_pool_alloc(desc->sdmac->bd_pool, GFP_ATOMIC, + &desc->bd_phys); if (!desc->bd) return ret; } @@ -1221,8 +1223,8 @@ static void sdma_free_bd(struct sdma_desc *desc) gen_pool_free(desc->sdmac->sdma->iram_pool, (unsigned long)desc->bd, bd_size); else - dma_free_coherent(desc->sdmac->sdma->dev, bd_size, - desc->bd, desc->bd_phys); + dma_pool_free(desc->sdmac->bd_pool, desc->bd, + desc->bd_phys); spin_lock_irqsave(&desc->sdmac->vc.lock, flags); desc->sdmac->bd_size_sum -= bd_size; spin_unlock_irqrestore(&desc->sdmac->vc.lock, flags); @@ -1397,6 +1399,10 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) sdmac->bd_size_sum = 0; + sdmac->bd_pool = dma_pool_create("bd_pool", chan->device->dev, + sizeof(struct sdma_buffer_descriptor), + 32, 0); + return 0; disable_clk_ahb: @@ -1424,6 +1430,9 @@ static void sdma_free_chan_resources(struct dma_chan *chan) clk_disable(sdma->clk_ipg); clk_disable(sdma->clk_ahb); + + dma_pool_destroy(sdmac->bd_pool); + sdmac->bd_pool = NULL; } static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, -- 2.17.1