Commit d3ee98cd authored by Russell King - ARM Linux's avatar Russell King - ARM Linux Committed by Vinod Koul

dmaengine: consolidate initialization of cookies

Provide a common function to initialize a channels cookie values.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Tested-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarJassi Brar <jassisinghbrar@gmail.com>
[imx-sdma.c & mxs-dma.c]
Tested-by: default avatarShawn Guo <shawn.guo@linaro.org>
Signed-off-by: default avatarVinod Koul <vinod.koul@linux.intel.com>
parent 96a2af41
...@@ -1709,8 +1709,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x, ...@@ -1709,8 +1709,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x,
chan->name); chan->name);
chan->chan.device = dmadev; chan->chan.device = dmadev;
chan->chan.cookie = 0; dma_cookie_init(&chan->chan);
chan->chan.completed_cookie = 0;
spin_lock_init(&chan->lock); spin_lock_init(&chan->lock);
INIT_LIST_HEAD(&chan->pend_list); INIT_LIST_HEAD(&chan->pend_list);
......
...@@ -1103,7 +1103,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan) ...@@ -1103,7 +1103,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan)
spin_lock_irqsave(&atchan->lock, flags); spin_lock_irqsave(&atchan->lock, flags);
atchan->descs_allocated = i; atchan->descs_allocated = i;
list_splice(&tmp_list, &atchan->free_list); list_splice(&tmp_list, &atchan->free_list);
chan->completed_cookie = chan->cookie = 1; dma_cookie_init(chan);
spin_unlock_irqrestore(&atchan->lock, flags); spin_unlock_irqrestore(&atchan->lock, flags);
/* channel parameters */ /* channel parameters */
...@@ -1303,7 +1303,7 @@ static int __init at_dma_probe(struct platform_device *pdev) ...@@ -1303,7 +1303,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
struct at_dma_chan *atchan = &atdma->chan[i]; struct at_dma_chan *atchan = &atdma->chan[i];
atchan->chan_common.device = &atdma->dma_common; atchan->chan_common.device = &atdma->dma_common;
atchan->chan_common.cookie = atchan->chan_common.completed_cookie = 1; dma_cookie_init(&atchan->chan_common);
list_add_tail(&atchan->chan_common.device_node, list_add_tail(&atchan->chan_common.device_node,
&atdma->dma_common.channels); &atdma->dma_common.channels);
......
...@@ -915,7 +915,7 @@ static int coh901318_alloc_chan_resources(struct dma_chan *chan) ...@@ -915,7 +915,7 @@ static int coh901318_alloc_chan_resources(struct dma_chan *chan)
coh901318_config(cohc, NULL); coh901318_config(cohc, NULL);
cohc->allocated = 1; cohc->allocated = 1;
chan->completed_cookie = chan->cookie = 1; dma_cookie_init(chan);
spin_unlock_irqrestore(&cohc->lock, flags); spin_unlock_irqrestore(&cohc->lock, flags);
......
...@@ -8,6 +8,16 @@ ...@@ -8,6 +8,16 @@
#include <linux/bug.h> #include <linux/bug.h>
#include <linux/dmaengine.h> #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 * dma_cookie_assign - assign a DMA engine cookie to the descriptor
* @tx: descriptor needing cookie * @tx: descriptor needing cookie
......
...@@ -1021,7 +1021,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan) ...@@ -1021,7 +1021,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan)
return -EIO; return -EIO;
} }
chan->completed_cookie = chan->cookie = 1; dma_cookie_init(chan);
/* /*
* NOTE: some controllers may have additional features that we * NOTE: some controllers may have additional features that we
...@@ -1449,7 +1449,7 @@ static int __init dw_probe(struct platform_device *pdev) ...@@ -1449,7 +1449,7 @@ static int __init dw_probe(struct platform_device *pdev)
struct dw_dma_chan *dwc = &dw->chan[i]; struct dw_dma_chan *dwc = &dw->chan[i];
dwc->chan.device = &dw->dma; dwc->chan.device = &dw->dma;
dwc->chan.cookie = dwc->chan.completed_cookie = 1; dma_cookie_init(&dwc->chan);
if (pdata->chan_allocation_order == CHAN_ALLOCATION_ASCENDING) if (pdata->chan_allocation_order == CHAN_ALLOCATION_ASCENDING)
list_add_tail(&dwc->chan.device_node, list_add_tail(&dwc->chan.device_node,
&dw->dma.channels); &dw->dma.channels);
......
...@@ -854,8 +854,7 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan) ...@@ -854,8 +854,7 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
goto fail_clk_disable; goto fail_clk_disable;
spin_lock_irq(&edmac->lock); spin_lock_irq(&edmac->lock);
edmac->chan.completed_cookie = 1; dma_cookie_init(&edmac->chan);
edmac->chan.cookie = 1;
ret = edmac->edma->hw_setup(edmac); ret = edmac->edma->hw_setup(edmac);
spin_unlock_irq(&edmac->lock); spin_unlock_irq(&edmac->lock);
......
...@@ -867,7 +867,7 @@ static int intel_mid_dma_alloc_chan_resources(struct dma_chan *chan) ...@@ -867,7 +867,7 @@ static int intel_mid_dma_alloc_chan_resources(struct dma_chan *chan)
pm_runtime_put(&mid->pdev->dev); pm_runtime_put(&mid->pdev->dev);
return -EIO; return -EIO;
} }
chan->completed_cookie = chan->cookie = 1; dma_cookie_init(chan);
spin_lock_bh(&midc->lock); spin_lock_bh(&midc->lock);
while (midc->descs_allocated < DESCS_PER_CHANNEL) { while (midc->descs_allocated < DESCS_PER_CHANNEL) {
...@@ -1100,7 +1100,7 @@ static int mid_setup_dma(struct pci_dev *pdev) ...@@ -1100,7 +1100,7 @@ static int mid_setup_dma(struct pci_dev *pdev)
struct intel_mid_dma_chan *midch = &dma->ch[i]; struct intel_mid_dma_chan *midch = &dma->ch[i];
midch->chan.device = &dma->common; midch->chan.device = &dma->common;
midch->chan.cookie = 1; dma_cookie_init(&midch->chan);
midch->ch_id = dma->chan_base + i; midch->ch_id = dma->chan_base + i;
pr_debug("MDMA:Init CH %d, ID %d\n", i, midch->ch_id); pr_debug("MDMA:Init CH %d, ID %d\n", i, midch->ch_id);
......
...@@ -1504,8 +1504,7 @@ static int idmac_alloc_chan_resources(struct dma_chan *chan) ...@@ -1504,8 +1504,7 @@ static int idmac_alloc_chan_resources(struct dma_chan *chan)
BUG_ON(chan->client_count > 1); BUG_ON(chan->client_count > 1);
WARN_ON(ichan->status != IPU_CHANNEL_FREE); WARN_ON(ichan->status != IPU_CHANNEL_FREE);
chan->cookie = 1; dma_cookie_init(chan);
chan->completed_cookie = -ENXIO;
ret = ipu_irq_map(chan->chan_id); ret = ipu_irq_map(chan->chan_id);
if (ret < 0) if (ret < 0)
...@@ -1633,8 +1632,7 @@ static int __init ipu_idmac_init(struct ipu *ipu) ...@@ -1633,8 +1632,7 @@ static int __init ipu_idmac_init(struct ipu *ipu)
snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i); snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i);
dma_chan->device = &idmac->dma; dma_chan->device = &idmac->dma;
dma_chan->cookie = 1; dma_cookie_init(dma_chan);
dma_chan->completed_cookie = -ENXIO;
dma_chan->chan_id = i; dma_chan->chan_id = i;
list_add_tail(&dma_chan->device_node, &dma->channels); list_add_tail(&dma_chan->device_node, &dma->channels);
} }
......
...@@ -733,8 +733,7 @@ static int __devinit mpc_dma_probe(struct platform_device *op) ...@@ -733,8 +733,7 @@ static int __devinit mpc_dma_probe(struct platform_device *op)
mchan = &mdma->channels[i]; mchan = &mdma->channels[i];
mchan->chan.device = dma; mchan->chan.device = dma;
mchan->chan.cookie = 1; dma_cookie_init(&mchan->chan);
mchan->chan.completed_cookie = mchan->chan.cookie;
INIT_LIST_HEAD(&mchan->free); INIT_LIST_HEAD(&mchan->free);
INIT_LIST_HEAD(&mchan->prepared); INIT_LIST_HEAD(&mchan->prepared);
......
...@@ -531,7 +531,7 @@ static int pd_alloc_chan_resources(struct dma_chan *chan) ...@@ -531,7 +531,7 @@ static int pd_alloc_chan_resources(struct dma_chan *chan)
spin_lock_irq(&pd_chan->lock); spin_lock_irq(&pd_chan->lock);
list_splice(&tmp_list, &pd_chan->free_list); list_splice(&tmp_list, &pd_chan->free_list);
pd_chan->descs_allocated = i; pd_chan->descs_allocated = i;
chan->completed_cookie = chan->cookie = 1; dma_cookie_init(chan);
spin_unlock_irq(&pd_chan->lock); spin_unlock_irq(&pd_chan->lock);
pdc_enable_irq(chan, 1); pdc_enable_irq(chan, 1);
...@@ -912,7 +912,7 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev, ...@@ -912,7 +912,7 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev,
struct pch_dma_chan *pd_chan = &pd->channels[i]; struct pch_dma_chan *pd_chan = &pd->channels[i];
pd_chan->chan.device = &pd->dma; pd_chan->chan.device = &pd->dma;
pd_chan->chan.cookie = 1; dma_cookie_init(&pd_chan->chan);
pd_chan->membase = &regs->desc[i]; pd_chan->membase = &regs->desc[i];
......
...@@ -304,7 +304,7 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan) ...@@ -304,7 +304,7 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan)
spin_lock_irqsave(&pch->lock, flags); spin_lock_irqsave(&pch->lock, flags);
chan->completed_cookie = chan->cookie = 1; dma_cookie_init(chan);
pch->cyclic = false; pch->cyclic = false;
pch->pl330_chid = pl330_request_channel(&pdmac->pif); pch->pl330_chid = pl330_request_channel(&pdmac->pif);
......
...@@ -625,8 +625,7 @@ static int __devinit sirfsoc_dma_probe(struct platform_device *op) ...@@ -625,8 +625,7 @@ static int __devinit sirfsoc_dma_probe(struct platform_device *op)
schan = &sdma->channels[i]; schan = &sdma->channels[i];
schan->chan.device = dma; schan->chan.device = dma;
schan->chan.cookie = 1; dma_cookie_init(&schan->chan);
schan->chan.completed_cookie = schan->chan.cookie;
INIT_LIST_HEAD(&schan->free); INIT_LIST_HEAD(&schan->free);
INIT_LIST_HEAD(&schan->prepared); INIT_LIST_HEAD(&schan->prepared);
......
...@@ -2172,7 +2172,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) ...@@ -2172,7 +2172,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
bool is_free_phy; bool is_free_phy;
spin_lock_irqsave(&d40c->lock, flags); 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 no dma configuration is set use default configuration (memcpy) */
if (!d40c->configured) { if (!d40c->configured) {
......
...@@ -477,8 +477,7 @@ static int td_alloc_chan_resources(struct dma_chan *chan) ...@@ -477,8 +477,7 @@ static int td_alloc_chan_resources(struct dma_chan *chan)
} }
spin_lock_bh(&td_chan->lock); spin_lock_bh(&td_chan->lock);
chan->completed_cookie = 1; dma_cookie_init(chan);
chan->cookie = 1;
spin_unlock_bh(&td_chan->lock); spin_unlock_bh(&td_chan->lock);
return 0; return 0;
...@@ -755,7 +754,7 @@ static int __devinit td_probe(struct platform_device *pdev) ...@@ -755,7 +754,7 @@ static int __devinit td_probe(struct platform_device *pdev)
} }
td_chan->chan.device = &td->dma; td_chan->chan.device = &td->dma;
td_chan->chan.cookie = 1; dma_cookie_init(&td_chan->chan);
spin_lock_init(&td_chan->lock); spin_lock_init(&td_chan->lock);
INIT_LIST_HEAD(&td_chan->active_list); INIT_LIST_HEAD(&td_chan->active_list);
INIT_LIST_HEAD(&td_chan->queue); INIT_LIST_HEAD(&td_chan->queue);
......
...@@ -1034,7 +1034,7 @@ static int txx9dmac_alloc_chan_resources(struct dma_chan *chan) ...@@ -1034,7 +1034,7 @@ static int txx9dmac_alloc_chan_resources(struct dma_chan *chan)
return -EIO; return -EIO;
} }
chan->completed_cookie = chan->cookie = 1; dma_cookie_init(chan);
dc->ccr = TXX9_DMA_CCR_IMMCHN | TXX9_DMA_CCR_INTENE | CCR_LE; dc->ccr = TXX9_DMA_CCR_IMMCHN | TXX9_DMA_CCR_INTENE | CCR_LE;
txx9dmac_chan_set_SMPCHN(dc); txx9dmac_chan_set_SMPCHN(dc);
...@@ -1163,7 +1163,7 @@ static int __init txx9dmac_chan_probe(struct platform_device *pdev) ...@@ -1163,7 +1163,7 @@ static int __init txx9dmac_chan_probe(struct platform_device *pdev)
dc->ddev->chan[ch] = dc; dc->ddev->chan[ch] = dc;
dc->chan.device = &dc->dma; dc->chan.device = &dc->dma;
list_add_tail(&dc->chan.device_node, &dc->chan.device->channels); list_add_tail(&dc->chan.device_node, &dc->chan.device->channels);
dc->chan.cookie = dc->chan.completed_cookie = 1; dma_cookie_init(&dc->chan);
if (is_dmac64(dc)) if (is_dmac64(dc))
dc->ch_regs = &__txx9dmac_regs(dc->ddev)->CHAN[ch]; dc->ch_regs = &__txx9dmac_regs(dc->ddev)->CHAN[ch];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment