summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolin Chen <b42378@freescale.com>2013-07-30 14:49:29 +0800
committerNicolin Chen <b42378@freescale.com>2013-08-08 18:36:43 +0800
commit0af5e5c8fc507ebd85b76e5b2a6d81a5227e1b57 (patch)
tree6ae600a70918b2ae8c093d20b4795f0e9006ebe9
parentff126ab90b352607539b68db409ced07110bd37d (diff)
ENGR00273432 DMA: imx-sdma: Allocate 4KB iram page size for bd
One bd actually needs 4KB page size. So changed the iram_alloc() size parameter to allocate a precise iram memory for bd. This patch also removed the extra iram pool for SDMA due to its insufficient total size: SDMA allows around 48 channels to work simultaneously, so it's better to allocate memory from iram pool directly. [There will be 3KB size waste in sdma->channel_control, which is 640B but actually using 4KB due to 4KB alignment for iram pool.] Acked-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Nicolin Chen <b42378@freescale.com>
-rw-r--r--drivers/dma/imx-sdma.c52
1 files changed, 12 insertions, 40 deletions
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index bee75e8c85c5..81434d6af1bb 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -339,34 +339,6 @@ struct sdma_engine {
#define SDMA_H_CONFIG_ACR (1 << 4) /* indicates if AHB freq /core freq = 2 or 1 */
#define SDMA_H_CONFIG_CSM (3) /* indicates which context switch mode is selected*/
-#ifdef CONFIG_SDMA_IRAM
-static unsigned long sdma_iram_paddr;
-static void *sdma_iram_vaddr;
-#define sdma_iram_phys_to_virt(p) (sdma_iram_vaddr + ((p) - sdma_iram_paddr))
-#define sdma_iram_virt_to_phys(v) (sdma_iram_paddr + ((v) - sdma_iram_vaddr))
-static struct gen_pool *sdma_iram_pool;
-
-/*!
- * Allocates uncacheable buffer from IRAM
- */
-void __iomem *sdma_iram_malloc(size_t size, unsigned long *buf)
-{
- *buf = gen_pool_alloc(sdma_iram_pool, size);
- if (!buf)
- return NULL;
-
- return sdma_iram_phys_to_virt(*buf);
-}
-
-void sdma_iram_free(unsigned long buf, size_t size)
-{
- if (!sdma_iram_pool)
- return;
-
- gen_pool_free(sdma_iram_pool, buf, size);
-}
-#endif /*CONFIG_SDMA_IRAM */
-
static inline u32 chnenbl_ofs(struct sdma_engine *sdma, unsigned int event)
{
@@ -449,7 +421,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
int ret;
#ifdef CONFIG_SDMA_IRAM
- buf_virt = sdma_iram_malloc(size, (unsigned long *)&buf_phys);
+ buf_virt = iram_alloc(size, (unsigned long *)&buf_phys);
#else
buf_virt = dma_alloc_coherent(NULL,
size,
@@ -472,7 +444,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
#ifdef CONFIG_SDMA_IRAM
- sdma_iram_free(buf_phys, size);
+ iram_free(buf_phys, size);
#else
dma_free_coherent(NULL, size, buf_virt, buf_phys);
#endif
@@ -938,8 +910,7 @@ static int sdma_request_channel(struct sdma_channel *sdmac)
int ret = -EBUSY;
#ifdef CONFIG_SDMA_IRAM
- sdmac->bd = sdma_iram_malloc(sizeof(sdmac->bd),
- (unsigned long *)&sdmac->bd_phys);
+ sdmac->bd = iram_alloc(PAGE_SIZE, (unsigned long *)&sdmac->bd_phys);
#else
sdmac->bd = dma_alloc_noncached(NULL, PAGE_SIZE, &sdmac->bd_phys, GFP_KERNEL);
#endif
@@ -1106,7 +1077,7 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
sdma_set_channel_priority(sdmac, 0);
#ifdef CONFIG_SDMA_IRAM
- sdma_iram_free(sdmac->bd_phys, sizeof(sdmac->bd));
+ iram_free(sdmac->bd_phys, PAGE_SIZE);
#else
dma_free_coherent(NULL, PAGE_SIZE, sdmac->bd, sdmac->bd_phys);
#endif
@@ -1494,12 +1465,7 @@ static int __init sdma_init(struct sdma_engine *sdma)
writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
#ifdef CONFIG_SDMA_IRAM
- /* Allocate memory for SDMA channel and buffer descriptors */
- sdma_iram_vaddr = iram_alloc(SZ_4K, &sdma_iram_paddr);
- sdma_iram_pool = gen_pool_create(PAGE_SHIFT/2, -1);
- gen_pool_add(sdma_iram_pool, sdma_iram_paddr, SZ_4K, -1);
-
- sdma->channel_control = sdma_iram_malloc(MAX_DMA_CHANNELS *
+ sdma->channel_control = iram_alloc(MAX_DMA_CHANNELS *
sizeof(struct sdma_channel_control)
+ sizeof(struct sdma_context_data),
(unsigned long *)&ccb_phys);
@@ -1534,7 +1500,7 @@ static int __init sdma_init(struct sdma_engine *sdma)
ret = sdma_request_channel(&sdma->channel[0]);
if (ret)
- goto err_dma_alloc;
+ goto err_dma_request;
sdma_config_ownership(&sdma->channel[0], false, true, false);
@@ -1557,6 +1523,12 @@ static int __init sdma_init(struct sdma_engine *sdma)
return 0;
+err_dma_request:
+#ifdef CONFIG_SDMA_IRAM
+ iram_free((unsigned long)ccb_phys, MAX_DMA_CHANNELS
+ * sizeof(struct sdma_channel_control)
+ + sizeof(struct sdma_context_data));
+#endif
err_dma_alloc:
clk_disable(sdma->clk);
dev_err(sdma->dev, "initialisation failed with %d\n", ret);