aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/ipu/ipu_idmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dma/ipu/ipu_idmac.c')
-rw-r--r--drivers/dma/ipu/ipu_idmac.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c
index 6212b16e8cf2..62e3f8ec2461 100644
--- a/drivers/dma/ipu/ipu_idmac.c
+++ b/drivers/dma/ipu/ipu_idmac.c
@@ -25,6 +25,7 @@
25 25
26#include <mach/ipu.h> 26#include <mach/ipu.h>
27 27
28#include "../dmaengine.h"
28#include "ipu_intern.h" 29#include "ipu_intern.h"
29 30
30#define FS_VF_IN_VALID 0x00000002 31#define FS_VF_IN_VALID 0x00000002
@@ -866,14 +867,7 @@ static dma_cookie_t idmac_tx_submit(struct dma_async_tx_descriptor *tx)
866 867
867 dev_dbg(dev, "Submitting sg %p\n", &desc->sg[0]); 868 dev_dbg(dev, "Submitting sg %p\n", &desc->sg[0]);
868 869
869 cookie = ichan->dma_chan.cookie; 870 cookie = dma_cookie_assign(tx);
870
871 if (++cookie < 0)
872 cookie = 1;
873
874 /* from dmaengine.h: "last cookie value returned to client" */
875 ichan->dma_chan.cookie = cookie;
876 tx->cookie = cookie;
877 871
878 /* ipu->lock can be taken under ichan->lock, but not v.v. */ 872 /* ipu->lock can be taken under ichan->lock, but not v.v. */
879 spin_lock_irqsave(&ichan->lock, flags); 873 spin_lock_irqsave(&ichan->lock, flags);
@@ -1295,7 +1289,7 @@ static irqreturn_t idmac_interrupt(int irq, void *dev_id)
1295 /* Flip the active buffer - even if update above failed */ 1289 /* Flip the active buffer - even if update above failed */
1296 ichan->active_buffer = !ichan->active_buffer; 1290 ichan->active_buffer = !ichan->active_buffer;
1297 if (done) 1291 if (done)
1298 ichan->completed = desc->txd.cookie; 1292 dma_cookie_complete(&desc->txd);
1299 1293
1300 callback = desc->txd.callback; 1294 callback = desc->txd.callback;
1301 callback_param = desc->txd.callback_param; 1295 callback_param = desc->txd.callback_param;
@@ -1341,7 +1335,8 @@ static void ipu_gc_tasklet(unsigned long arg)
1341/* Allocate and initialise a transfer descriptor. */ 1335/* Allocate and initialise a transfer descriptor. */
1342static struct dma_async_tx_descriptor *idmac_prep_slave_sg(struct dma_chan *chan, 1336static struct dma_async_tx_descriptor *idmac_prep_slave_sg(struct dma_chan *chan,
1343 struct scatterlist *sgl, unsigned int sg_len, 1337 struct scatterlist *sgl, unsigned int sg_len,
1344 enum dma_transfer_direction direction, unsigned long tx_flags) 1338 enum dma_transfer_direction direction, unsigned long tx_flags,
1339 void *context)
1345{ 1340{
1346 struct idmac_channel *ichan = to_idmac_chan(chan); 1341 struct idmac_channel *ichan = to_idmac_chan(chan);
1347 struct idmac_tx_desc *desc = NULL; 1342 struct idmac_tx_desc *desc = NULL;
@@ -1510,8 +1505,7 @@ static int idmac_alloc_chan_resources(struct dma_chan *chan)
1510 BUG_ON(chan->client_count > 1); 1505 BUG_ON(chan->client_count > 1);
1511 WARN_ON(ichan->status != IPU_CHANNEL_FREE); 1506 WARN_ON(ichan->status != IPU_CHANNEL_FREE);
1512 1507
1513 chan->cookie = 1; 1508 dma_cookie_init(chan);
1514 ichan->completed = -ENXIO;
1515 1509
1516 ret = ipu_irq_map(chan->chan_id); 1510 ret = ipu_irq_map(chan->chan_id);
1517 if (ret < 0) 1511 if (ret < 0)
@@ -1600,9 +1594,7 @@ static void idmac_free_chan_resources(struct dma_chan *chan)
1600static enum dma_status idmac_tx_status(struct dma_chan *chan, 1594static enum dma_status idmac_tx_status(struct dma_chan *chan,
1601 dma_cookie_t cookie, struct dma_tx_state *txstate) 1595 dma_cookie_t cookie, struct dma_tx_state *txstate)
1602{ 1596{
1603 struct idmac_channel *ichan = to_idmac_chan(chan); 1597 dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie, 0);
1604
1605 dma_set_tx_state(txstate, ichan->completed, chan->cookie, 0);
1606 if (cookie != chan->cookie) 1598 if (cookie != chan->cookie)
1607 return DMA_ERROR; 1599 return DMA_ERROR;
1608 return DMA_SUCCESS; 1600 return DMA_SUCCESS;
@@ -1638,11 +1630,10 @@ static int __init ipu_idmac_init(struct ipu *ipu)
1638 1630
1639 ichan->status = IPU_CHANNEL_FREE; 1631 ichan->status = IPU_CHANNEL_FREE;
1640 ichan->sec_chan_en = false; 1632 ichan->sec_chan_en = false;
1641 ichan->completed = -ENXIO;
1642 snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i); 1633 snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i);
1643 1634
1644 dma_chan->device = &idmac->dma; 1635 dma_chan->device = &idmac->dma;
1645 dma_chan->cookie = 1; 1636 dma_cookie_init(dma_chan);
1646 dma_chan->chan_id = i; 1637 dma_chan->chan_id = i;
1647 list_add_tail(&dma_chan->device_node, &dma->channels); 1638 list_add_tail(&dma_chan->device_node, &dma->channels);
1648 } 1639 }