diff options
author | Russell King - ARM Linux <linux@arm.linux.org.uk> | 2012-03-06 17:35:07 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@linux.intel.com> | 2012-03-13 02:07:01 -0400 |
commit | f7fbce07c6ce26a25b4e0cb5f241c361fde87901 (patch) | |
tree | 66e6321b5ef49e18479ffeb1ed4fd5169e120f97 /drivers/dma | |
parent | 884485e1f12dcd39390f042e772cdbefc9ebb750 (diff) |
dmaengine: provide a common function for completing a dma descriptor
Provide a common function to do the cookie mechanics for completing
a DMA descriptor.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
[imx-sdma.c & mxs-dma.c]
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/amba-pl08x.c | 2 | ||||
-rw-r--r-- | drivers/dma/at_hdmac.c | 2 | ||||
-rw-r--r-- | drivers/dma/coh901318.c | 2 | ||||
-rw-r--r-- | drivers/dma/dmaengine.h | 18 | ||||
-rw-r--r-- | drivers/dma/dw_dmac.c | 2 | ||||
-rw-r--r-- | drivers/dma/ep93xx_dma.c | 2 | ||||
-rw-r--r-- | drivers/dma/fsldma.c | 2 | ||||
-rw-r--r-- | drivers/dma/imx-dma.c | 2 | ||||
-rw-r--r-- | drivers/dma/imx-sdma.c | 2 | ||||
-rw-r--r-- | drivers/dma/intel_mid_dma.c | 2 | ||||
-rw-r--r-- | drivers/dma/ioat/dma.c | 3 | ||||
-rw-r--r-- | drivers/dma/ioat/dma_v2.c | 3 | ||||
-rw-r--r-- | drivers/dma/ioat/dma_v3.c | 3 | ||||
-rw-r--r-- | drivers/dma/ipu/ipu_idmac.c | 2 | ||||
-rw-r--r-- | drivers/dma/mxs-dma.c | 2 | ||||
-rw-r--r-- | drivers/dma/pl330.c | 2 | ||||
-rw-r--r-- | drivers/dma/ste_dma40.c | 2 | ||||
-rw-r--r-- | drivers/dma/timb_dma.c | 2 | ||||
-rw-r--r-- | drivers/dma/txx9dmac.c | 2 |
19 files changed, 36 insertions, 21 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index d8d3dc273f29..346327572cfb 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c | |||
@@ -1542,7 +1542,7 @@ static void pl08x_tasklet(unsigned long data) | |||
1542 | 1542 | ||
1543 | if (txd) { | 1543 | if (txd) { |
1544 | /* Update last completed */ | 1544 | /* Update last completed */ |
1545 | plchan->chan.completed_cookie = txd->tx.cookie; | 1545 | dma_cookie_complete(&txd->tx); |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | /* If a new descriptor is queued, set it up plchan->at is NULL here */ | 1548 | /* If a new descriptor is queued, set it up plchan->at is NULL here */ |
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index df47e7d6164b..b2826304da24 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c | |||
@@ -249,7 +249,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc) | |||
249 | dev_vdbg(chan2dev(&atchan->chan_common), | 249 | dev_vdbg(chan2dev(&atchan->chan_common), |
250 | "descriptor %u complete\n", txd->cookie); | 250 | "descriptor %u complete\n", txd->cookie); |
251 | 251 | ||
252 | atchan->chan_common.completed_cookie = txd->cookie; | 252 | dma_cookie_complete(txd); |
253 | 253 | ||
254 | /* move children to free_list */ | 254 | /* move children to free_list */ |
255 | list_splice_init(&desc->tx_list, &atchan->free_list); | 255 | list_splice_init(&desc->tx_list, &atchan->free_list); |
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c index 843a1a3b8a81..24837d700951 100644 --- a/drivers/dma/coh901318.c +++ b/drivers/dma/coh901318.c | |||
@@ -691,7 +691,7 @@ static void dma_tasklet(unsigned long data) | |||
691 | callback_param = cohd_fin->desc.callback_param; | 691 | callback_param = cohd_fin->desc.callback_param; |
692 | 692 | ||
693 | /* sign this job as completed on the channel */ | 693 | /* sign this job as completed on the channel */ |
694 | cohc->chan.completed_cookie = cohd_fin->desc.cookie; | 694 | dma_cookie_complete(&cohd_fin->desc); |
695 | 695 | ||
696 | /* release the lli allocation and remove the descriptor */ | 696 | /* release the lli allocation and remove the descriptor */ |
697 | coh901318_lli_free(&cohc->base->pool, &cohd_fin->lli); | 697 | coh901318_lli_free(&cohc->base->pool, &cohd_fin->lli); |
diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h index 7692c8644045..47e099772b8e 100644 --- a/drivers/dma/dmaengine.h +++ b/drivers/dma/dmaengine.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #ifndef DMAENGINE_H | 5 | #ifndef DMAENGINE_H |
6 | #define DMAENGINE_H | 6 | #define DMAENGINE_H |
7 | 7 | ||
8 | #include <linux/bug.h> | ||
8 | #include <linux/dmaengine.h> | 9 | #include <linux/dmaengine.h> |
9 | 10 | ||
10 | /** | 11 | /** |
@@ -27,4 +28,21 @@ static inline dma_cookie_t dma_cookie_assign(struct dma_async_tx_descriptor *tx) | |||
27 | return cookie; | 28 | return cookie; |
28 | } | 29 | } |
29 | 30 | ||
31 | /** | ||
32 | * dma_cookie_complete - complete a descriptor | ||
33 | * @tx: descriptor to complete | ||
34 | * | ||
35 | * Mark this descriptor complete by updating the channels completed | ||
36 | * cookie marker. Zero the descriptors cookie to prevent accidental | ||
37 | * repeated completions. | ||
38 | * | ||
39 | * Note: caller is expected to hold a lock to prevent concurrency. | ||
40 | */ | ||
41 | static inline void dma_cookie_complete(struct dma_async_tx_descriptor *tx) | ||
42 | { | ||
43 | BUG_ON(tx->cookie < DMA_MIN_COOKIE); | ||
44 | tx->chan->completed_cookie = tx->cookie; | ||
45 | tx->cookie = 0; | ||
46 | } | ||
47 | |||
30 | #endif | 48 | #endif |
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c index 3a4ca67ace02..12ea60b2a1be 100644 --- a/drivers/dma/dw_dmac.c +++ b/drivers/dma/dw_dmac.c | |||
@@ -235,7 +235,7 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc, | |||
235 | dev_vdbg(chan2dev(&dwc->chan), "descriptor %u complete\n", txd->cookie); | 235 | dev_vdbg(chan2dev(&dwc->chan), "descriptor %u complete\n", txd->cookie); |
236 | 236 | ||
237 | spin_lock_irqsave(&dwc->lock, flags); | 237 | spin_lock_irqsave(&dwc->lock, flags); |
238 | dwc->chan.completed_cookie = txd->cookie; | 238 | dma_cookie_complete(txd); |
239 | if (callback_required) { | 239 | if (callback_required) { |
240 | callback = txd->callback; | 240 | callback = txd->callback; |
241 | param = txd->callback_param; | 241 | param = txd->callback_param; |
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c index e5aaae87ddfb..1c56f75d9faf 100644 --- a/drivers/dma/ep93xx_dma.c +++ b/drivers/dma/ep93xx_dma.c | |||
@@ -703,7 +703,7 @@ static void ep93xx_dma_tasklet(unsigned long data) | |||
703 | desc = ep93xx_dma_get_active(edmac); | 703 | desc = ep93xx_dma_get_active(edmac); |
704 | if (desc) { | 704 | if (desc) { |
705 | if (desc->complete) { | 705 | if (desc->complete) { |
706 | edmac->chan.completed_cookie = desc->txd.cookie; | 706 | dma_cookie_complete(&desc->txd); |
707 | list_splice_init(&edmac->active, &list); | 707 | list_splice_init(&edmac->active, &list); |
708 | } | 708 | } |
709 | callback = desc->txd.callback; | 709 | callback = desc->txd.callback; |
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index 04b4347ba4e9..f36e8b18cba2 100644 --- a/drivers/dma/fsldma.c +++ b/drivers/dma/fsldma.c | |||
@@ -1081,8 +1081,8 @@ static void dma_do_tasklet(unsigned long data) | |||
1081 | 1081 | ||
1082 | desc = to_fsl_desc(chan->ld_running.prev); | 1082 | desc = to_fsl_desc(chan->ld_running.prev); |
1083 | cookie = desc->async_tx.cookie; | 1083 | cookie = desc->async_tx.cookie; |
1084 | dma_cookie_complete(&desc->async_tx); | ||
1084 | 1085 | ||
1085 | chan->common.completed_cookie = cookie; | ||
1086 | chan_dbg(chan, "completed_cookie=%d\n", cookie); | 1086 | chan_dbg(chan, "completed_cookie=%d\n", cookie); |
1087 | } | 1087 | } |
1088 | 1088 | ||
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c index 687fc687aaf6..9a3cbac3d695 100644 --- a/drivers/dma/imx-dma.c +++ b/drivers/dma/imx-dma.c | |||
@@ -66,7 +66,7 @@ static void imxdma_handle(struct imxdma_channel *imxdmac) | |||
66 | { | 66 | { |
67 | if (imxdmac->desc.callback) | 67 | if (imxdmac->desc.callback) |
68 | imxdmac->desc.callback(imxdmac->desc.callback_param); | 68 | imxdmac->desc.callback(imxdmac->desc.callback_param); |
69 | imxdmac->chan.completed_cookie = imxdmac->desc.cookie; | 69 | dma_cookie_complete(&imxdmac->desc); |
70 | } | 70 | } |
71 | 71 | ||
72 | static void imxdma_irq_handler(int channel, void *data) | 72 | static void imxdma_irq_handler(int channel, void *data) |
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 3f0c002933f3..981071ebd5c8 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c | |||
@@ -530,7 +530,7 @@ static void mxc_sdma_handle_channel_normal(struct sdma_channel *sdmac) | |||
530 | else | 530 | else |
531 | sdmac->status = DMA_SUCCESS; | 531 | sdmac->status = DMA_SUCCESS; |
532 | 532 | ||
533 | sdmac->chan.completed_cookie = sdmac->desc.cookie; | 533 | dma_cookie_complete(&sdmac->desc); |
534 | if (sdmac->desc.callback) | 534 | if (sdmac->desc.callback) |
535 | sdmac->desc.callback(sdmac->desc.callback_param); | 535 | sdmac->desc.callback(sdmac->desc.callback_param); |
536 | } | 536 | } |
diff --git a/drivers/dma/intel_mid_dma.c b/drivers/dma/intel_mid_dma.c index e9217c390b76..cee79f6e035d 100644 --- a/drivers/dma/intel_mid_dma.c +++ b/drivers/dma/intel_mid_dma.c | |||
@@ -290,7 +290,7 @@ static void midc_descriptor_complete(struct intel_mid_dma_chan *midc, | |||
290 | struct intel_mid_dma_lli *llitem; | 290 | struct intel_mid_dma_lli *llitem; |
291 | void *param_txd = NULL; | 291 | void *param_txd = NULL; |
292 | 292 | ||
293 | midc->chan.completed_cookie = txd->cookie; | 293 | dma_cookie_complete(txd); |
294 | callback_txd = txd->callback; | 294 | callback_txd = txd->callback; |
295 | param_txd = txd->callback_param; | 295 | param_txd = txd->callback_param; |
296 | 296 | ||
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c index 5c06117ac682..b0517c86c1bb 100644 --- a/drivers/dma/ioat/dma.c +++ b/drivers/dma/ioat/dma.c | |||
@@ -600,8 +600,7 @@ static void __cleanup(struct ioat_dma_chan *ioat, unsigned long phys_complete) | |||
600 | */ | 600 | */ |
601 | dump_desc_dbg(ioat, desc); | 601 | dump_desc_dbg(ioat, desc); |
602 | if (tx->cookie) { | 602 | if (tx->cookie) { |
603 | chan->common.completed_cookie = tx->cookie; | 603 | dma_cookie_complete(tx); |
604 | tx->cookie = 0; | ||
605 | ioat_dma_unmap(chan, tx->flags, desc->len, desc->hw); | 604 | ioat_dma_unmap(chan, tx->flags, desc->len, desc->hw); |
606 | ioat->active -= desc->hw->tx_cnt; | 605 | ioat->active -= desc->hw->tx_cnt; |
607 | if (tx->callback) { | 606 | if (tx->callback) { |
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c index 17ecacb70d40..e8e110ff3d96 100644 --- a/drivers/dma/ioat/dma_v2.c +++ b/drivers/dma/ioat/dma_v2.c | |||
@@ -149,8 +149,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) | |||
149 | dump_desc_dbg(ioat, desc); | 149 | dump_desc_dbg(ioat, desc); |
150 | if (tx->cookie) { | 150 | if (tx->cookie) { |
151 | ioat_dma_unmap(chan, tx->flags, desc->len, desc->hw); | 151 | ioat_dma_unmap(chan, tx->flags, desc->len, desc->hw); |
152 | chan->common.completed_cookie = tx->cookie; | 152 | dma_cookie_complete(tx); |
153 | tx->cookie = 0; | ||
154 | if (tx->callback) { | 153 | if (tx->callback) { |
155 | tx->callback(tx->callback_param); | 154 | tx->callback(tx->callback_param); |
156 | tx->callback = NULL; | 155 | tx->callback = NULL; |
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c index d4afac741e8a..1bda46c43bd7 100644 --- a/drivers/dma/ioat/dma_v3.c +++ b/drivers/dma/ioat/dma_v3.c | |||
@@ -277,9 +277,8 @@ static void __cleanup(struct ioat2_dma_chan *ioat, unsigned long phys_complete) | |||
277 | dump_desc_dbg(ioat, desc); | 277 | dump_desc_dbg(ioat, desc); |
278 | tx = &desc->txd; | 278 | tx = &desc->txd; |
279 | if (tx->cookie) { | 279 | if (tx->cookie) { |
280 | chan->common.completed_cookie = tx->cookie; | 280 | dma_cookie_complete(tx); |
281 | ioat3_dma_unmap(ioat, desc, idx + i); | 281 | ioat3_dma_unmap(ioat, desc, idx + i); |
282 | tx->cookie = 0; | ||
283 | if (tx->callback) { | 282 | if (tx->callback) { |
284 | tx->callback(tx->callback_param); | 283 | tx->callback(tx->callback_param); |
285 | tx->callback = NULL; | 284 | tx->callback = NULL; |
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c index d4620c53fd2d..bff9250a59ce 100644 --- a/drivers/dma/ipu/ipu_idmac.c +++ b/drivers/dma/ipu/ipu_idmac.c | |||
@@ -1289,7 +1289,7 @@ static irqreturn_t idmac_interrupt(int irq, void *dev_id) | |||
1289 | /* Flip the active buffer - even if update above failed */ | 1289 | /* Flip the active buffer - even if update above failed */ |
1290 | ichan->active_buffer = !ichan->active_buffer; | 1290 | ichan->active_buffer = !ichan->active_buffer; |
1291 | if (done) | 1291 | if (done) |
1292 | ichan->dma_chan.completed_cookie = desc->txd.cookie; | 1292 | dma_cookie_complete(&desc->txd); |
1293 | 1293 | ||
1294 | callback = desc->txd.callback; | 1294 | callback = desc->txd.callback; |
1295 | callback_param = desc->txd.callback_param; | 1295 | callback_param = desc->txd.callback_param; |
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index 4d3b6ff3050f..5f3492e5d28f 100644 --- a/drivers/dma/mxs-dma.c +++ b/drivers/dma/mxs-dma.c | |||
@@ -262,7 +262,7 @@ static irqreturn_t mxs_dma_int_handler(int irq, void *dev_id) | |||
262 | stat1 &= ~(1 << channel); | 262 | stat1 &= ~(1 << channel); |
263 | 263 | ||
264 | if (mxs_chan->status == DMA_SUCCESS) | 264 | if (mxs_chan->status == DMA_SUCCESS) |
265 | mxs_chan->chan.completed_cookie = mxs_chan->desc.cookie; | 265 | dma_cookie_complete(&mxs_chan->desc); |
266 | 266 | ||
267 | /* schedule tasklet on this channel */ | 267 | /* schedule tasklet on this channel */ |
268 | tasklet_schedule(&mxs_chan->tasklet); | 268 | tasklet_schedule(&mxs_chan->tasklet); |
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 644eb789958b..a81d0a5f8191 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
@@ -233,7 +233,7 @@ static void pl330_tasklet(unsigned long data) | |||
233 | /* Pick up ripe tomatoes */ | 233 | /* Pick up ripe tomatoes */ |
234 | list_for_each_entry_safe(desc, _dt, &pch->work_list, node) | 234 | list_for_each_entry_safe(desc, _dt, &pch->work_list, node) |
235 | if (desc->status == DONE) { | 235 | if (desc->status == DONE) { |
236 | pch->chan.completed_cookie = desc->txd.cookie; | 236 | dma_cookie_complete(&desc->txd); |
237 | list_move_tail(&desc->node, &list); | 237 | list_move_tail(&desc->node, &list); |
238 | } | 238 | } |
239 | 239 | ||
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 23e2edc4afd4..c2463758fed1 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c | |||
@@ -1347,7 +1347,7 @@ static void dma_tasklet(unsigned long data) | |||
1347 | goto err; | 1347 | goto err; |
1348 | 1348 | ||
1349 | if (!d40d->cyclic) | 1349 | if (!d40d->cyclic) |
1350 | d40c->chan.completed_cookie = d40d->txd.cookie; | 1350 | dma_cookie_complete(&d40d->txd); |
1351 | 1351 | ||
1352 | /* | 1352 | /* |
1353 | * If terminating a channel pending_tx is set to zero. | 1353 | * If terminating a channel pending_tx is set to zero. |
diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c index b6e83fc27c4e..1845ac9d6e88 100644 --- a/drivers/dma/timb_dma.c +++ b/drivers/dma/timb_dma.c | |||
@@ -285,7 +285,7 @@ static void __td_finish(struct timb_dma_chan *td_chan) | |||
285 | else | 285 | else |
286 | iowrite32(0, td_chan->membase + TIMBDMA_OFFS_TX_DLAR); | 286 | iowrite32(0, td_chan->membase + TIMBDMA_OFFS_TX_DLAR); |
287 | */ | 287 | */ |
288 | td_chan->chan.completed_cookie = txd->cookie; | 288 | dma_cookie_complete(txd); |
289 | td_chan->ongoing = false; | 289 | td_chan->ongoing = false; |
290 | 290 | ||
291 | callback = txd->callback; | 291 | callback = txd->callback; |
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c index 66f8fca1bd3c..8a5225bf9bc9 100644 --- a/drivers/dma/txx9dmac.c +++ b/drivers/dma/txx9dmac.c | |||
@@ -411,7 +411,7 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc, | |||
411 | dev_vdbg(chan2dev(&dc->chan), "descriptor %u %p complete\n", | 411 | dev_vdbg(chan2dev(&dc->chan), "descriptor %u %p complete\n", |
412 | txd->cookie, desc); | 412 | txd->cookie, desc); |
413 | 413 | ||
414 | dc->chan.completed_cookie = txd->cookie; | 414 | dma_cookie_complete(txd); |
415 | callback = txd->callback; | 415 | callback = txd->callback; |
416 | param = txd->callback_param; | 416 | param = txd->callback_param; |
417 | 417 | ||