aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/at_hdmac.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/at_hdmac.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/at_hdmac.c')
-rw-r--r--drivers/dma/at_hdmac.c48
1 files changed, 11 insertions, 37 deletions
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index f4aed5fc2cb6..5d225ddc7698 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -27,6 +27,7 @@
27#include <linux/of_device.h> 27#include <linux/of_device.h>
28 28
29#include "at_hdmac_regs.h" 29#include "at_hdmac_regs.h"
30#include "dmaengine.h"
30 31
31/* 32/*
32 * Glossary 33 * Glossary
@@ -192,27 +193,6 @@ static void atc_desc_chain(struct at_desc **first, struct at_desc **prev,
192} 193}
193 194
194/** 195/**
195 * atc_assign_cookie - compute and assign new cookie
196 * @atchan: channel we work on
197 * @desc: descriptor to assign cookie for
198 *
199 * Called with atchan->lock held and bh disabled
200 */
201static dma_cookie_t
202atc_assign_cookie(struct at_dma_chan *atchan, struct at_desc *desc)
203{
204 dma_cookie_t cookie = atchan->chan_common.cookie;
205
206 if (++cookie < 0)
207 cookie = 1;
208
209 atchan->chan_common.cookie = cookie;
210 desc->txd.cookie = cookie;
211
212 return cookie;
213}
214
215/**
216 * atc_dostart - starts the DMA engine for real 196 * atc_dostart - starts the DMA engine for real
217 * @atchan: the channel we want to start 197 * @atchan: the channel we want to start
218 * @first: first descriptor in the list we want to begin with 198 * @first: first descriptor in the list we want to begin with
@@ -269,7 +249,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc)
269 dev_vdbg(chan2dev(&atchan->chan_common), 249 dev_vdbg(chan2dev(&atchan->chan_common),
270 "descriptor %u complete\n", txd->cookie); 250 "descriptor %u complete\n", txd->cookie);
271 251
272 atchan->completed_cookie = txd->cookie; 252 dma_cookie_complete(txd);
273 253
274 /* move children to free_list */ 254 /* move children to free_list */
275 list_splice_init(&desc->tx_list, &atchan->free_list); 255 list_splice_init(&desc->tx_list, &atchan->free_list);
@@ -547,7 +527,7 @@ static dma_cookie_t atc_tx_submit(struct dma_async_tx_descriptor *tx)
547 unsigned long flags; 527 unsigned long flags;
548 528
549 spin_lock_irqsave(&atchan->lock, flags); 529 spin_lock_irqsave(&atchan->lock, flags);
550 cookie = atc_assign_cookie(atchan, desc); 530 cookie = dma_cookie_assign(tx);
551 531
552 if (list_empty(&atchan->active_list)) { 532 if (list_empty(&atchan->active_list)) {
553 dev_vdbg(chan2dev(tx->chan), "tx_submit: started %u\n", 533 dev_vdbg(chan2dev(tx->chan), "tx_submit: started %u\n",
@@ -1016,26 +996,20 @@ atc_tx_status(struct dma_chan *chan,
1016 996
1017 spin_lock_irqsave(&atchan->lock, flags); 997 spin_lock_irqsave(&atchan->lock, flags);
1018 998
1019 last_complete = atchan->completed_cookie; 999 ret = dma_cookie_status(chan, cookie, txstate);
1020 last_used = chan->cookie;
1021
1022 ret = dma_async_is_complete(cookie, last_complete, last_used);
1023 if (ret != DMA_SUCCESS) { 1000 if (ret != DMA_SUCCESS) {
1024 atc_cleanup_descriptors(atchan); 1001 atc_cleanup_descriptors(atchan);
1025 1002
1026 last_complete = atchan->completed_cookie; 1003 ret = dma_cookie_status(chan, cookie, txstate);
1027 last_used = chan->cookie;
1028
1029 ret = dma_async_is_complete(cookie, last_complete, last_used);
1030 } 1004 }
1031 1005
1006 last_complete = chan->completed_cookie;
1007 last_used = chan->cookie;
1008
1032 spin_unlock_irqrestore(&atchan->lock, flags); 1009 spin_unlock_irqrestore(&atchan->lock, flags);
1033 1010
1034 if (ret != DMA_SUCCESS) 1011 if (ret != DMA_SUCCESS)
1035 dma_set_tx_state(txstate, last_complete, last_used, 1012 dma_set_residue(txstate, atc_first_active(atchan)->len);
1036 atc_first_active(atchan)->len);
1037 else
1038 dma_set_tx_state(txstate, last_complete, last_used, 0);
1039 1013
1040 if (atc_chan_is_paused(atchan)) 1014 if (atc_chan_is_paused(atchan))
1041 ret = DMA_PAUSED; 1015 ret = DMA_PAUSED;
@@ -1129,7 +1103,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan)
1129 spin_lock_irqsave(&atchan->lock, flags); 1103 spin_lock_irqsave(&atchan->lock, flags);
1130 atchan->descs_allocated = i; 1104 atchan->descs_allocated = i;
1131 list_splice(&tmp_list, &atchan->free_list); 1105 list_splice(&tmp_list, &atchan->free_list);
1132 atchan->completed_cookie = chan->cookie = 1; 1106 dma_cookie_init(chan);
1133 spin_unlock_irqrestore(&atchan->lock, flags); 1107 spin_unlock_irqrestore(&atchan->lock, flags);
1134 1108
1135 /* channel parameters */ 1109 /* channel parameters */
@@ -1329,7 +1303,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
1329 struct at_dma_chan *atchan = &atdma->chan[i]; 1303 struct at_dma_chan *atchan = &atdma->chan[i];
1330 1304
1331 atchan->chan_common.device = &atdma->dma_common; 1305 atchan->chan_common.device = &atdma->dma_common;
1332 atchan->chan_common.cookie = atchan->completed_cookie = 1; 1306 dma_cookie_init(&atchan->chan_common);
1333 list_add_tail(&atchan->chan_common.device_node, 1307 list_add_tail(&atchan->chan_common.device_node,
1334 &atdma->dma_common.channels); 1308 &atdma->dma_common.channels);
1335 1309