diff options
Diffstat (limited to 'drivers/dma/txx9dmac.c')
-rw-r--r-- | drivers/dma/txx9dmac.c | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c index 6122c364cf11..40440f946385 100644 --- a/drivers/dma/txx9dmac.c +++ b/drivers/dma/txx9dmac.c | |||
@@ -15,6 +15,8 @@ | |||
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/scatterlist.h> | 17 | #include <linux/scatterlist.h> |
18 | |||
19 | #include "dmaengine.h" | ||
18 | #include "txx9dmac.h" | 20 | #include "txx9dmac.h" |
19 | 21 | ||
20 | static struct txx9dmac_chan *to_txx9dmac_chan(struct dma_chan *chan) | 22 | static struct txx9dmac_chan *to_txx9dmac_chan(struct dma_chan *chan) |
@@ -279,21 +281,6 @@ static void txx9dmac_desc_put(struct txx9dmac_chan *dc, | |||
279 | } | 281 | } |
280 | } | 282 | } |
281 | 283 | ||
282 | /* Called with dc->lock held and bh disabled */ | ||
283 | static dma_cookie_t | ||
284 | txx9dmac_assign_cookie(struct txx9dmac_chan *dc, struct txx9dmac_desc *desc) | ||
285 | { | ||
286 | dma_cookie_t cookie = dc->chan.cookie; | ||
287 | |||
288 | if (++cookie < 0) | ||
289 | cookie = 1; | ||
290 | |||
291 | dc->chan.cookie = cookie; | ||
292 | desc->txd.cookie = cookie; | ||
293 | |||
294 | return cookie; | ||
295 | } | ||
296 | |||
297 | /*----------------------------------------------------------------------*/ | 284 | /*----------------------------------------------------------------------*/ |
298 | 285 | ||
299 | static void txx9dmac_dump_regs(struct txx9dmac_chan *dc) | 286 | static void txx9dmac_dump_regs(struct txx9dmac_chan *dc) |
@@ -424,7 +411,7 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc, | |||
424 | dev_vdbg(chan2dev(&dc->chan), "descriptor %u %p complete\n", | 411 | dev_vdbg(chan2dev(&dc->chan), "descriptor %u %p complete\n", |
425 | txd->cookie, desc); | 412 | txd->cookie, desc); |
426 | 413 | ||
427 | dc->completed = txd->cookie; | 414 | dma_cookie_complete(txd); |
428 | callback = txd->callback; | 415 | callback = txd->callback; |
429 | param = txd->callback_param; | 416 | param = txd->callback_param; |
430 | 417 | ||
@@ -738,7 +725,7 @@ static dma_cookie_t txx9dmac_tx_submit(struct dma_async_tx_descriptor *tx) | |||
738 | dma_cookie_t cookie; | 725 | dma_cookie_t cookie; |
739 | 726 | ||
740 | spin_lock_bh(&dc->lock); | 727 | spin_lock_bh(&dc->lock); |
741 | cookie = txx9dmac_assign_cookie(dc, desc); | 728 | cookie = dma_cookie_assign(tx); |
742 | 729 | ||
743 | dev_vdbg(chan2dev(tx->chan), "tx_submit: queued %u %p\n", | 730 | dev_vdbg(chan2dev(tx->chan), "tx_submit: queued %u %p\n", |
744 | desc->txd.cookie, desc); | 731 | desc->txd.cookie, desc); |
@@ -972,27 +959,17 @@ txx9dmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie, | |||
972 | struct dma_tx_state *txstate) | 959 | struct dma_tx_state *txstate) |
973 | { | 960 | { |
974 | struct txx9dmac_chan *dc = to_txx9dmac_chan(chan); | 961 | struct txx9dmac_chan *dc = to_txx9dmac_chan(chan); |
975 | dma_cookie_t last_used; | 962 | enum dma_status ret; |
976 | dma_cookie_t last_complete; | ||
977 | int ret; | ||
978 | 963 | ||
979 | last_complete = dc->completed; | 964 | ret = dma_cookie_status(chan, cookie, txstate); |
980 | last_used = chan->cookie; | ||
981 | |||
982 | ret = dma_async_is_complete(cookie, last_complete, last_used); | ||
983 | if (ret != DMA_SUCCESS) { | 965 | if (ret != DMA_SUCCESS) { |
984 | spin_lock_bh(&dc->lock); | 966 | spin_lock_bh(&dc->lock); |
985 | txx9dmac_scan_descriptors(dc); | 967 | txx9dmac_scan_descriptors(dc); |
986 | spin_unlock_bh(&dc->lock); | 968 | spin_unlock_bh(&dc->lock); |
987 | 969 | ||
988 | last_complete = dc->completed; | 970 | ret = dma_cookie_status(chan, cookie, txstate); |
989 | last_used = chan->cookie; | ||
990 | |||
991 | ret = dma_async_is_complete(cookie, last_complete, last_used); | ||
992 | } | 971 | } |
993 | 972 | ||
994 | dma_set_tx_state(txstate, last_complete, last_used, 0); | ||
995 | |||
996 | return ret; | 973 | return ret; |
997 | } | 974 | } |
998 | 975 | ||
@@ -1057,7 +1034,7 @@ static int txx9dmac_alloc_chan_resources(struct dma_chan *chan) | |||
1057 | return -EIO; | 1034 | return -EIO; |
1058 | } | 1035 | } |
1059 | 1036 | ||
1060 | dc->completed = chan->cookie = 1; | 1037 | dma_cookie_init(chan); |
1061 | 1038 | ||
1062 | dc->ccr = TXX9_DMA_CCR_IMMCHN | TXX9_DMA_CCR_INTENE | CCR_LE; | 1039 | dc->ccr = TXX9_DMA_CCR_IMMCHN | TXX9_DMA_CCR_INTENE | CCR_LE; |
1063 | txx9dmac_chan_set_SMPCHN(dc); | 1040 | txx9dmac_chan_set_SMPCHN(dc); |
@@ -1186,7 +1163,7 @@ static int __init txx9dmac_chan_probe(struct platform_device *pdev) | |||
1186 | dc->ddev->chan[ch] = dc; | 1163 | dc->ddev->chan[ch] = dc; |
1187 | dc->chan.device = &dc->dma; | 1164 | dc->chan.device = &dc->dma; |
1188 | list_add_tail(&dc->chan.device_node, &dc->chan.device->channels); | 1165 | list_add_tail(&dc->chan.device_node, &dc->chan.device->channels); |
1189 | dc->chan.cookie = dc->completed = 1; | 1166 | dma_cookie_init(&dc->chan); |
1190 | 1167 | ||
1191 | if (is_dmac64(dc)) | 1168 | if (is_dmac64(dc)) |
1192 | dc->ch_regs = &__txx9dmac_regs(dc->ddev)->CHAN[ch]; | 1169 | dc->ch_regs = &__txx9dmac_regs(dc->ddev)->CHAN[ch]; |