diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-05-25 08:10:36 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-07-01 09:15:55 -0400 |
commit | ea1605612ca4a8c7936e155da768bb9f4e69e84f (patch) | |
tree | 4a769ee3efeb141be59fec1de64474f303f69e48 /drivers/dma/amba-pl08x.c | |
parent | eab82533c972bf932434b69bbb71c6724d863ef7 (diff) |
dmaengine: PL08x: split the pend_list in two
Our behaviour wasn't correct; issue_pending is supposed to be called
before any submitted descriptors are available for processing by the
DMA engine. Split the pend_list in two, one for submitted descriptors
and another list for issued descriptors.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/dma/amba-pl08x.c')
-rw-r--r-- | drivers/dma/amba-pl08x.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index c278d23adee7..b6132845e65c 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c | |||
@@ -217,6 +217,7 @@ enum pl08x_dma_chan_state { | |||
217 | * @cd: channel platform data | 217 | * @cd: channel platform data |
218 | * @runtime_addr: address for RX/TX according to the runtime config | 218 | * @runtime_addr: address for RX/TX according to the runtime config |
219 | * @pend_list: queued transactions pending on this channel | 219 | * @pend_list: queued transactions pending on this channel |
220 | * @issued_list: issued transactions for this channel | ||
220 | * @done_list: list of completed transactions | 221 | * @done_list: list of completed transactions |
221 | * @at: active transaction on this channel | 222 | * @at: active transaction on this channel |
222 | * @lock: a lock for this channel data | 223 | * @lock: a lock for this channel data |
@@ -235,6 +236,7 @@ struct pl08x_dma_chan { | |||
235 | const struct pl08x_channel_data *cd; | 236 | const struct pl08x_channel_data *cd; |
236 | struct dma_slave_config cfg; | 237 | struct dma_slave_config cfg; |
237 | struct list_head pend_list; | 238 | struct list_head pend_list; |
239 | struct list_head issued_list; | ||
238 | struct list_head done_list; | 240 | struct list_head done_list; |
239 | struct pl08x_txd *at; | 241 | struct pl08x_txd *at; |
240 | spinlock_t lock; | 242 | spinlock_t lock; |
@@ -362,7 +364,7 @@ static void pl08x_start_next_txd(struct pl08x_dma_chan *plchan) | |||
362 | struct pl08x_txd *txd; | 364 | struct pl08x_txd *txd; |
363 | u32 val; | 365 | u32 val; |
364 | 366 | ||
365 | txd = list_first_entry(&plchan->pend_list, struct pl08x_txd, node); | 367 | txd = list_first_entry(&plchan->issued_list, struct pl08x_txd, node); |
366 | list_del(&txd->node); | 368 | list_del(&txd->node); |
367 | 369 | ||
368 | plchan->at = txd; | 370 | plchan->at = txd; |
@@ -525,6 +527,15 @@ static u32 pl08x_getbytes_chan(struct pl08x_dma_chan *plchan) | |||
525 | } | 527 | } |
526 | 528 | ||
527 | /* Sum up all queued transactions */ | 529 | /* Sum up all queued transactions */ |
530 | if (!list_empty(&plchan->issued_list)) { | ||
531 | struct pl08x_txd *txdi; | ||
532 | list_for_each_entry(txdi, &plchan->issued_list, node) { | ||
533 | struct pl08x_sg *dsg; | ||
534 | list_for_each_entry(dsg, &txd->dsg_list, node) | ||
535 | bytes += dsg->len; | ||
536 | } | ||
537 | } | ||
538 | |||
528 | if (!list_empty(&plchan->pend_list)) { | 539 | if (!list_empty(&plchan->pend_list)) { |
529 | struct pl08x_txd *txdi; | 540 | struct pl08x_txd *txdi; |
530 | list_for_each_entry(txdi, &plchan->pend_list, node) { | 541 | list_for_each_entry(txdi, &plchan->pend_list, node) { |
@@ -991,16 +1002,17 @@ static void pl08x_free_txd(struct pl08x_driver_data *pl08x, | |||
991 | static void pl08x_free_txd_list(struct pl08x_driver_data *pl08x, | 1002 | static void pl08x_free_txd_list(struct pl08x_driver_data *pl08x, |
992 | struct pl08x_dma_chan *plchan) | 1003 | struct pl08x_dma_chan *plchan) |
993 | { | 1004 | { |
994 | struct pl08x_txd *txdi = NULL; | 1005 | LIST_HEAD(head); |
995 | struct pl08x_txd *next; | 1006 | struct pl08x_txd *txd; |
996 | 1007 | ||
997 | if (!list_empty(&plchan->pend_list)) { | 1008 | list_splice_tail_init(&plchan->issued_list, &head); |
998 | list_for_each_entry_safe(txdi, | 1009 | list_splice_tail_init(&plchan->pend_list, &head); |
999 | next, &plchan->pend_list, node) { | 1010 | |
1000 | pl08x_release_mux(plchan); | 1011 | while (!list_empty(&head)) { |
1001 | list_del(&txdi->node); | 1012 | txd = list_first_entry(&head, struct pl08x_txd, node); |
1002 | pl08x_free_txd(pl08x, txdi); | 1013 | pl08x_release_mux(plchan); |
1003 | } | 1014 | list_del(&txd->node); |
1015 | pl08x_free_txd(pl08x, txd); | ||
1004 | } | 1016 | } |
1005 | } | 1017 | } |
1006 | 1018 | ||
@@ -1269,6 +1281,8 @@ static void pl08x_issue_pending(struct dma_chan *chan) | |||
1269 | unsigned long flags; | 1281 | unsigned long flags; |
1270 | 1282 | ||
1271 | spin_lock_irqsave(&plchan->lock, flags); | 1283 | spin_lock_irqsave(&plchan->lock, flags); |
1284 | list_splice_tail_init(&plchan->pend_list, &plchan->issued_list); | ||
1285 | |||
1272 | /* Something is already active, or we're waiting for a channel... */ | 1286 | /* Something is already active, or we're waiting for a channel... */ |
1273 | if (plchan->at || plchan->state == PL08X_CHAN_WAITING) { | 1287 | if (plchan->at || plchan->state == PL08X_CHAN_WAITING) { |
1274 | spin_unlock_irqrestore(&plchan->lock, flags); | 1288 | spin_unlock_irqrestore(&plchan->lock, flags); |
@@ -1276,7 +1290,7 @@ static void pl08x_issue_pending(struct dma_chan *chan) | |||
1276 | } | 1290 | } |
1277 | 1291 | ||
1278 | /* Take the first element in the queue and execute it */ | 1292 | /* Take the first element in the queue and execute it */ |
1279 | if (!list_empty(&plchan->pend_list)) { | 1293 | if (!list_empty(&plchan->issued_list)) { |
1280 | plchan->state = PL08X_CHAN_RUNNING; | 1294 | plchan->state = PL08X_CHAN_RUNNING; |
1281 | pl08x_start_next_txd(plchan); | 1295 | pl08x_start_next_txd(plchan); |
1282 | } | 1296 | } |
@@ -1658,9 +1672,9 @@ static void pl08x_tasklet(unsigned long data) | |||
1658 | list_splice_tail_init(&plchan->done_list, &head); | 1672 | list_splice_tail_init(&plchan->done_list, &head); |
1659 | 1673 | ||
1660 | /* If a new descriptor is queued, set it up plchan->at is NULL here */ | 1674 | /* If a new descriptor is queued, set it up plchan->at is NULL here */ |
1661 | if (!list_empty(&plchan->pend_list)) { | 1675 | if (!list_empty(&plchan->issued_list)) { |
1662 | pl08x_start_next_txd(plchan); | 1676 | pl08x_start_next_txd(plchan); |
1663 | } else if (plchan->phychan_hold) { | 1677 | } else if (!list_empty(&plchan->pend_list) || plchan->phychan_hold) { |
1664 | /* | 1678 | /* |
1665 | * This channel is still in use - we have a new txd being | 1679 | * This channel is still in use - we have a new txd being |
1666 | * prepared and will soon be queued. Don't give up the | 1680 | * prepared and will soon be queued. Don't give up the |
@@ -1841,6 +1855,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x, | |||
1841 | 1855 | ||
1842 | spin_lock_init(&chan->lock); | 1856 | spin_lock_init(&chan->lock); |
1843 | INIT_LIST_HEAD(&chan->pend_list); | 1857 | INIT_LIST_HEAD(&chan->pend_list); |
1858 | INIT_LIST_HEAD(&chan->issued_list); | ||
1844 | INIT_LIST_HEAD(&chan->done_list); | 1859 | INIT_LIST_HEAD(&chan->done_list); |
1845 | tasklet_init(&chan->tasklet, pl08x_tasklet, | 1860 | tasklet_init(&chan->tasklet, pl08x_tasklet, |
1846 | (unsigned long) chan); | 1861 | (unsigned long) chan); |