aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/pch_dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dma/pch_dma.c')
-rw-r--r--drivers/dma/pch_dma.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index 823f58179f9d..65c0495a6d40 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -25,6 +25,8 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/pch_dma.h> 26#include <linux/pch_dma.h>
27 27
28#include "dmaengine.h"
29
28#define DRV_NAME "pch-dma" 30#define DRV_NAME "pch-dma"
29 31
30#define DMA_CTL0_DISABLE 0x0 32#define DMA_CTL0_DISABLE 0x0
@@ -105,7 +107,6 @@ struct pch_dma_chan {
105 107
106 spinlock_t lock; 108 spinlock_t lock;
107 109
108 dma_cookie_t completed_cookie;
109 struct list_head active_list; 110 struct list_head active_list;
110 struct list_head queue; 111 struct list_head queue;
111 struct list_head free_list; 112 struct list_head free_list;
@@ -416,20 +417,6 @@ static void pdc_advance_work(struct pch_dma_chan *pd_chan)
416 } 417 }
417} 418}
418 419
419static dma_cookie_t pdc_assign_cookie(struct pch_dma_chan *pd_chan,
420 struct pch_dma_desc *desc)
421{
422 dma_cookie_t cookie = pd_chan->chan.cookie;
423
424 if (++cookie < 0)
425 cookie = 1;
426
427 pd_chan->chan.cookie = cookie;
428 desc->txd.cookie = cookie;
429
430 return cookie;
431}
432
433static dma_cookie_t pd_tx_submit(struct dma_async_tx_descriptor *txd) 420static dma_cookie_t pd_tx_submit(struct dma_async_tx_descriptor *txd)
434{ 421{
435 struct pch_dma_desc *desc = to_pd_desc(txd); 422 struct pch_dma_desc *desc = to_pd_desc(txd);
@@ -437,7 +424,7 @@ static dma_cookie_t pd_tx_submit(struct dma_async_tx_descriptor *txd)
437 dma_cookie_t cookie; 424 dma_cookie_t cookie;
438 425
439 spin_lock(&pd_chan->lock); 426 spin_lock(&pd_chan->lock);
440 cookie = pdc_assign_cookie(pd_chan, desc); 427 cookie = dma_cookie_assign(txd);
441 428
442 if (list_empty(&pd_chan->active_list)) { 429 if (list_empty(&pd_chan->active_list)) {
443 list_add_tail(&desc->desc_node, &pd_chan->active_list); 430 list_add_tail(&desc->desc_node, &pd_chan->active_list);
@@ -544,7 +531,7 @@ static int pd_alloc_chan_resources(struct dma_chan *chan)
544 spin_lock_irq(&pd_chan->lock); 531 spin_lock_irq(&pd_chan->lock);
545 list_splice(&tmp_list, &pd_chan->free_list); 532 list_splice(&tmp_list, &pd_chan->free_list);
546 pd_chan->descs_allocated = i; 533 pd_chan->descs_allocated = i;
547 pd_chan->completed_cookie = chan->cookie = 1; 534 dma_cookie_init(chan);
548 spin_unlock_irq(&pd_chan->lock); 535 spin_unlock_irq(&pd_chan->lock);
549 536
550 pdc_enable_irq(chan, 1); 537 pdc_enable_irq(chan, 1);
@@ -578,19 +565,12 @@ static enum dma_status pd_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
578 struct dma_tx_state *txstate) 565 struct dma_tx_state *txstate)
579{ 566{
580 struct pch_dma_chan *pd_chan = to_pd_chan(chan); 567 struct pch_dma_chan *pd_chan = to_pd_chan(chan);
581 dma_cookie_t last_used; 568 enum dma_status ret;
582 dma_cookie_t last_completed;
583 int ret;
584 569
585 spin_lock_irq(&pd_chan->lock); 570 spin_lock_irq(&pd_chan->lock);
586 last_completed = pd_chan->completed_cookie; 571 ret = dma_cookie_status(chan, cookie, txstate);
587 last_used = chan->cookie;
588 spin_unlock_irq(&pd_chan->lock); 572 spin_unlock_irq(&pd_chan->lock);
589 573
590 ret = dma_async_is_complete(cookie, last_completed, last_used);
591
592 dma_set_tx_state(txstate, last_completed, last_used, 0);
593
594 return ret; 574 return ret;
595} 575}
596 576
@@ -607,7 +587,8 @@ static void pd_issue_pending(struct dma_chan *chan)
607 587
608static struct dma_async_tx_descriptor *pd_prep_slave_sg(struct dma_chan *chan, 588static struct dma_async_tx_descriptor *pd_prep_slave_sg(struct dma_chan *chan,
609 struct scatterlist *sgl, unsigned int sg_len, 589 struct scatterlist *sgl, unsigned int sg_len,
610 enum dma_transfer_direction direction, unsigned long flags) 590 enum dma_transfer_direction direction, unsigned long flags,
591 void *context)
611{ 592{
612 struct pch_dma_chan *pd_chan = to_pd_chan(chan); 593 struct pch_dma_chan *pd_chan = to_pd_chan(chan);
613 struct pch_dma_slave *pd_slave = chan->private; 594 struct pch_dma_slave *pd_slave = chan->private;
@@ -932,7 +913,7 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev,
932 struct pch_dma_chan *pd_chan = &pd->channels[i]; 913 struct pch_dma_chan *pd_chan = &pd->channels[i];
933 914
934 pd_chan->chan.device = &pd->dma; 915 pd_chan->chan.device = &pd->dma;
935 pd_chan->chan.cookie = 1; 916 dma_cookie_init(&pd_chan->chan);
936 917
937 pd_chan->membase = &regs->desc[i]; 918 pd_chan->membase = &regs->desc[i];
938 919