summaryrefslogtreecommitdiff
path: root/drivers/dma
diff options
context:
space:
mode:
authorRussell King - ARM Linux <linux@arm.linux.org.uk>2012-03-06 22:35:47 +0000
committerSimone Willett <swillett@nvidia.com>2012-04-03 09:36:16 -0700
commitff27e02b2ca48beb0330473427fa8e0be64c15ab (patch)
tree368456e1e5e5001ea132e57a748defbfe9309775 /drivers/dma
parentb1ca7f8af4b3c86635fc523283c2bed9175aea14 (diff)
dmaengine: consolidate initialization of cookies
Provide a common function to initialize a channels cookie values. Change-Id: Idc822d69971d7a6d26ffea8809df4825b87020e5 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Tested-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Jassi Brar <jassisinghbrar@gmail.com> [imx-sdma.c & mxs-dma.c] Tested-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com> (cherry picked from mainline commit d3ee98cdcd6198ea1cf75c603178acc8a805b69b) Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Change-Id: Id7d52f05b78d15b0c61cb04122b19810e78b9269 Reviewed-on: http://git-master/r/93783
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/amba-pl08x.c3
-rw-r--r--drivers/dma/at_hdmac.c4
-rw-r--r--drivers/dma/coh901318.c2
-rw-r--r--drivers/dma/dmaengine.h10
-rw-r--r--drivers/dma/dw_dmac.c12
-rw-r--r--drivers/dma/ep93xx_dma.c3
-rw-r--r--drivers/dma/intel_mid_dma.c6
-rw-r--r--drivers/dma/ipu/ipu_idmac.c10
-rw-r--r--drivers/dma/mpc512x_dma.c3
-rw-r--r--drivers/dma/pch_dma.c6
-rw-r--r--drivers/dma/pl330.c2
-rw-r--r--drivers/dma/sirf-dma.c3
-rw-r--r--drivers/dma/ste_dma40.c2
-rw-r--r--drivers/dma/timb_dma.c7
-rw-r--r--drivers/dma/txx9dmac.c10
15 files changed, 62 insertions, 21 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index df8da2a503c1..c6704da02387 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -1718,8 +1718,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x,
chan->name);
chan->chan.device = dmadev;
- chan->chan.cookie = 0;
- chan->chan.completed_cookie = 0;
+ dma_cookie_init(&chan->chan);
spin_lock_init(&chan->lock);
INIT_LIST_HEAD(&chan->pend_list);
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index ddeeadded1af..2def41f09f65 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -1093,7 +1093,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan)
spin_lock_bh(&atchan->lock);
atchan->descs_allocated = i;
list_splice(&tmp_list, &atchan->free_list);
- atchan->completed_cookie = chan->cookie = 1;
+ dma_cookie_init(chan);
spin_unlock_bh(&atchan->lock);
/* channel parameters */
@@ -1239,7 +1239,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
atchan->chan_common.device = &atdma->dma_common;
atchan->chan_common.chan_id = i;
- atchan->chan_common.cookie = atchan->chan_common.completed_cookie = 1;
+ dma_cookie_init(&atchan->chan_common);
list_add_tail(&atchan->chan_common.device_node,
&atdma->dma_common.channels);
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index 5249082476f6..3d1ff2edd4c0 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -915,7 +915,7 @@ static int coh901318_alloc_chan_resources(struct dma_chan *chan)
coh901318_config(cohc, NULL);
cohc->allocated = 1;
- chan->completed_cookie = chan->cookie = 1;
+ dma_cookie_init(chan);
spin_unlock_irqrestore(&cohc->lock, flags);
diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
index 1ca5e0e633f4..17f983a4e9ba 100644
--- a/drivers/dma/dmaengine.h
+++ b/drivers/dma/dmaengine.h
@@ -9,6 +9,16 @@
#include <linux/dmaengine.h>
/**
+ * dma_cookie_init - initialize the cookies for a DMA channel
+ * @chan: dma channel to initialize
+ */
+static inline void dma_cookie_init(struct dma_chan *chan)
+{
+ chan->cookie = DMA_MIN_COOKIE;
+ chan->completed_cookie = DMA_MIN_COOKIE;
+}
+
+/**
* dma_cookie_assign - assign a DMA engine cookie to the descriptor
* @tx: descriptor needing cookie
*
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 9f45bde70641..36ffc4cdaf80 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -979,7 +979,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan)
return -EIO;
}
- chan->completed_cookie = chan->cookie = 1;
+ dma_cookie_init(chan);
cfghi = DWC_CFGH_FIFO_MODE;
cfglo = 0;
@@ -1000,6 +1000,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan)
channel_writel(dwc, CFG_LO, cfglo);
channel_writel(dwc, CFG_HI, cfghi);
+ dma_cookie_init(chan);
/*
* NOTE: some controllers may have additional features that we
@@ -1417,8 +1418,17 @@ static int __init dw_probe(struct platform_device *pdev)
struct dw_dma_chan *dwc = &dw->chan[i];
dwc->chan.device = &dw->dma;
+<<<<<<< HEAD
dwc->chan.chan_id = i;
dwc->chan.cookie = dwc->chan.completed_cookie = 1;
+=======
+<<<<<<< HEAD
+ dwc->chan.cookie = dwc->completed = 1;
+ dwc->chan.chan_id = i;
+=======
+ dma_cookie_init(&dwc->chan);
+>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
+>>>>>>> 1e15982... dmaengine: consolidate initialization of cookies
if (pdata->chan_allocation_order == CHAN_ALLOCATION_ASCENDING)
list_add_tail(&dwc->chan.device_node,
&dw->dma.channels);
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index e74b09cdc9c5..47950b55f6ea 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -821,8 +821,7 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
goto fail_clk_disable;
spin_lock_irq(&edmac->lock);
- edmac->chan.completed_cookie = 1;
- edmac->chan.cookie = 1;
+ dma_cookie_init(&edmac->chan);
ret = edmac->edma->hw_setup(edmac);
spin_unlock_irq(&edmac->lock);
diff --git a/drivers/dma/intel_mid_dma.c b/drivers/dma/intel_mid_dma.c
index c68f1f763e18..83380c56ac37 100644
--- a/drivers/dma/intel_mid_dma.c
+++ b/drivers/dma/intel_mid_dma.c
@@ -862,7 +862,7 @@ static int intel_mid_dma_alloc_chan_resources(struct dma_chan *chan)
pm_runtime_put(&mid->pdev->dev);
return -EIO;
}
- chan->completed_cookie = chan->cookie = 1;
+ dma_cookie_init(chan);
spin_lock_bh(&midc->lock);
while (midc->descs_allocated < DESCS_PER_CHANNEL) {
@@ -1093,8 +1093,12 @@ static int mid_setup_dma(struct pci_dev *pdev)
struct intel_mid_dma_chan *midch = &dma->ch[i];
midch->chan.device = &dma->common;
+<<<<<<< HEAD
midch->chan.cookie = 1;
midch->chan.chan_id = i;
+=======
+ dma_cookie_init(&midch->chan);
+>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
midch->ch_id = dma->chan_base + i;
pr_debug("MDMA:Init CH %d, ID %d\n", i, midch->ch_id);
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c
index fbc9034f597e..b37edcece79e 100644
--- a/drivers/dma/ipu/ipu_idmac.c
+++ b/drivers/dma/ipu/ipu_idmac.c
@@ -1506,8 +1506,7 @@ static int idmac_alloc_chan_resources(struct dma_chan *chan)
BUG_ON(chan->client_count > 1);
WARN_ON(ichan->status != IPU_CHANNEL_FREE);
- chan->cookie = 1;
- chan->completed_cookie = -ENXIO;
+ dma_cookie_init(chan);
ret = ipu_irq_map(chan->chan_id);
if (ret < 0)
@@ -1635,8 +1634,15 @@ static int __init ipu_idmac_init(struct ipu *ipu)
snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i);
dma_chan->device = &idmac->dma;
+<<<<<<< HEAD
dma_chan->cookie = 1;
+<<<<<<< HEAD
dma_chan->completed_cookie = -ENXIO;
+=======
+=======
+ dma_cookie_init(dma_chan);
+>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
+>>>>>>> 1e15982... dmaengine: consolidate initialization of cookies
dma_chan->chan_id = i;
list_add_tail(&dma_chan->device_node, &dma->channels);
}
diff --git a/drivers/dma/mpc512x_dma.c b/drivers/dma/mpc512x_dma.c
index 3b5b61dc4349..3034cb768015 100644
--- a/drivers/dma/mpc512x_dma.c
+++ b/drivers/dma/mpc512x_dma.c
@@ -734,8 +734,7 @@ static int __devinit mpc_dma_probe(struct platform_device *op)
mchan->chan.device = dma;
mchan->chan.chan_id = i;
- mchan->chan.cookie = 1;
- mchan->chan.completed_cookie = mchan->chan.cookie;
+ dma_cookie_init(&mchan->chan);
INIT_LIST_HEAD(&mchan->free);
INIT_LIST_HEAD(&mchan->prepared);
diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index 5a346976ee23..4762f458e6d3 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -531,7 +531,7 @@ static int pd_alloc_chan_resources(struct dma_chan *chan)
spin_lock_irq(&pd_chan->lock);
list_splice(&tmp_list, &pd_chan->free_list);
pd_chan->descs_allocated = i;
- chan->completed_cookie = chan->cookie = 1;
+ dma_cookie_init(chan);
spin_unlock_irq(&pd_chan->lock);
pdc_enable_irq(chan, 1);
@@ -914,8 +914,12 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev,
struct pch_dma_chan *pd_chan = &pd->channels[i];
pd_chan->chan.device = &pd->dma;
+<<<<<<< HEAD
pd_chan->chan.cookie = 1;
pd_chan->chan.chan_id = i;
+=======
+ dma_cookie_init(&pd_chan->chan);
+>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
pd_chan->membase = &regs->desc[i];
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index da0b2974c598..254046c67024 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -234,7 +234,7 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan)
spin_lock_irqsave(&pch->lock, flags);
- chan->completed_cookie = chan->cookie = 1;
+ dma_cookie_init(chan);
pch->cyclic = false;
pch->pl330_chid = pl330_request_channel(&pdmac->pif);
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index dd81987e3529..824a7e0b9614 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -626,8 +626,7 @@ static int __devinit sirfsoc_dma_probe(struct platform_device *op)
schan = &sdma->channels[i];
schan->chan.device = dma;
- schan->chan.cookie = 1;
- schan->chan.completed_cookie = schan->chan.cookie;
+ dma_cookie_init(&schan->chan);
INIT_LIST_HEAD(&schan->free);
INIT_LIST_HEAD(&schan->prepared);
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 037a4d8e62c4..0a61f15d49d7 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1990,7 +1990,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
bool is_free_phy;
spin_lock_irqsave(&d40c->lock, flags);
- chan->completed_cookie = chan->cookie = 1;
+ dma_cookie_init(chan);
/* If no dma configuration is set use default configuration (memcpy) */
if (!d40c->configured) {
diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c
index ad3396b52cbd..49e5b0234e81 100644
--- a/drivers/dma/timb_dma.c
+++ b/drivers/dma/timb_dma.c
@@ -477,8 +477,7 @@ static int td_alloc_chan_resources(struct dma_chan *chan)
}
spin_lock_bh(&td_chan->lock);
- chan->completed_cookie = 1;
- chan->cookie = 1;
+ dma_cookie_init(chan);
spin_unlock_bh(&td_chan->lock);
return 0;
@@ -755,8 +754,12 @@ static int __devinit td_probe(struct platform_device *pdev)
}
td_chan->chan.device = &td->dma;
+<<<<<<< HEAD
td_chan->chan.cookie = 1;
td_chan->chan.chan_id = i;
+=======
+ dma_cookie_init(&td_chan->chan);
+>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
spin_lock_init(&td_chan->lock);
INIT_LIST_HEAD(&td_chan->active_list);
INIT_LIST_HEAD(&td_chan->queue);
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c
index 93e0eb58b01b..e743c9c7c20a 100644
--- a/drivers/dma/txx9dmac.c
+++ b/drivers/dma/txx9dmac.c
@@ -1033,7 +1033,7 @@ static int txx9dmac_alloc_chan_resources(struct dma_chan *chan)
return -EIO;
}
- chan->completed_cookie = chan->cookie = 1;
+ dma_cookie_init(chan);
dc->ccr = TXX9_DMA_CCR_IMMCHN | TXX9_DMA_CCR_INTENE | CCR_LE;
txx9dmac_chan_set_SMPCHN(dc);
@@ -1162,7 +1162,15 @@ static int __init txx9dmac_chan_probe(struct platform_device *pdev)
dc->ddev->chan[ch] = dc;
dc->chan.device = &dc->dma;
list_add_tail(&dc->chan.device_node, &dc->chan.device->channels);
+<<<<<<< HEAD
dc->chan.cookie = dc->chan.completed_cookie = 1;
+=======
+<<<<<<< HEAD
+ dc->chan.cookie = dc->completed = 1;
+=======
+ dma_cookie_init(&dc->chan);
+>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
+>>>>>>> 1e15982... dmaengine: consolidate initialization of cookies
if (is_dmac64(dc))
dc->ch_regs = &__txx9dmac_regs(dc->ddev)->CHAN[ch];