Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d4e58de authored by Russell King - ARM Linux's avatar Russell King - ARM Linux Committed by Vinod Koul
Browse files

dmaengine: move last completed cookie into generic dma_chan structure



Every DMA engine implementation declares a last completed dma cookie
in their private dma channel structures.  This is pointless, and
forces driver specific code.  Move this out into the common dma_chan
structure.

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 08714f60
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ struct iop_adma_device {
/**
 * struct iop_adma_chan - internal representation of an ADMA device
 * @pending: allows batching of hardware operations
 * @completed_cookie: identifier for the most recently completed operation
 * @lock: serializes enqueue/dequeue operations to the slot pool
 * @mmr_base: memory mapped register base
 * @chain: device chain view of the descriptors
@@ -62,7 +61,6 @@ struct iop_adma_device {
 */
struct iop_adma_chan {
	int pending;
	dma_cookie_t completed_cookie;
	spinlock_t lock; /* protects the descriptor slot pool */
	void __iomem *mmr_base;
	struct list_head chain;
+4 −4
Original line number Diff line number Diff line
@@ -971,7 +971,7 @@ static enum dma_status pl08x_dma_tx_status(struct dma_chan *chan,
	u32 bytesleft = 0;

	last_used = plchan->chan.cookie;
	last_complete = plchan->lc;
	last_complete = plchan->chan.completed_cookie;

	ret = dma_async_is_complete(cookie, last_complete, last_used);
	if (ret == DMA_SUCCESS) {
@@ -983,7 +983,7 @@ static enum dma_status pl08x_dma_tx_status(struct dma_chan *chan,
	 * This cookie not complete yet
	 */
	last_used = plchan->chan.cookie;
	last_complete = plchan->lc;
	last_complete = plchan->chan.completed_cookie;

	/* Get number of bytes left in the active transactions and queue */
	bytesleft = pl08x_getbytes_chan(plchan);
@@ -1543,7 +1543,7 @@ static void pl08x_tasklet(unsigned long data)

	if (txd) {
		/* Update last completed */
		plchan->lc = txd->tx.cookie;
		plchan->chan.completed_cookie = txd->tx.cookie;
	}

	/* If a new descriptor is queued, set it up plchan->at is NULL here */
@@ -1725,7 +1725,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x,

		chan->chan.device = dmadev;
		chan->chan.cookie = 0;
		chan->lc = 0;
		chan->chan.completed_cookie = 0;

		spin_lock_init(&chan->lock);
		INIT_LIST_HEAD(&chan->pend_list);
+5 −5
Original line number Diff line number Diff line
@@ -269,7 +269,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc)
	dev_vdbg(chan2dev(&atchan->chan_common),
		"descriptor %u complete\n", txd->cookie);

	atchan->completed_cookie = txd->cookie;
	atchan->chan_common.completed_cookie = txd->cookie;

	/* move children to free_list */
	list_splice_init(&desc->tx_list, &atchan->free_list);
@@ -1016,14 +1016,14 @@ atc_tx_status(struct dma_chan *chan,

	spin_lock_irqsave(&atchan->lock, flags);

	last_complete = atchan->completed_cookie;
	last_complete = chan->completed_cookie;
	last_used = chan->cookie;

	ret = dma_async_is_complete(cookie, last_complete, last_used);
	if (ret != DMA_SUCCESS) {
		atc_cleanup_descriptors(atchan);

		last_complete = atchan->completed_cookie;
		last_complete = chan->completed_cookie;
		last_used = chan->cookie;

		ret = dma_async_is_complete(cookie, last_complete, last_used);
@@ -1129,7 +1129,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan)
	spin_lock_irqsave(&atchan->lock, flags);
	atchan->descs_allocated = i;
	list_splice(&tmp_list, &atchan->free_list);
	atchan->completed_cookie = chan->cookie = 1;
	chan->completed_cookie = chan->cookie = 1;
	spin_unlock_irqrestore(&atchan->lock, flags);

	/* channel parameters */
@@ -1329,7 +1329,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
		struct at_dma_chan	*atchan = &atdma->chan[i];

		atchan->chan_common.device = &atdma->dma_common;
		atchan->chan_common.cookie = atchan->completed_cookie = 1;
		atchan->chan_common.cookie = atchan->chan_common.completed_cookie = 1;
		list_add_tail(&atchan->chan_common.device_node,
				&atdma->dma_common.channels);

+0 −2
Original line number Diff line number Diff line
@@ -208,7 +208,6 @@ enum atc_status {
 * @save_dscr: for cyclic operations, preserve next descriptor address in
 *             the cyclic list on suspend/resume cycle
 * @lock: serializes enqueue/dequeue operations to descriptors lists
 * @completed_cookie: identifier for the most recently completed operation
 * @active_list: list of descriptors dmaengine is being running on
 * @queue: list of descriptors ready to be submitted to engine
 * @free_list: list of descriptors usable by the channel
@@ -227,7 +226,6 @@ struct at_dma_chan {
	spinlock_t		lock;

	/* these other elements are all protected by lock */
	dma_cookie_t		completed_cookie;
	struct list_head	active_list;
	struct list_head	queue;
	struct list_head	free_list;
+3 −4
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ struct coh901318_base {
struct coh901318_chan {
	spinlock_t lock;
	int allocated;
	int completed;
	int id;
	int stopped;

@@ -705,7 +704,7 @@ static void dma_tasklet(unsigned long data)
	callback_param = cohd_fin->desc.callback_param;

	/* sign this job as completed on the channel */
	cohc->completed = cohd_fin->desc.cookie;
	cohc->chan.completed_cookie = cohd_fin->desc.cookie;

	/* release the lli allocation and remove the descriptor */
	coh901318_lli_free(&cohc->base->pool, &cohd_fin->lli);
@@ -929,7 +928,7 @@ static int coh901318_alloc_chan_resources(struct dma_chan *chan)
	coh901318_config(cohc, NULL);

	cohc->allocated = 1;
	cohc->completed = chan->cookie = 1;
	chan->completed_cookie = chan->cookie = 1;

	spin_unlock_irqrestore(&cohc->lock, flags);

@@ -1169,7 +1168,7 @@ coh901318_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
	dma_cookie_t last_complete;
	int ret;

	last_complete = cohc->completed;
	last_complete = chan->completed_cookie;
	last_used = chan->cookie;

	ret = dma_async_is_complete(cookie, last_complete, last_used);
Loading