aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/imx-dma.c
diff options
context:
space:
mode:
authorVinod Koul <vinod.koul@linux.intel.com>2012-03-13 03:09:49 -0400
committerVinod Koul <vinod.koul@linux.intel.com>2012-03-13 03:09:49 -0400
commit1f3d6dc0be92f0caca937926cca16ec4fdd585a3 (patch)
treea12562009ae984dd16ed080af13d0036b88a93a7 /drivers/dma/imx-dma.c
parent5170c051a56244816d948c43592c1b2805ed4f3a (diff)
parent949ff5b8d46b5e3435d21b2651ce3a2599208d44 (diff)
Merge branch 'rmk_cookie_fixes2' into next
Conflicts: drivers/dma/imx-dma.c drivers/dma/pl330.c Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'drivers/dma/imx-dma.c')
-rw-r--r--drivers/dma/imx-dma.c39
1 files changed, 7 insertions, 32 deletions
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index c32103f04fb3..20c1565a7486 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -32,6 +32,7 @@
32#include <mach/dma-v1.h> 32#include <mach/dma-v1.h>
33#include <mach/hardware.h> 33#include <mach/hardware.h>
34 34
35#include "dmaengine.h"
35#define IMXDMA_MAX_CHAN_DESCRIPTORS 16 36#define IMXDMA_MAX_CHAN_DESCRIPTORS 16
36 37
37enum imxdma_prep_type { 38enum imxdma_prep_type {
@@ -77,7 +78,8 @@ struct imxdma_channel {
77 u32 watermark_level; 78 u32 watermark_level;
78 struct dma_chan chan; 79 struct dma_chan chan;
79 spinlock_t lock; 80 spinlock_t lock;
80 dma_cookie_t last_completed; 81 struct dma_async_tx_descriptor desc;
82 enum dma_status status;
81 int dma_request; 83 int dma_request;
82 struct scatterlist *sg_list; 84 struct scatterlist *sg_list;
83}; 85};
@@ -192,7 +194,7 @@ static void imxdma_tasklet(unsigned long data)
192 if (desc->desc.callback) 194 if (desc->desc.callback)
193 desc->desc.callback(desc->desc.callback_param); 195 desc->desc.callback(desc->desc.callback_param);
194 196
195 imxdmac->last_completed = desc->desc.cookie; 197 dma_cookie_complete(&desc->desc);
196 198
197 /* If we are dealing with a cyclic descriptor keep it on ld_active */ 199 /* If we are dealing with a cyclic descriptor keep it on ld_active */
198 if (imxdma_chan_is_doing_cyclic(imxdmac)) 200 if (imxdma_chan_is_doing_cyclic(imxdmac))
@@ -276,31 +278,7 @@ static enum dma_status imxdma_tx_status(struct dma_chan *chan,
276 dma_cookie_t cookie, 278 dma_cookie_t cookie,
277 struct dma_tx_state *txstate) 279 struct dma_tx_state *txstate)
278{ 280{
279 struct imxdma_channel *imxdmac = to_imxdma_chan(chan); 281 return dma_cookie_status(chan, cookie, txstate);
280 dma_cookie_t last_used;
281 enum dma_status ret;
282 unsigned long flags;
283
284 spin_lock_irqsave(&imxdmac->lock, flags);
285 last_used = chan->cookie;
286
287 ret = dma_async_is_complete(cookie, imxdmac->last_completed, last_used);
288 dma_set_tx_state(txstate, imxdmac->last_completed, last_used, 0);
289 spin_unlock_irqrestore(&imxdmac->lock, flags);
290
291 return ret;
292}
293
294static dma_cookie_t imxdma_assign_cookie(struct imxdma_channel *imxdma)
295{
296 dma_cookie_t cookie = imxdma->chan.cookie;
297
298 if (++cookie < 0)
299 cookie = 1;
300
301 imxdma->chan.cookie = cookie;
302
303 return cookie;
304} 282}
305 283
306static dma_cookie_t imxdma_tx_submit(struct dma_async_tx_descriptor *tx) 284static dma_cookie_t imxdma_tx_submit(struct dma_async_tx_descriptor *tx)
@@ -310,11 +288,7 @@ static dma_cookie_t imxdma_tx_submit(struct dma_async_tx_descriptor *tx)
310 unsigned long flags; 288 unsigned long flags;
311 289
312 spin_lock_irqsave(&imxdmac->lock, flags); 290 spin_lock_irqsave(&imxdmac->lock, flags);
313 291 cookie = dma_cookie_assign(tx);
314 list_move_tail(imxdmac->ld_free.next, &imxdmac->ld_queue);
315 cookie = imxdma_assign_cookie(imxdmac);
316 tx->cookie = cookie;
317
318 spin_unlock_irqrestore(&imxdmac->lock, flags); 292 spin_unlock_irqrestore(&imxdmac->lock, flags);
319 293
320 return cookie; 294 return cookie;
@@ -583,6 +557,7 @@ static int __init imxdma_probe(struct platform_device *pdev)
583 tasklet_init(&imxdmac->dma_tasklet, imxdma_tasklet, 557 tasklet_init(&imxdmac->dma_tasklet, imxdma_tasklet,
584 (unsigned long)imxdmac); 558 (unsigned long)imxdmac);
585 imxdmac->chan.device = &imxdma->dma_device; 559 imxdmac->chan.device = &imxdma->dma_device;
560 dma_cookie_init(&imxdmac->chan);
586 imxdmac->channel = i; 561 imxdmac->channel = i;
587 562
588 /* Add the channel to the DMAC list */ 563 /* Add the channel to the DMAC list */