aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/Kconfig8
-rw-r--r--drivers/dma/dmaengine.c15
-rw-r--r--drivers/dma/fsldma.c57
-rw-r--r--drivers/dma/ioat_dma.c36
-rw-r--r--drivers/dma/iop-adma.c60
5 files changed, 73 insertions, 103 deletions
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 27340a7b19dd..6239c3df30ac 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -46,14 +46,6 @@ config FSL_DMA
46 MPC8560/40, MPC8555, MPC8548 and MPC8641 processors. 46 MPC8560/40, MPC8555, MPC8548 and MPC8641 processors.
47 The MPC8349, MPC8360 is also supported. 47 The MPC8349, MPC8360 is also supported.
48 48
49config FSL_DMA_SELFTEST
50 bool "Enable the self test for each DMA channel"
51 depends on FSL_DMA
52 default y
53 ---help---
54 Enable the self test for each DMA channel. A self test will be
55 performed after the channel probed to ensure the DMA works well.
56
57config DMA_ENGINE 49config DMA_ENGINE
58 bool 50 bool
59 51
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 8db0e7f9d3f4..d6dc70fd7527 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -362,7 +362,6 @@ int dma_async_device_register(struct dma_device *device)
362 362
363 BUG_ON(!device->device_alloc_chan_resources); 363 BUG_ON(!device->device_alloc_chan_resources);
364 BUG_ON(!device->device_free_chan_resources); 364 BUG_ON(!device->device_free_chan_resources);
365 BUG_ON(!device->device_dependency_added);
366 BUG_ON(!device->device_is_tx_complete); 365 BUG_ON(!device->device_is_tx_complete);
367 BUG_ON(!device->device_issue_pending); 366 BUG_ON(!device->device_issue_pending);
368 BUG_ON(!device->dev); 367 BUG_ON(!device->dev);
@@ -479,7 +478,8 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
479 478
480 dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE); 479 dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE);
481 dma_dest = dma_map_single(dev->dev, dest, len, DMA_FROM_DEVICE); 480 dma_dest = dma_map_single(dev->dev, dest, len, DMA_FROM_DEVICE);
482 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 0); 481 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len,
482 DMA_CTRL_ACK);
483 483
484 if (!tx) { 484 if (!tx) {
485 dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); 485 dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE);
@@ -487,7 +487,6 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
487 return -ENOMEM; 487 return -ENOMEM;
488 } 488 }
489 489
490 tx->ack = 1;
491 tx->callback = NULL; 490 tx->callback = NULL;
492 cookie = tx->tx_submit(tx); 491 cookie = tx->tx_submit(tx);
493 492
@@ -525,7 +524,8 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
525 524
526 dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE); 525 dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE);
527 dma_dest = dma_map_page(dev->dev, page, offset, len, DMA_FROM_DEVICE); 526 dma_dest = dma_map_page(dev->dev, page, offset, len, DMA_FROM_DEVICE);
528 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 0); 527 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len,
528 DMA_CTRL_ACK);
529 529
530 if (!tx) { 530 if (!tx) {
531 dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); 531 dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE);
@@ -533,7 +533,6 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
533 return -ENOMEM; 533 return -ENOMEM;
534 } 534 }
535 535
536 tx->ack = 1;
537 tx->callback = NULL; 536 tx->callback = NULL;
538 cookie = tx->tx_submit(tx); 537 cookie = tx->tx_submit(tx);
539 538
@@ -574,7 +573,8 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg,
574 dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE); 573 dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE);
575 dma_dest = dma_map_page(dev->dev, dest_pg, dest_off, len, 574 dma_dest = dma_map_page(dev->dev, dest_pg, dest_off, len,
576 DMA_FROM_DEVICE); 575 DMA_FROM_DEVICE);
577 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 0); 576 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len,
577 DMA_CTRL_ACK);
578 578
579 if (!tx) { 579 if (!tx) {
580 dma_unmap_page(dev->dev, dma_src, len, DMA_TO_DEVICE); 580 dma_unmap_page(dev->dev, dma_src, len, DMA_TO_DEVICE);
@@ -582,7 +582,6 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg,
582 return -ENOMEM; 582 return -ENOMEM;
583 } 583 }
584 584
585 tx->ack = 1;
586 tx->callback = NULL; 585 tx->callback = NULL;
587 cookie = tx->tx_submit(tx); 586 cookie = tx->tx_submit(tx);
588 587
@@ -600,8 +599,6 @@ void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx,
600{ 599{
601 tx->chan = chan; 600 tx->chan = chan;
602 spin_lock_init(&tx->lock); 601 spin_lock_init(&tx->lock);
603 INIT_LIST_HEAD(&tx->depend_node);
604 INIT_LIST_HEAD(&tx->depend_list);
605} 602}
606EXPORT_SYMBOL(dma_async_tx_descriptor_init); 603EXPORT_SYMBOL(dma_async_tx_descriptor_init);
607 604
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index df163687c91a..054eabffc185 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -412,7 +412,7 @@ static void fsl_dma_free_chan_resources(struct dma_chan *chan)
412} 412}
413 413
414static struct dma_async_tx_descriptor * 414static struct dma_async_tx_descriptor *
415fsl_dma_prep_interrupt(struct dma_chan *chan) 415fsl_dma_prep_interrupt(struct dma_chan *chan, unsigned long flags)
416{ 416{
417 struct fsl_dma_chan *fsl_chan; 417 struct fsl_dma_chan *fsl_chan;
418 struct fsl_desc_sw *new; 418 struct fsl_desc_sw *new;
@@ -429,7 +429,7 @@ fsl_dma_prep_interrupt(struct dma_chan *chan)
429 } 429 }
430 430
431 new->async_tx.cookie = -EBUSY; 431 new->async_tx.cookie = -EBUSY;
432 new->async_tx.ack = 0; 432 new->async_tx.flags = flags;
433 433
434 /* Insert the link descriptor to the LD ring */ 434 /* Insert the link descriptor to the LD ring */
435 list_add_tail(&new->node, &new->async_tx.tx_list); 435 list_add_tail(&new->node, &new->async_tx.tx_list);
@@ -482,7 +482,7 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy(
482 set_desc_next(fsl_chan, &prev->hw, new->async_tx.phys); 482 set_desc_next(fsl_chan, &prev->hw, new->async_tx.phys);
483 483
484 new->async_tx.cookie = 0; 484 new->async_tx.cookie = 0;
485 new->async_tx.ack = 1; 485 async_tx_ack(&new->async_tx);
486 486
487 prev = new; 487 prev = new;
488 len -= copy; 488 len -= copy;
@@ -493,7 +493,7 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy(
493 list_add_tail(&new->node, &first->async_tx.tx_list); 493 list_add_tail(&new->node, &first->async_tx.tx_list);
494 } while (len); 494 } while (len);
495 495
496 new->async_tx.ack = 0; /* client is in control of this ack */ 496 new->async_tx.flags = flags; /* client is in control of this ack */
497 new->async_tx.cookie = -EBUSY; 497 new->async_tx.cookie = -EBUSY;
498 498
499 /* Set End-of-link to the last link descriptor of new list*/ 499 /* Set End-of-link to the last link descriptor of new list*/
@@ -658,13 +658,6 @@ static void fsl_dma_memcpy_issue_pending(struct dma_chan *chan)
658 fsl_chan_xfer_ld_queue(fsl_chan); 658 fsl_chan_xfer_ld_queue(fsl_chan);
659} 659}
660 660
661static void fsl_dma_dependency_added(struct dma_chan *chan)
662{
663 struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan);
664
665 fsl_chan_ld_cleanup(fsl_chan);
666}
667
668/** 661/**
669 * fsl_dma_is_complete - Determine the DMA status 662 * fsl_dma_is_complete - Determine the DMA status
670 * @fsl_chan : Freescale DMA channel 663 * @fsl_chan : Freescale DMA channel
@@ -696,6 +689,8 @@ static irqreturn_t fsl_dma_chan_do_interrupt(int irq, void *data)
696{ 689{
697 struct fsl_dma_chan *fsl_chan = (struct fsl_dma_chan *)data; 690 struct fsl_dma_chan *fsl_chan = (struct fsl_dma_chan *)data;
698 u32 stat; 691 u32 stat;
692 int update_cookie = 0;
693 int xfer_ld_q = 0;
699 694
700 stat = get_sr(fsl_chan); 695 stat = get_sr(fsl_chan);
701 dev_dbg(fsl_chan->dev, "event: channel %d, stat = 0x%x\n", 696 dev_dbg(fsl_chan->dev, "event: channel %d, stat = 0x%x\n",
@@ -720,8 +715,8 @@ static irqreturn_t fsl_dma_chan_do_interrupt(int irq, void *data)
720 * Now, update the completed cookie, and continue the 715 * Now, update the completed cookie, and continue the
721 * next uncompleted transfer. 716 * next uncompleted transfer.
722 */ 717 */
723 fsl_dma_update_completed_cookie(fsl_chan); 718 update_cookie = 1;
724 fsl_chan_xfer_ld_queue(fsl_chan); 719 xfer_ld_q = 1;
725 } 720 }
726 stat &= ~FSL_DMA_SR_PE; 721 stat &= ~FSL_DMA_SR_PE;
727 } 722 }
@@ -734,19 +729,33 @@ static irqreturn_t fsl_dma_chan_do_interrupt(int irq, void *data)
734 dev_dbg(fsl_chan->dev, "event: clndar %p, nlndar %p\n", 729 dev_dbg(fsl_chan->dev, "event: clndar %p, nlndar %p\n",
735 (void *)get_cdar(fsl_chan), (void *)get_ndar(fsl_chan)); 730 (void *)get_cdar(fsl_chan), (void *)get_ndar(fsl_chan));
736 stat &= ~FSL_DMA_SR_EOSI; 731 stat &= ~FSL_DMA_SR_EOSI;
737 fsl_dma_update_completed_cookie(fsl_chan); 732 update_cookie = 1;
733 }
734
735 /* For MPC8349, EOCDI event need to update cookie
736 * and start the next transfer if it exist.
737 */
738 if (stat & FSL_DMA_SR_EOCDI) {
739 dev_dbg(fsl_chan->dev, "event: End-of-Chain link INT\n");
740 stat &= ~FSL_DMA_SR_EOCDI;
741 update_cookie = 1;
742 xfer_ld_q = 1;
738 } 743 }
739 744
740 /* If it current transfer is the end-of-transfer, 745 /* If it current transfer is the end-of-transfer,
741 * we should clear the Channel Start bit for 746 * we should clear the Channel Start bit for
742 * prepare next transfer. 747 * prepare next transfer.
743 */ 748 */
744 if (stat & (FSL_DMA_SR_EOLNI | FSL_DMA_SR_EOCDI)) { 749 if (stat & FSL_DMA_SR_EOLNI) {
745 dev_dbg(fsl_chan->dev, "event: End-of-link INT\n"); 750 dev_dbg(fsl_chan->dev, "event: End-of-link INT\n");
746 stat &= ~FSL_DMA_SR_EOLNI; 751 stat &= ~FSL_DMA_SR_EOLNI;
747 fsl_chan_xfer_ld_queue(fsl_chan); 752 xfer_ld_q = 1;
748 } 753 }
749 754
755 if (update_cookie)
756 fsl_dma_update_completed_cookie(fsl_chan);
757 if (xfer_ld_q)
758 fsl_chan_xfer_ld_queue(fsl_chan);
750 if (stat) 759 if (stat)
751 dev_dbg(fsl_chan->dev, "event: unhandled sr 0x%02x\n", 760 dev_dbg(fsl_chan->dev, "event: unhandled sr 0x%02x\n",
752 stat); 761 stat);
@@ -776,15 +785,13 @@ static void dma_do_tasklet(unsigned long data)
776 fsl_chan_ld_cleanup(fsl_chan); 785 fsl_chan_ld_cleanup(fsl_chan);
777} 786}
778 787
779#ifdef FSL_DMA_CALLBACKTEST 788static void fsl_dma_callback_test(void *param)
780static void fsl_dma_callback_test(struct fsl_dma_chan *fsl_chan)
781{ 789{
790 struct fsl_dma_chan *fsl_chan = param;
782 if (fsl_chan) 791 if (fsl_chan)
783 dev_info(fsl_chan->dev, "selftest: callback is ok!\n"); 792 dev_dbg(fsl_chan->dev, "selftest: callback is ok!\n");
784} 793}
785#endif
786 794
787#ifdef CONFIG_FSL_DMA_SELFTEST
788static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan) 795static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan)
789{ 796{
790 struct dma_chan *chan; 797 struct dma_chan *chan;
@@ -867,7 +874,7 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan)
867 async_tx_ack(tx3); 874 async_tx_ack(tx3);
868 875
869 /* Interrupt tx test */ 876 /* Interrupt tx test */
870 tx1 = fsl_dma_prep_interrupt(chan); 877 tx1 = fsl_dma_prep_interrupt(chan, 0);
871 async_tx_ack(tx1); 878 async_tx_ack(tx1);
872 cookie = fsl_dma_tx_submit(tx1); 879 cookie = fsl_dma_tx_submit(tx1);
873 880
@@ -875,13 +882,11 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan)
875 cookie = fsl_dma_tx_submit(tx3); 882 cookie = fsl_dma_tx_submit(tx3);
876 cookie = fsl_dma_tx_submit(tx2); 883 cookie = fsl_dma_tx_submit(tx2);
877 884
878#ifdef FSL_DMA_CALLBACKTEST
879 if (dma_has_cap(DMA_INTERRUPT, ((struct fsl_dma_device *) 885 if (dma_has_cap(DMA_INTERRUPT, ((struct fsl_dma_device *)
880 dev_get_drvdata(fsl_chan->dev->parent))->common.cap_mask)) { 886 dev_get_drvdata(fsl_chan->dev->parent))->common.cap_mask)) {
881 tx3->callback = fsl_dma_callback_test; 887 tx3->callback = fsl_dma_callback_test;
882 tx3->callback_param = fsl_chan; 888 tx3->callback_param = fsl_chan;
883 } 889 }
884#endif
885 fsl_dma_memcpy_issue_pending(chan); 890 fsl_dma_memcpy_issue_pending(chan);
886 msleep(2); 891 msleep(2);
887 892
@@ -906,7 +911,6 @@ out:
906 kfree(src); 911 kfree(src);
907 return err; 912 return err;
908} 913}
909#endif
910 914
911static int __devinit of_fsl_dma_chan_probe(struct of_device *dev, 915static int __devinit of_fsl_dma_chan_probe(struct of_device *dev,
912 const struct of_device_id *match) 916 const struct of_device_id *match)
@@ -997,11 +1001,9 @@ static int __devinit of_fsl_dma_chan_probe(struct of_device *dev,
997 } 1001 }
998 } 1002 }
999 1003
1000#ifdef CONFIG_FSL_DMA_SELFTEST
1001 err = fsl_dma_self_test(new_fsl_chan); 1004 err = fsl_dma_self_test(new_fsl_chan);
1002 if (err) 1005 if (err)
1003 goto err; 1006 goto err;
1004#endif
1005 1007
1006 dev_info(&dev->dev, "#%d (%s), irq %d\n", new_fsl_chan->id, 1008 dev_info(&dev->dev, "#%d (%s), irq %d\n", new_fsl_chan->id,
1007 match->compatible, new_fsl_chan->irq); 1009 match->compatible, new_fsl_chan->irq);
@@ -1080,7 +1082,6 @@ static int __devinit of_fsl_dma_probe(struct of_device *dev,
1080 fdev->common.device_prep_dma_memcpy = fsl_dma_prep_memcpy; 1082 fdev->common.device_prep_dma_memcpy = fsl_dma_prep_memcpy;
1081 fdev->common.device_is_tx_complete = fsl_dma_is_complete; 1083 fdev->common.device_is_tx_complete = fsl_dma_is_complete;
1082 fdev->common.device_issue_pending = fsl_dma_memcpy_issue_pending; 1084 fdev->common.device_issue_pending = fsl_dma_memcpy_issue_pending;
1083 fdev->common.device_dependency_added = fsl_dma_dependency_added;
1084 fdev->common.dev = &dev->dev; 1085 fdev->common.dev = &dev->dev;
1085 1086
1086 irq = irq_of_parse_and_map(dev->node, 0); 1087 irq = irq_of_parse_and_map(dev->node, 0);
diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c
index 4017d9e7acd2..318e8a22d814 100644
--- a/drivers/dma/ioat_dma.c
+++ b/drivers/dma/ioat_dma.c
@@ -212,14 +212,14 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx)
212 u32 copy; 212 u32 copy;
213 size_t len; 213 size_t len;
214 dma_addr_t src, dst; 214 dma_addr_t src, dst;
215 int orig_ack; 215 unsigned long orig_flags;
216 unsigned int desc_count = 0; 216 unsigned int desc_count = 0;
217 217
218 /* src and dest and len are stored in the initial descriptor */ 218 /* src and dest and len are stored in the initial descriptor */
219 len = first->len; 219 len = first->len;
220 src = first->src; 220 src = first->src;
221 dst = first->dst; 221 dst = first->dst;
222 orig_ack = first->async_tx.ack; 222 orig_flags = first->async_tx.flags;
223 new = first; 223 new = first;
224 224
225 spin_lock_bh(&ioat_chan->desc_lock); 225 spin_lock_bh(&ioat_chan->desc_lock);
@@ -228,7 +228,7 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx)
228 do { 228 do {
229 copy = min_t(size_t, len, ioat_chan->xfercap); 229 copy = min_t(size_t, len, ioat_chan->xfercap);
230 230
231 new->async_tx.ack = 1; 231 async_tx_ack(&new->async_tx);
232 232
233 hw = new->hw; 233 hw = new->hw;
234 hw->size = copy; 234 hw->size = copy;
@@ -264,7 +264,7 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx)
264 } 264 }
265 265
266 new->tx_cnt = desc_count; 266 new->tx_cnt = desc_count;
267 new->async_tx.ack = orig_ack; /* client is in control of this ack */ 267 new->async_tx.flags = orig_flags; /* client is in control of this ack */
268 268
269 /* store the original values for use in later cleanup */ 269 /* store the original values for use in later cleanup */
270 if (new != first) { 270 if (new != first) {
@@ -304,14 +304,14 @@ static dma_cookie_t ioat2_tx_submit(struct dma_async_tx_descriptor *tx)
304 u32 copy; 304 u32 copy;
305 size_t len; 305 size_t len;
306 dma_addr_t src, dst; 306 dma_addr_t src, dst;
307 int orig_ack; 307 unsigned long orig_flags;
308 unsigned int desc_count = 0; 308 unsigned int desc_count = 0;
309 309
310 /* src and dest and len are stored in the initial descriptor */ 310 /* src and dest and len are stored in the initial descriptor */
311 len = first->len; 311 len = first->len;
312 src = first->src; 312 src = first->src;
313 dst = first->dst; 313 dst = first->dst;
314 orig_ack = first->async_tx.ack; 314 orig_flags = first->async_tx.flags;
315 new = first; 315 new = first;
316 316
317 /* 317 /*
@@ -321,7 +321,7 @@ static dma_cookie_t ioat2_tx_submit(struct dma_async_tx_descriptor *tx)
321 do { 321 do {
322 copy = min_t(size_t, len, ioat_chan->xfercap); 322 copy = min_t(size_t, len, ioat_chan->xfercap);
323 323
324 new->async_tx.ack = 1; 324 async_tx_ack(&new->async_tx);
325 325
326 hw = new->hw; 326 hw = new->hw;
327 hw->size = copy; 327 hw->size = copy;
@@ -349,7 +349,7 @@ static dma_cookie_t ioat2_tx_submit(struct dma_async_tx_descriptor *tx)
349 } 349 }
350 350
351 new->tx_cnt = desc_count; 351 new->tx_cnt = desc_count;
352 new->async_tx.ack = orig_ack; /* client is in control of this ack */ 352 new->async_tx.flags = orig_flags; /* client is in control of this ack */
353 353
354 /* store the original values for use in later cleanup */ 354 /* store the original values for use in later cleanup */
355 if (new != first) { 355 if (new != first) {
@@ -714,7 +714,7 @@ static struct dma_async_tx_descriptor *ioat1_dma_prep_memcpy(
714 new->len = len; 714 new->len = len;
715 new->dst = dma_dest; 715 new->dst = dma_dest;
716 new->src = dma_src; 716 new->src = dma_src;
717 new->async_tx.ack = 0; 717 new->async_tx.flags = flags;
718 return &new->async_tx; 718 return &new->async_tx;
719 } else 719 } else
720 return NULL; 720 return NULL;
@@ -742,7 +742,7 @@ static struct dma_async_tx_descriptor *ioat2_dma_prep_memcpy(
742 new->len = len; 742 new->len = len;
743 new->dst = dma_dest; 743 new->dst = dma_dest;
744 new->src = dma_src; 744 new->src = dma_src;
745 new->async_tx.ack = 0; 745 new->async_tx.flags = flags;
746 return &new->async_tx; 746 return &new->async_tx;
747 } else 747 } else
748 return NULL; 748 return NULL;
@@ -842,7 +842,7 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan)
842 * a completed entry, but not the last, so clean 842 * a completed entry, but not the last, so clean
843 * up if the client is done with the descriptor 843 * up if the client is done with the descriptor
844 */ 844 */
845 if (desc->async_tx.ack) { 845 if (async_tx_test_ack(&desc->async_tx)) {
846 list_del(&desc->node); 846 list_del(&desc->node);
847 list_add_tail(&desc->node, 847 list_add_tail(&desc->node,
848 &ioat_chan->free_desc); 848 &ioat_chan->free_desc);
@@ -924,17 +924,6 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan)
924 spin_unlock_bh(&ioat_chan->cleanup_lock); 924 spin_unlock_bh(&ioat_chan->cleanup_lock);
925} 925}
926 926
927static void ioat_dma_dependency_added(struct dma_chan *chan)
928{
929 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
930 spin_lock_bh(&ioat_chan->desc_lock);
931 if (ioat_chan->pending == 0) {
932 spin_unlock_bh(&ioat_chan->desc_lock);
933 ioat_dma_memcpy_cleanup(ioat_chan);
934 } else
935 spin_unlock_bh(&ioat_chan->desc_lock);
936}
937
938/** 927/**
939 * ioat_dma_is_complete - poll the status of a IOAT DMA transaction 928 * ioat_dma_is_complete - poll the status of a IOAT DMA transaction
940 * @chan: IOAT DMA channel handle 929 * @chan: IOAT DMA channel handle
@@ -990,7 +979,7 @@ static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan)
990 desc->hw->size = 0; 979 desc->hw->size = 0;
991 desc->hw->src_addr = 0; 980 desc->hw->src_addr = 0;
992 desc->hw->dst_addr = 0; 981 desc->hw->dst_addr = 0;
993 desc->async_tx.ack = 1; 982 async_tx_ack(&desc->async_tx);
994 switch (ioat_chan->device->version) { 983 switch (ioat_chan->device->version) {
995 case IOAT_VER_1_2: 984 case IOAT_VER_1_2:
996 desc->hw->next = 0; 985 desc->hw->next = 0;
@@ -1316,7 +1305,6 @@ struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev,
1316 1305
1317 dma_cap_set(DMA_MEMCPY, device->common.cap_mask); 1306 dma_cap_set(DMA_MEMCPY, device->common.cap_mask);
1318 device->common.device_is_tx_complete = ioat_dma_is_complete; 1307 device->common.device_is_tx_complete = ioat_dma_is_complete;
1319 device->common.device_dependency_added = ioat_dma_dependency_added;
1320 switch (device->version) { 1308 switch (device->version) {
1321 case IOAT_VER_1_2: 1309 case IOAT_VER_1_2:
1322 device->common.device_prep_dma_memcpy = ioat1_dma_prep_memcpy; 1310 device->common.device_prep_dma_memcpy = ioat1_dma_prep_memcpy;
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c
index f82b0906d466..762b729672e0 100644
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -63,7 +63,6 @@ iop_adma_run_tx_complete_actions(struct iop_adma_desc_slot *desc,
63 struct iop_adma_chan *iop_chan, dma_cookie_t cookie) 63 struct iop_adma_chan *iop_chan, dma_cookie_t cookie)
64{ 64{
65 BUG_ON(desc->async_tx.cookie < 0); 65 BUG_ON(desc->async_tx.cookie < 0);
66 spin_lock_bh(&desc->async_tx.lock);
67 if (desc->async_tx.cookie > 0) { 66 if (desc->async_tx.cookie > 0) {
68 cookie = desc->async_tx.cookie; 67 cookie = desc->async_tx.cookie;
69 desc->async_tx.cookie = 0; 68 desc->async_tx.cookie = 0;
@@ -101,7 +100,6 @@ iop_adma_run_tx_complete_actions(struct iop_adma_desc_slot *desc,
101 100
102 /* run dependent operations */ 101 /* run dependent operations */
103 async_tx_run_dependencies(&desc->async_tx); 102 async_tx_run_dependencies(&desc->async_tx);
104 spin_unlock_bh(&desc->async_tx.lock);
105 103
106 return cookie; 104 return cookie;
107} 105}
@@ -113,7 +111,7 @@ iop_adma_clean_slot(struct iop_adma_desc_slot *desc,
113 /* the client is allowed to attach dependent operations 111 /* the client is allowed to attach dependent operations
114 * until 'ack' is set 112 * until 'ack' is set
115 */ 113 */
116 if (!desc->async_tx.ack) 114 if (!async_tx_test_ack(&desc->async_tx))
117 return 0; 115 return 0;
118 116
119 /* leave the last descriptor in the chain 117 /* leave the last descriptor in the chain
@@ -150,7 +148,7 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan)
150 "this_desc: %#x next_desc: %#x ack: %d\n", 148 "this_desc: %#x next_desc: %#x ack: %d\n",
151 iter->async_tx.cookie, iter->idx, busy, 149 iter->async_tx.cookie, iter->idx, busy,
152 iter->async_tx.phys, iop_desc_get_next_desc(iter), 150 iter->async_tx.phys, iop_desc_get_next_desc(iter),
153 iter->async_tx.ack); 151 async_tx_test_ack(&iter->async_tx));
154 prefetch(_iter); 152 prefetch(_iter);
155 prefetch(&_iter->async_tx); 153 prefetch(&_iter->async_tx);
156 154
@@ -257,8 +255,6 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan)
257 255
258 BUG_ON(!seen_current); 256 BUG_ON(!seen_current);
259 257
260 iop_chan_idle(busy, iop_chan);
261
262 if (cookie > 0) { 258 if (cookie > 0) {
263 iop_chan->completed_cookie = cookie; 259 iop_chan->completed_cookie = cookie;
264 pr_debug("\tcompleted cookie %d\n", cookie); 260 pr_debug("\tcompleted cookie %d\n", cookie);
@@ -275,8 +271,11 @@ iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan)
275 271
276static void iop_adma_tasklet(unsigned long data) 272static void iop_adma_tasklet(unsigned long data)
277{ 273{
278 struct iop_adma_chan *chan = (struct iop_adma_chan *) data; 274 struct iop_adma_chan *iop_chan = (struct iop_adma_chan *) data;
279 __iop_adma_slot_cleanup(chan); 275
276 spin_lock(&iop_chan->lock);
277 __iop_adma_slot_cleanup(iop_chan);
278 spin_unlock(&iop_chan->lock);
280} 279}
281 280
282static struct iop_adma_desc_slot * 281static struct iop_adma_desc_slot *
@@ -339,9 +338,7 @@ retry:
339 338
340 /* pre-ack all but the last descriptor */ 339 /* pre-ack all but the last descriptor */
341 if (num_slots != slots_per_op) 340 if (num_slots != slots_per_op)
342 iter->async_tx.ack = 1; 341 async_tx_ack(&iter->async_tx);
343 else
344 iter->async_tx.ack = 0;
345 342
346 list_add_tail(&iter->chain_node, &chain); 343 list_add_tail(&iter->chain_node, &chain);
347 alloc_tail = iter; 344 alloc_tail = iter;
@@ -514,7 +511,7 @@ static int iop_adma_alloc_chan_resources(struct dma_chan *chan)
514} 511}
515 512
516static struct dma_async_tx_descriptor * 513static struct dma_async_tx_descriptor *
517iop_adma_prep_dma_interrupt(struct dma_chan *chan) 514iop_adma_prep_dma_interrupt(struct dma_chan *chan, unsigned long flags)
518{ 515{
519 struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan); 516 struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
520 struct iop_adma_desc_slot *sw_desc, *grp_start; 517 struct iop_adma_desc_slot *sw_desc, *grp_start;
@@ -529,6 +526,7 @@ iop_adma_prep_dma_interrupt(struct dma_chan *chan)
529 grp_start = sw_desc->group_head; 526 grp_start = sw_desc->group_head;
530 iop_desc_init_interrupt(grp_start, iop_chan); 527 iop_desc_init_interrupt(grp_start, iop_chan);
531 grp_start->unmap_len = 0; 528 grp_start->unmap_len = 0;
529 sw_desc->async_tx.flags = flags;
532 } 530 }
533 spin_unlock_bh(&iop_chan->lock); 531 spin_unlock_bh(&iop_chan->lock);
534 532
@@ -561,6 +559,7 @@ iop_adma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dma_dest,
561 iop_desc_set_memcpy_src_addr(grp_start, dma_src); 559 iop_desc_set_memcpy_src_addr(grp_start, dma_src);
562 sw_desc->unmap_src_cnt = 1; 560 sw_desc->unmap_src_cnt = 1;
563 sw_desc->unmap_len = len; 561 sw_desc->unmap_len = len;
562 sw_desc->async_tx.flags = flags;
564 } 563 }
565 spin_unlock_bh(&iop_chan->lock); 564 spin_unlock_bh(&iop_chan->lock);
566 565
@@ -593,6 +592,7 @@ iop_adma_prep_dma_memset(struct dma_chan *chan, dma_addr_t dma_dest,
593 iop_desc_set_dest_addr(grp_start, iop_chan, dma_dest); 592 iop_desc_set_dest_addr(grp_start, iop_chan, dma_dest);
594 sw_desc->unmap_src_cnt = 1; 593 sw_desc->unmap_src_cnt = 1;
595 sw_desc->unmap_len = len; 594 sw_desc->unmap_len = len;
595 sw_desc->async_tx.flags = flags;
596 } 596 }
597 spin_unlock_bh(&iop_chan->lock); 597 spin_unlock_bh(&iop_chan->lock);
598 598
@@ -626,6 +626,7 @@ iop_adma_prep_dma_xor(struct dma_chan *chan, dma_addr_t dma_dest,
626 iop_desc_set_dest_addr(grp_start, iop_chan, dma_dest); 626 iop_desc_set_dest_addr(grp_start, iop_chan, dma_dest);
627 sw_desc->unmap_src_cnt = src_cnt; 627 sw_desc->unmap_src_cnt = src_cnt;
628 sw_desc->unmap_len = len; 628 sw_desc->unmap_len = len;
629 sw_desc->async_tx.flags = flags;
629 while (src_cnt--) 630 while (src_cnt--)
630 iop_desc_set_xor_src_addr(grp_start, src_cnt, 631 iop_desc_set_xor_src_addr(grp_start, src_cnt,
631 dma_src[src_cnt]); 632 dma_src[src_cnt]);
@@ -662,6 +663,7 @@ iop_adma_prep_dma_zero_sum(struct dma_chan *chan, dma_addr_t *dma_src,
662 __func__, grp_start->xor_check_result); 663 __func__, grp_start->xor_check_result);
663 sw_desc->unmap_src_cnt = src_cnt; 664 sw_desc->unmap_src_cnt = src_cnt;
664 sw_desc->unmap_len = len; 665 sw_desc->unmap_len = len;
666 sw_desc->async_tx.flags = flags;
665 while (src_cnt--) 667 while (src_cnt--)
666 iop_desc_set_zero_sum_src_addr(grp_start, src_cnt, 668 iop_desc_set_zero_sum_src_addr(grp_start, src_cnt,
667 dma_src[src_cnt]); 669 dma_src[src_cnt]);
@@ -671,12 +673,6 @@ iop_adma_prep_dma_zero_sum(struct dma_chan *chan, dma_addr_t *dma_src,
671 return sw_desc ? &sw_desc->async_tx : NULL; 673 return sw_desc ? &sw_desc->async_tx : NULL;
672} 674}
673 675
674static void iop_adma_dependency_added(struct dma_chan *chan)
675{
676 struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
677 tasklet_schedule(&iop_chan->irq_tasklet);
678}
679
680static void iop_adma_free_chan_resources(struct dma_chan *chan) 676static void iop_adma_free_chan_resources(struct dma_chan *chan)
681{ 677{
682 struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan); 678 struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
@@ -854,11 +850,11 @@ static int __devinit iop_adma_memcpy_self_test(struct iop_adma_device *device)
854 src_dma = dma_map_single(dma_chan->device->dev, src, 850 src_dma = dma_map_single(dma_chan->device->dev, src,
855 IOP_ADMA_TEST_SIZE, DMA_TO_DEVICE); 851 IOP_ADMA_TEST_SIZE, DMA_TO_DEVICE);
856 tx = iop_adma_prep_dma_memcpy(dma_chan, dest_dma, src_dma, 852 tx = iop_adma_prep_dma_memcpy(dma_chan, dest_dma, src_dma,
857 IOP_ADMA_TEST_SIZE, 1); 853 IOP_ADMA_TEST_SIZE,
854 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
858 855
859 cookie = iop_adma_tx_submit(tx); 856 cookie = iop_adma_tx_submit(tx);
860 iop_adma_issue_pending(dma_chan); 857 iop_adma_issue_pending(dma_chan);
861 async_tx_ack(tx);
862 msleep(1); 858 msleep(1);
863 859
864 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) != 860 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) !=
@@ -954,11 +950,11 @@ iop_adma_xor_zero_sum_self_test(struct iop_adma_device *device)
954 dma_srcs[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i], 950 dma_srcs[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i],
955 0, PAGE_SIZE, DMA_TO_DEVICE); 951 0, PAGE_SIZE, DMA_TO_DEVICE);
956 tx = iop_adma_prep_dma_xor(dma_chan, dest_dma, dma_srcs, 952 tx = iop_adma_prep_dma_xor(dma_chan, dest_dma, dma_srcs,
957 IOP_ADMA_NUM_SRC_TEST, PAGE_SIZE, 1); 953 IOP_ADMA_NUM_SRC_TEST, PAGE_SIZE,
954 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
958 955
959 cookie = iop_adma_tx_submit(tx); 956 cookie = iop_adma_tx_submit(tx);
960 iop_adma_issue_pending(dma_chan); 957 iop_adma_issue_pending(dma_chan);
961 async_tx_ack(tx);
962 msleep(8); 958 msleep(8);
963 959
964 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) != 960 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) !=
@@ -1001,11 +997,11 @@ iop_adma_xor_zero_sum_self_test(struct iop_adma_device *device)
1001 DMA_TO_DEVICE); 997 DMA_TO_DEVICE);
1002 tx = iop_adma_prep_dma_zero_sum(dma_chan, dma_srcs, 998 tx = iop_adma_prep_dma_zero_sum(dma_chan, dma_srcs,
1003 IOP_ADMA_NUM_SRC_TEST + 1, PAGE_SIZE, 999 IOP_ADMA_NUM_SRC_TEST + 1, PAGE_SIZE,
1004 &zero_sum_result, 1); 1000 &zero_sum_result,
1001 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
1005 1002
1006 cookie = iop_adma_tx_submit(tx); 1003 cookie = iop_adma_tx_submit(tx);
1007 iop_adma_issue_pending(dma_chan); 1004 iop_adma_issue_pending(dma_chan);
1008 async_tx_ack(tx);
1009 msleep(8); 1005 msleep(8);
1010 1006
1011 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) { 1007 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) {
@@ -1025,11 +1021,11 @@ iop_adma_xor_zero_sum_self_test(struct iop_adma_device *device)
1025 /* test memset */ 1021 /* test memset */
1026 dma_addr = dma_map_page(dma_chan->device->dev, dest, 0, 1022 dma_addr = dma_map_page(dma_chan->device->dev, dest, 0,
1027 PAGE_SIZE, DMA_FROM_DEVICE); 1023 PAGE_SIZE, DMA_FROM_DEVICE);
1028 tx = iop_adma_prep_dma_memset(dma_chan, dma_addr, 0, PAGE_SIZE, 1); 1024 tx = iop_adma_prep_dma_memset(dma_chan, dma_addr, 0, PAGE_SIZE,
1025 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
1029 1026
1030 cookie = iop_adma_tx_submit(tx); 1027 cookie = iop_adma_tx_submit(tx);
1031 iop_adma_issue_pending(dma_chan); 1028 iop_adma_issue_pending(dma_chan);
1032 async_tx_ack(tx);
1033 msleep(8); 1029 msleep(8);
1034 1030
1035 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) { 1031 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) {
@@ -1057,11 +1053,11 @@ iop_adma_xor_zero_sum_self_test(struct iop_adma_device *device)
1057 DMA_TO_DEVICE); 1053 DMA_TO_DEVICE);
1058 tx = iop_adma_prep_dma_zero_sum(dma_chan, dma_srcs, 1054 tx = iop_adma_prep_dma_zero_sum(dma_chan, dma_srcs,
1059 IOP_ADMA_NUM_SRC_TEST + 1, PAGE_SIZE, 1055 IOP_ADMA_NUM_SRC_TEST + 1, PAGE_SIZE,
1060 &zero_sum_result, 1); 1056 &zero_sum_result,
1057 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
1061 1058
1062 cookie = iop_adma_tx_submit(tx); 1059 cookie = iop_adma_tx_submit(tx);
1063 iop_adma_issue_pending(dma_chan); 1060 iop_adma_issue_pending(dma_chan);
1064 async_tx_ack(tx);
1065 msleep(8); 1061 msleep(8);
1066 1062
1067 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) { 1063 if (iop_adma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) {
@@ -1177,7 +1173,6 @@ static int __devinit iop_adma_probe(struct platform_device *pdev)
1177 dma_dev->device_free_chan_resources = iop_adma_free_chan_resources; 1173 dma_dev->device_free_chan_resources = iop_adma_free_chan_resources;
1178 dma_dev->device_is_tx_complete = iop_adma_is_complete; 1174 dma_dev->device_is_tx_complete = iop_adma_is_complete;
1179 dma_dev->device_issue_pending = iop_adma_issue_pending; 1175 dma_dev->device_issue_pending = iop_adma_issue_pending;
1180 dma_dev->device_dependency_added = iop_adma_dependency_added;
1181 dma_dev->dev = &pdev->dev; 1176 dma_dev->dev = &pdev->dev;
1182 1177
1183 /* set prep routines based on capability */ 1178 /* set prep routines based on capability */
@@ -1232,9 +1227,6 @@ static int __devinit iop_adma_probe(struct platform_device *pdev)
1232 } 1227 }
1233 1228
1234 spin_lock_init(&iop_chan->lock); 1229 spin_lock_init(&iop_chan->lock);
1235 init_timer(&iop_chan->cleanup_watchdog);
1236 iop_chan->cleanup_watchdog.data = (unsigned long) iop_chan;
1237 iop_chan->cleanup_watchdog.function = iop_adma_tasklet;
1238 INIT_LIST_HEAD(&iop_chan->chain); 1230 INIT_LIST_HEAD(&iop_chan->chain);
1239 INIT_LIST_HEAD(&iop_chan->all_slots); 1231 INIT_LIST_HEAD(&iop_chan->all_slots);
1240 INIT_RCU_HEAD(&iop_chan->common.rcu); 1232 INIT_RCU_HEAD(&iop_chan->common.rcu);
@@ -1298,7 +1290,7 @@ static void iop_chan_start_null_memcpy(struct iop_adma_chan *iop_chan)
1298 grp_start = sw_desc->group_head; 1290 grp_start = sw_desc->group_head;
1299 1291
1300 list_splice_init(&sw_desc->async_tx.tx_list, &iop_chan->chain); 1292 list_splice_init(&sw_desc->async_tx.tx_list, &iop_chan->chain);
1301 sw_desc->async_tx.ack = 1; 1293 async_tx_ack(&sw_desc->async_tx);
1302 iop_desc_init_memcpy(grp_start, 0); 1294 iop_desc_init_memcpy(grp_start, 0);
1303 iop_desc_set_byte_count(grp_start, iop_chan, 0); 1295 iop_desc_set_byte_count(grp_start, iop_chan, 0);
1304 iop_desc_set_dest_addr(grp_start, iop_chan, 0); 1296 iop_desc_set_dest_addr(grp_start, iop_chan, 0);
@@ -1354,7 +1346,7 @@ static void iop_chan_start_null_xor(struct iop_adma_chan *iop_chan)
1354 if (sw_desc) { 1346 if (sw_desc) {
1355 grp_start = sw_desc->group_head; 1347 grp_start = sw_desc->group_head;
1356 list_splice_init(&sw_desc->async_tx.tx_list, &iop_chan->chain); 1348 list_splice_init(&sw_desc->async_tx.tx_list, &iop_chan->chain);
1357 sw_desc->async_tx.ack = 1; 1349 async_tx_ack(&sw_desc->async_tx);
1358 iop_desc_init_null_xor(grp_start, 2, 0); 1350 iop_desc_init_null_xor(grp_start, 2, 0);
1359 iop_desc_set_byte_count(grp_start, iop_chan, 0); 1351 iop_desc_set_byte_count(grp_start, iop_chan, 0);
1360 iop_desc_set_dest_addr(grp_start, iop_chan, 0); 1352 iop_desc_set_dest_addr(grp_start, iop_chan, 0);