dmaengine: consolidate assignment of DMA cookies
Everyone deals with assigning DMA cookies in the same way (it's part of the API so they should be), so lets consolidate the common code into a helper function to avoid this duplication. 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>
This commit is contained in:
parent
d2ebfb335b
commit
884485e1f1
|
@ -921,13 +921,10 @@ static dma_cookie_t pl08x_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
struct pl08x_dma_chan *plchan = to_pl08x_chan(tx->chan);
|
struct pl08x_dma_chan *plchan = to_pl08x_chan(tx->chan);
|
||||||
struct pl08x_txd *txd = to_pl08x_txd(tx);
|
struct pl08x_txd *txd = to_pl08x_txd(tx);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
spin_lock_irqsave(&plchan->lock, flags);
|
spin_lock_irqsave(&plchan->lock, flags);
|
||||||
|
cookie = dma_cookie_assign(tx);
|
||||||
plchan->chan.cookie += 1;
|
|
||||||
if (plchan->chan.cookie < 0)
|
|
||||||
plchan->chan.cookie = 1;
|
|
||||||
tx->cookie = plchan->chan.cookie;
|
|
||||||
|
|
||||||
/* Put this onto the pending list */
|
/* Put this onto the pending list */
|
||||||
list_add_tail(&txd->node, &plchan->pend_list);
|
list_add_tail(&txd->node, &plchan->pend_list);
|
||||||
|
@ -947,7 +944,7 @@ static dma_cookie_t pl08x_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
|
|
||||||
spin_unlock_irqrestore(&plchan->lock, flags);
|
spin_unlock_irqrestore(&plchan->lock, flags);
|
||||||
|
|
||||||
return tx->cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dma_async_tx_descriptor *pl08x_prep_dma_interrupt(
|
static struct dma_async_tx_descriptor *pl08x_prep_dma_interrupt(
|
||||||
|
|
|
@ -192,27 +192,6 @@ static void atc_desc_chain(struct at_desc **first, struct at_desc **prev,
|
||||||
*prev = desc;
|
*prev = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* atc_assign_cookie - compute and assign new cookie
|
|
||||||
* @atchan: channel we work on
|
|
||||||
* @desc: descriptor to assign cookie for
|
|
||||||
*
|
|
||||||
* Called with atchan->lock held and bh disabled
|
|
||||||
*/
|
|
||||||
static dma_cookie_t
|
|
||||||
atc_assign_cookie(struct at_dma_chan *atchan, struct at_desc *desc)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = atchan->chan_common.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
atchan->chan_common.cookie = cookie;
|
|
||||||
desc->txd.cookie = cookie;
|
|
||||||
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* atc_dostart - starts the DMA engine for real
|
* atc_dostart - starts the DMA engine for real
|
||||||
* @atchan: the channel we want to start
|
* @atchan: the channel we want to start
|
||||||
|
@ -548,7 +527,7 @@ static dma_cookie_t atc_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&atchan->lock, flags);
|
spin_lock_irqsave(&atchan->lock, flags);
|
||||||
cookie = atc_assign_cookie(atchan, desc);
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
if (list_empty(&atchan->active_list)) {
|
if (list_empty(&atchan->active_list)) {
|
||||||
dev_vdbg(chan2dev(tx->chan), "tx_submit: started %u\n",
|
dev_vdbg(chan2dev(tx->chan), "tx_submit: started %u\n",
|
||||||
|
|
|
@ -318,20 +318,6 @@ static int coh901318_prep_linked_list(struct coh901318_chan *cohc,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static dma_cookie_t
|
|
||||||
coh901318_assign_cookie(struct coh901318_chan *cohc,
|
|
||||||
struct coh901318_desc *cohd)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = cohc->chan.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
cohc->chan.cookie = cookie;
|
|
||||||
cohd->desc.cookie = cookie;
|
|
||||||
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct coh901318_desc *
|
static struct coh901318_desc *
|
||||||
coh901318_desc_get(struct coh901318_chan *cohc)
|
coh901318_desc_get(struct coh901318_chan *cohc)
|
||||||
|
@ -966,16 +952,16 @@ coh901318_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
desc);
|
desc);
|
||||||
struct coh901318_chan *cohc = to_coh901318_chan(tx->chan);
|
struct coh901318_chan *cohc = to_coh901318_chan(tx->chan);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
spin_lock_irqsave(&cohc->lock, flags);
|
spin_lock_irqsave(&cohc->lock, flags);
|
||||||
|
cookie = dma_cookie_assign(tx);
|
||||||
tx->cookie = coh901318_assign_cookie(cohc, cohd);
|
|
||||||
|
|
||||||
coh901318_desc_queue(cohc, cohd);
|
coh901318_desc_queue(cohc, cohd);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&cohc->lock, flags);
|
spin_unlock_irqrestore(&cohc->lock, flags);
|
||||||
|
|
||||||
return tx->cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dma_async_tx_descriptor *
|
static struct dma_async_tx_descriptor *
|
||||||
|
|
|
@ -7,4 +7,24 @@
|
||||||
|
|
||||||
#include <linux/dmaengine.h>
|
#include <linux/dmaengine.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dma_cookie_assign - assign a DMA engine cookie to the descriptor
|
||||||
|
* @tx: descriptor needing cookie
|
||||||
|
*
|
||||||
|
* Assign a unique non-zero per-channel cookie to the descriptor.
|
||||||
|
* Note: caller is expected to hold a lock to prevent concurrency.
|
||||||
|
*/
|
||||||
|
static inline dma_cookie_t dma_cookie_assign(struct dma_async_tx_descriptor *tx)
|
||||||
|
{
|
||||||
|
struct dma_chan *chan = tx->chan;
|
||||||
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
|
cookie = chan->cookie + 1;
|
||||||
|
if (cookie < DMA_MIN_COOKIE)
|
||||||
|
cookie = DMA_MIN_COOKIE;
|
||||||
|
tx->cookie = chan->cookie = cookie;
|
||||||
|
|
||||||
|
return cookie;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -157,21 +157,6 @@ static void dwc_desc_put(struct dw_dma_chan *dwc, struct dw_desc *desc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called with dwc->lock held and bh disabled */
|
|
||||||
static dma_cookie_t
|
|
||||||
dwc_assign_cookie(struct dw_dma_chan *dwc, struct dw_desc *desc)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = dwc->chan.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
dwc->chan.cookie = cookie;
|
|
||||||
desc->txd.cookie = cookie;
|
|
||||||
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dwc_initialize(struct dw_dma_chan *dwc)
|
static void dwc_initialize(struct dw_dma_chan *dwc)
|
||||||
{
|
{
|
||||||
struct dw_dma *dw = to_dw_dma(dwc->chan.device);
|
struct dw_dma *dw = to_dw_dma(dwc->chan.device);
|
||||||
|
@ -603,7 +588,7 @@ static dma_cookie_t dwc_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&dwc->lock, flags);
|
spin_lock_irqsave(&dwc->lock, flags);
|
||||||
cookie = dwc_assign_cookie(dwc, desc);
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* REVISIT: We should attempt to chain as many descriptors as
|
* REVISIT: We should attempt to chain as many descriptors as
|
||||||
|
|
|
@ -783,17 +783,10 @@ static dma_cookie_t ep93xx_dma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&edmac->lock, flags);
|
spin_lock_irqsave(&edmac->lock, flags);
|
||||||
|
cookie = dma_cookie_assign(tx);
|
||||||
cookie = edmac->chan.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
desc = container_of(tx, struct ep93xx_dma_desc, txd);
|
desc = container_of(tx, struct ep93xx_dma_desc, txd);
|
||||||
|
|
||||||
edmac->chan.cookie = cookie;
|
|
||||||
desc->txd.cookie = cookie;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If nothing is currently prosessed, we push this descriptor
|
* If nothing is currently prosessed, we push this descriptor
|
||||||
* directly to the hardware. Otherwise we put the descriptor
|
* directly to the hardware. Otherwise we put the descriptor
|
||||||
|
|
|
@ -414,17 +414,10 @@ static dma_cookie_t fsl_dma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
* assign cookies to all of the software descriptors
|
* assign cookies to all of the software descriptors
|
||||||
* that make up this transaction
|
* that make up this transaction
|
||||||
*/
|
*/
|
||||||
cookie = chan->common.cookie;
|
|
||||||
list_for_each_entry(child, &desc->tx_list, node) {
|
list_for_each_entry(child, &desc->tx_list, node) {
|
||||||
cookie++;
|
cookie = dma_cookie_assign(&child->async_tx);
|
||||||
if (cookie < DMA_MIN_COOKIE)
|
|
||||||
cookie = DMA_MIN_COOKIE;
|
|
||||||
|
|
||||||
child->async_tx.cookie = cookie;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chan->common.cookie = cookie;
|
|
||||||
|
|
||||||
/* put this transaction onto the tail of the pending queue */
|
/* put this transaction onto the tail of the pending queue */
|
||||||
append_ld_queue(chan, desc);
|
append_ld_queue(chan, desc);
|
||||||
|
|
||||||
|
|
|
@ -165,19 +165,6 @@ static enum dma_status imxdma_tx_status(struct dma_chan *chan,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dma_cookie_t imxdma_assign_cookie(struct imxdma_channel *imxdma)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = imxdma->chan.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
imxdma->chan.cookie = cookie;
|
|
||||||
imxdma->desc.cookie = cookie;
|
|
||||||
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
static dma_cookie_t imxdma_tx_submit(struct dma_async_tx_descriptor *tx)
|
static dma_cookie_t imxdma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
{
|
{
|
||||||
struct imxdma_channel *imxdmac = to_imxdma_chan(tx->chan);
|
struct imxdma_channel *imxdmac = to_imxdma_chan(tx->chan);
|
||||||
|
@ -185,7 +172,7 @@ static dma_cookie_t imxdma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
|
|
||||||
spin_lock_irq(&imxdmac->lock);
|
spin_lock_irq(&imxdmac->lock);
|
||||||
|
|
||||||
cookie = imxdma_assign_cookie(imxdmac);
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
spin_unlock_irq(&imxdmac->lock);
|
spin_unlock_irq(&imxdmac->lock);
|
||||||
|
|
||||||
|
|
|
@ -815,19 +815,6 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dma_cookie_t sdma_assign_cookie(struct sdma_channel *sdmac)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = sdmac->chan.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
sdmac->chan.cookie = cookie;
|
|
||||||
sdmac->desc.cookie = cookie;
|
|
||||||
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct sdma_channel *to_sdma_chan(struct dma_chan *chan)
|
static struct sdma_channel *to_sdma_chan(struct dma_chan *chan)
|
||||||
{
|
{
|
||||||
return container_of(chan, struct sdma_channel, chan);
|
return container_of(chan, struct sdma_channel, chan);
|
||||||
|
@ -841,7 +828,7 @@ static dma_cookie_t sdma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
|
|
||||||
spin_lock_irqsave(&sdmac->lock, flags);
|
spin_lock_irqsave(&sdmac->lock, flags);
|
||||||
|
|
||||||
cookie = sdma_assign_cookie(sdmac);
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&sdmac->lock, flags);
|
spin_unlock_irqrestore(&sdmac->lock, flags);
|
||||||
|
|
||||||
|
@ -1140,7 +1127,6 @@ static void sdma_issue_pending(struct dma_chan *chan)
|
||||||
struct sdma_engine *sdma = sdmac->sdma;
|
struct sdma_engine *sdma = sdmac->sdma;
|
||||||
|
|
||||||
if (sdmac->status == DMA_IN_PROGRESS)
|
if (sdmac->status == DMA_IN_PROGRESS)
|
||||||
sdma_enable_channel(sdma, sdmac->channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1 34
|
#define SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1 34
|
||||||
|
|
|
@ -436,14 +436,7 @@ static dma_cookie_t intel_mid_dma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
dma_cookie_t cookie;
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
spin_lock_bh(&midc->lock);
|
spin_lock_bh(&midc->lock);
|
||||||
cookie = midc->chan.cookie;
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
midc->chan.cookie = cookie;
|
|
||||||
desc->txd.cookie = cookie;
|
|
||||||
|
|
||||||
|
|
||||||
if (list_empty(&midc->active_list))
|
if (list_empty(&midc->active_list))
|
||||||
list_add_tail(&desc->desc_node, &midc->active_list);
|
list_add_tail(&desc->desc_node, &midc->active_list);
|
||||||
|
|
|
@ -237,12 +237,7 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
|
|
||||||
spin_lock_bh(&ioat->desc_lock);
|
spin_lock_bh(&ioat->desc_lock);
|
||||||
/* cookie incr and addition to used_list must be atomic */
|
/* cookie incr and addition to used_list must be atomic */
|
||||||
cookie = c->cookie;
|
cookie = dma_cookie_assign(tx);
|
||||||
cookie++;
|
|
||||||
if (cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
c->cookie = cookie;
|
|
||||||
tx->cookie = cookie;
|
|
||||||
dev_dbg(to_dev(&ioat->base), "%s: cookie: %d\n", __func__, cookie);
|
dev_dbg(to_dev(&ioat->base), "%s: cookie: %d\n", __func__, cookie);
|
||||||
|
|
||||||
/* write address into NextDescriptor field of last desc in chain */
|
/* write address into NextDescriptor field of last desc in chain */
|
||||||
|
|
|
@ -400,13 +400,9 @@ static dma_cookie_t ioat2_tx_submit_unlock(struct dma_async_tx_descriptor *tx)
|
||||||
struct dma_chan *c = tx->chan;
|
struct dma_chan *c = tx->chan;
|
||||||
struct ioat2_dma_chan *ioat = to_ioat2_chan(c);
|
struct ioat2_dma_chan *ioat = to_ioat2_chan(c);
|
||||||
struct ioat_chan_common *chan = &ioat->base;
|
struct ioat_chan_common *chan = &ioat->base;
|
||||||
dma_cookie_t cookie = c->cookie;
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
cookie++;
|
cookie = dma_cookie_assign(tx);
|
||||||
if (cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
tx->cookie = cookie;
|
|
||||||
c->cookie = cookie;
|
|
||||||
dev_dbg(to_dev(&ioat->base), "%s: cookie: %d\n", __func__, cookie);
|
dev_dbg(to_dev(&ioat->base), "%s: cookie: %d\n", __func__, cookie);
|
||||||
|
|
||||||
if (!test_and_set_bit(IOAT_COMPLETION_PENDING, &chan->state))
|
if (!test_and_set_bit(IOAT_COMPLETION_PENDING, &chan->state))
|
||||||
|
|
|
@ -440,18 +440,6 @@ retry:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dma_cookie_t
|
|
||||||
iop_desc_assign_cookie(struct iop_adma_chan *iop_chan,
|
|
||||||
struct iop_adma_desc_slot *desc)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = iop_chan->common.cookie;
|
|
||||||
cookie++;
|
|
||||||
if (cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
iop_chan->common.cookie = desc->async_tx.cookie = cookie;
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void iop_adma_check_threshold(struct iop_adma_chan *iop_chan)
|
static void iop_adma_check_threshold(struct iop_adma_chan *iop_chan)
|
||||||
{
|
{
|
||||||
dev_dbg(iop_chan->device->common.dev, "pending: %d\n",
|
dev_dbg(iop_chan->device->common.dev, "pending: %d\n",
|
||||||
|
@ -479,7 +467,7 @@ iop_adma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
slots_per_op = grp_start->slots_per_op;
|
slots_per_op = grp_start->slots_per_op;
|
||||||
|
|
||||||
spin_lock_bh(&iop_chan->lock);
|
spin_lock_bh(&iop_chan->lock);
|
||||||
cookie = iop_desc_assign_cookie(iop_chan, sw_desc);
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
old_chain_tail = list_entry(iop_chan->chain.prev,
|
old_chain_tail = list_entry(iop_chan->chain.prev,
|
||||||
struct iop_adma_desc_slot, chain_node);
|
struct iop_adma_desc_slot, chain_node);
|
||||||
|
|
|
@ -867,14 +867,7 @@ static dma_cookie_t idmac_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
|
|
||||||
dev_dbg(dev, "Submitting sg %p\n", &desc->sg[0]);
|
dev_dbg(dev, "Submitting sg %p\n", &desc->sg[0]);
|
||||||
|
|
||||||
cookie = ichan->dma_chan.cookie;
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
/* from dmaengine.h: "last cookie value returned to client" */
|
|
||||||
ichan->dma_chan.cookie = cookie;
|
|
||||||
tx->cookie = cookie;
|
|
||||||
|
|
||||||
/* ipu->lock can be taken under ichan->lock, but not v.v. */
|
/* ipu->lock can be taken under ichan->lock, but not v.v. */
|
||||||
spin_lock_irqsave(&ichan->lock, flags);
|
spin_lock_irqsave(&ichan->lock, flags);
|
||||||
|
|
|
@ -439,13 +439,7 @@ static dma_cookie_t mpc_dma_tx_submit(struct dma_async_tx_descriptor *txd)
|
||||||
mpc_dma_execute(mchan);
|
mpc_dma_execute(mchan);
|
||||||
|
|
||||||
/* Update cookie */
|
/* Update cookie */
|
||||||
cookie = mchan->chan.cookie + 1;
|
cookie = dma_cookie_assign(txd);
|
||||||
if (cookie <= 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
mchan->chan.cookie = cookie;
|
|
||||||
mdesc->desc.cookie = cookie;
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&mchan->lock, flags);
|
spin_unlock_irqrestore(&mchan->lock, flags);
|
||||||
|
|
||||||
return cookie;
|
return cookie;
|
||||||
|
|
|
@ -536,18 +536,6 @@ retry:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dma_cookie_t
|
|
||||||
mv_desc_assign_cookie(struct mv_xor_chan *mv_chan,
|
|
||||||
struct mv_xor_desc_slot *desc)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = mv_chan->common.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
mv_chan->common.cookie = desc->async_tx.cookie = cookie;
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************ DMA engine API functions ****************************/
|
/************************ DMA engine API functions ****************************/
|
||||||
static dma_cookie_t
|
static dma_cookie_t
|
||||||
mv_xor_tx_submit(struct dma_async_tx_descriptor *tx)
|
mv_xor_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
|
@ -565,7 +553,7 @@ mv_xor_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
grp_start = sw_desc->group_head;
|
grp_start = sw_desc->group_head;
|
||||||
|
|
||||||
spin_lock_bh(&mv_chan->lock);
|
spin_lock_bh(&mv_chan->lock);
|
||||||
cookie = mv_desc_assign_cookie(mv_chan, sw_desc);
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
if (list_empty(&mv_chan->chain))
|
if (list_empty(&mv_chan->chain))
|
||||||
list_splice_init(&sw_desc->tx_list, &mv_chan->chain);
|
list_splice_init(&sw_desc->tx_list, &mv_chan->chain);
|
||||||
|
|
|
@ -194,19 +194,6 @@ static void mxs_dma_resume_chan(struct mxs_dma_chan *mxs_chan)
|
||||||
mxs_chan->status = DMA_IN_PROGRESS;
|
mxs_chan->status = DMA_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dma_cookie_t mxs_dma_assign_cookie(struct mxs_dma_chan *mxs_chan)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = mxs_chan->chan.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
mxs_chan->chan.cookie = cookie;
|
|
||||||
mxs_chan->desc.cookie = cookie;
|
|
||||||
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
|
static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
|
||||||
{
|
{
|
||||||
return container_of(chan, struct mxs_dma_chan, chan);
|
return container_of(chan, struct mxs_dma_chan, chan);
|
||||||
|
@ -218,7 +205,7 @@ static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
|
|
||||||
mxs_dma_enable_chan(mxs_chan);
|
mxs_dma_enable_chan(mxs_chan);
|
||||||
|
|
||||||
return mxs_dma_assign_cookie(mxs_chan);
|
return dma_cookie_assign(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mxs_dma_tasklet(unsigned long data)
|
static void mxs_dma_tasklet(unsigned long data)
|
||||||
|
|
|
@ -417,20 +417,6 @@ static void pdc_advance_work(struct pch_dma_chan *pd_chan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static dma_cookie_t pdc_assign_cookie(struct pch_dma_chan *pd_chan,
|
|
||||||
struct pch_dma_desc *desc)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = pd_chan->chan.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
pd_chan->chan.cookie = cookie;
|
|
||||||
desc->txd.cookie = cookie;
|
|
||||||
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
static dma_cookie_t pd_tx_submit(struct dma_async_tx_descriptor *txd)
|
static dma_cookie_t pd_tx_submit(struct dma_async_tx_descriptor *txd)
|
||||||
{
|
{
|
||||||
struct pch_dma_desc *desc = to_pd_desc(txd);
|
struct pch_dma_desc *desc = to_pd_desc(txd);
|
||||||
|
@ -438,7 +424,7 @@ static dma_cookie_t pd_tx_submit(struct dma_async_tx_descriptor *txd)
|
||||||
dma_cookie_t cookie;
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
spin_lock(&pd_chan->lock);
|
spin_lock(&pd_chan->lock);
|
||||||
cookie = pdc_assign_cookie(pd_chan, desc);
|
cookie = dma_cookie_assign(txd);
|
||||||
|
|
||||||
if (list_empty(&pd_chan->active_list)) {
|
if (list_empty(&pd_chan->active_list)) {
|
||||||
list_add_tail(&desc->desc_node, &pd_chan->active_list);
|
list_add_tail(&desc->desc_node, &pd_chan->active_list);
|
||||||
|
|
|
@ -429,26 +429,16 @@ static dma_cookie_t pl330_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
spin_lock_irqsave(&pch->lock, flags);
|
spin_lock_irqsave(&pch->lock, flags);
|
||||||
|
|
||||||
/* Assign cookies to all nodes */
|
/* Assign cookies to all nodes */
|
||||||
cookie = tx->chan->cookie;
|
|
||||||
|
|
||||||
while (!list_empty(&last->node)) {
|
while (!list_empty(&last->node)) {
|
||||||
desc = list_entry(last->node.next, struct dma_pl330_desc, node);
|
desc = list_entry(last->node.next, struct dma_pl330_desc, node);
|
||||||
|
|
||||||
if (++cookie < 0)
|
dma_cookie_assign(&desc->txd);
|
||||||
cookie = 1;
|
|
||||||
desc->txd.cookie = cookie;
|
|
||||||
|
|
||||||
list_move_tail(&desc->node, &pch->work_list);
|
list_move_tail(&desc->node, &pch->work_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++cookie < 0)
|
cookie = dma_cookie_assign(&last->txd);
|
||||||
cookie = 1;
|
|
||||||
last->txd.cookie = cookie;
|
|
||||||
|
|
||||||
list_add_tail(&last->node, &pch->work_list);
|
list_add_tail(&last->node, &pch->work_list);
|
||||||
|
|
||||||
tx->chan->cookie = cookie;
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&pch->lock, flags);
|
spin_unlock_irqrestore(&pch->lock, flags);
|
||||||
|
|
||||||
return cookie;
|
return cookie;
|
||||||
|
|
|
@ -2150,22 +2150,6 @@ static int ppc440spe_adma_alloc_chan_resources(struct dma_chan *chan)
|
||||||
return (i > 0) ? i : -ENOMEM;
|
return (i > 0) ? i : -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ppc440spe_desc_assign_cookie - assign a cookie
|
|
||||||
*/
|
|
||||||
static dma_cookie_t ppc440spe_desc_assign_cookie(
|
|
||||||
struct ppc440spe_adma_chan *chan,
|
|
||||||
struct ppc440spe_adma_desc_slot *desc)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = chan->common.cookie;
|
|
||||||
|
|
||||||
cookie++;
|
|
||||||
if (cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
chan->common.cookie = desc->async_tx.cookie = cookie;
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ppc440spe_rxor_set_region_data -
|
* ppc440spe_rxor_set_region_data -
|
||||||
*/
|
*/
|
||||||
|
@ -2236,8 +2220,7 @@ static dma_cookie_t ppc440spe_adma_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
slots_per_op = group_start->slots_per_op;
|
slots_per_op = group_start->slots_per_op;
|
||||||
|
|
||||||
spin_lock_bh(&chan->lock);
|
spin_lock_bh(&chan->lock);
|
||||||
|
cookie = dma_cookie_assign(tx);
|
||||||
cookie = ppc440spe_desc_assign_cookie(chan, sw_desc);
|
|
||||||
|
|
||||||
if (unlikely(list_empty(&chan->chain))) {
|
if (unlikely(list_empty(&chan->chain))) {
|
||||||
/* first peer */
|
/* first peer */
|
||||||
|
|
|
@ -298,13 +298,7 @@ static dma_cookie_t sh_dmae_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
else
|
else
|
||||||
power_up = false;
|
power_up = false;
|
||||||
|
|
||||||
cookie = sh_chan->common.cookie;
|
cookie = dma_cookie_assign(tx);
|
||||||
cookie++;
|
|
||||||
if (cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
sh_chan->common.cookie = cookie;
|
|
||||||
tx->cookie = cookie;
|
|
||||||
|
|
||||||
/* Mark all chunks of this descriptor as submitted, move to the queue */
|
/* Mark all chunks of this descriptor as submitted, move to the queue */
|
||||||
list_for_each_entry_safe(chunk, c, desc->node.prev, node) {
|
list_for_each_entry_safe(chunk, c, desc->node.prev, node) {
|
||||||
|
|
|
@ -257,13 +257,7 @@ static dma_cookie_t sirfsoc_dma_tx_submit(struct dma_async_tx_descriptor *txd)
|
||||||
/* Move descriptor to queue */
|
/* Move descriptor to queue */
|
||||||
list_move_tail(&sdesc->node, &schan->queued);
|
list_move_tail(&sdesc->node, &schan->queued);
|
||||||
|
|
||||||
/* Update cookie */
|
cookie = dma_cookie_assign(txd);
|
||||||
cookie = schan->chan.cookie + 1;
|
|
||||||
if (cookie <= 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
schan->chan.cookie = cookie;
|
|
||||||
sdesc->desc.cookie = cookie;
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&schan->lock, flags);
|
spin_unlock_irqrestore(&schan->lock, flags);
|
||||||
|
|
||||||
|
|
|
@ -1220,21 +1220,14 @@ static dma_cookie_t d40_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
chan);
|
chan);
|
||||||
struct d40_desc *d40d = container_of(tx, struct d40_desc, txd);
|
struct d40_desc *d40d = container_of(tx, struct d40_desc, txd);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
spin_lock_irqsave(&d40c->lock, flags);
|
spin_lock_irqsave(&d40c->lock, flags);
|
||||||
|
cookie = dma_cookie_assign(tx);
|
||||||
d40c->chan.cookie++;
|
|
||||||
|
|
||||||
if (d40c->chan.cookie < 0)
|
|
||||||
d40c->chan.cookie = 1;
|
|
||||||
|
|
||||||
d40d->txd.cookie = d40c->chan.cookie;
|
|
||||||
|
|
||||||
d40_desc_queue(d40c, d40d);
|
d40_desc_queue(d40c, d40d);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&d40c->lock, flags);
|
spin_unlock_irqrestore(&d40c->lock, flags);
|
||||||
|
|
||||||
return tx->cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int d40_start(struct d40_chan *d40c)
|
static int d40_start(struct d40_chan *d40c)
|
||||||
|
|
|
@ -350,12 +350,7 @@ static dma_cookie_t td_tx_submit(struct dma_async_tx_descriptor *txd)
|
||||||
dma_cookie_t cookie;
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
spin_lock_bh(&td_chan->lock);
|
spin_lock_bh(&td_chan->lock);
|
||||||
|
cookie = dma_cookie_assign(txd);
|
||||||
cookie = txd->chan->cookie;
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
txd->chan->cookie = cookie;
|
|
||||||
txd->cookie = cookie;
|
|
||||||
|
|
||||||
if (list_empty(&td_chan->active_list)) {
|
if (list_empty(&td_chan->active_list)) {
|
||||||
dev_dbg(chan2dev(txd->chan), "%s: started %u\n", __func__,
|
dev_dbg(chan2dev(txd->chan), "%s: started %u\n", __func__,
|
||||||
|
|
|
@ -281,21 +281,6 @@ static void txx9dmac_desc_put(struct txx9dmac_chan *dc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called with dc->lock held and bh disabled */
|
|
||||||
static dma_cookie_t
|
|
||||||
txx9dmac_assign_cookie(struct txx9dmac_chan *dc, struct txx9dmac_desc *desc)
|
|
||||||
{
|
|
||||||
dma_cookie_t cookie = dc->chan.cookie;
|
|
||||||
|
|
||||||
if (++cookie < 0)
|
|
||||||
cookie = 1;
|
|
||||||
|
|
||||||
dc->chan.cookie = cookie;
|
|
||||||
desc->txd.cookie = cookie;
|
|
||||||
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void txx9dmac_dump_regs(struct txx9dmac_chan *dc)
|
static void txx9dmac_dump_regs(struct txx9dmac_chan *dc)
|
||||||
|
@ -740,7 +725,7 @@ static dma_cookie_t txx9dmac_tx_submit(struct dma_async_tx_descriptor *tx)
|
||||||
dma_cookie_t cookie;
|
dma_cookie_t cookie;
|
||||||
|
|
||||||
spin_lock_bh(&dc->lock);
|
spin_lock_bh(&dc->lock);
|
||||||
cookie = txx9dmac_assign_cookie(dc, desc);
|
cookie = dma_cookie_assign(tx);
|
||||||
|
|
||||||
dev_vdbg(chan2dev(tx->chan), "tx_submit: queued %u %p\n",
|
dev_vdbg(chan2dev(tx->chan), "tx_submit: queued %u %p\n",
|
||||||
desc->txd.cookie, desc);
|
desc->txd.cookie, desc);
|
||||||
|
|
Loading…
Reference in New Issue