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

Commit 07934481 authored by Linus Walleij's avatar Linus Walleij Committed by Dan Williams
Browse files

DMAENGINE: generic channel status v2



Convert the device_is_tx_complete() operation on the
DMA engine to a generic device_tx_status()operation which
can return three states, DMA_TX_RUNNING, DMA_TX_COMPLETE,
DMA_TX_PAUSED.

[dan.j.williams@intel.com: update for timberdale]
Signed-off-by: default avatarLinus Walleij <linus.walleij@stericsson.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Maciej Sosnowski <maciej.sosnowski@intel.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Li Yang <leoli@freescale.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Cc: Magnus Damm <damm@opensource.se>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Joe Perches <joe@perches.com>
Cc: Roland Dreier <rdreier@cisco.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent c3635c78
Loading
Loading
Loading
Loading
+0 −7
Original line number Original line Diff line number Diff line
@@ -102,13 +102,6 @@ struct coh901318_platform {
	const int max_channels;
	const int max_channels;
};
};


/**
 * coh901318_get_bytes_left() - Get number of bytes left on a current transfer
 * @chan: dma channel handle
 * return number of bytes left, or negative on error
 */
u32 coh901318_get_bytes_left(struct dma_chan *chan);

/**
/**
 * coh901318_filter_id() - DMA channel filter function
 * coh901318_filter_id() - DMA channel filter function
 * @chan: dma channel handle
 * @chan: dma channel handle
+15 −14
Original line number Original line Diff line number Diff line
@@ -798,29 +798,25 @@ static int atc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
}
}


/**
/**
 * atc_is_tx_complete - poll for transaction completion
 * atc_tx_status - poll for transaction completion
 * @chan: DMA channel
 * @chan: DMA channel
 * @cookie: transaction identifier to check status of
 * @cookie: transaction identifier to check status of
 * @done: if not %NULL, updated with last completed transaction
 * @txstate: if not %NULL updated with transaction state
 * @used: if not %NULL, updated with last used transaction
 *
 *
 * If @done and @used are passed in, upon return they reflect the driver
 * If @txstate is passed in, upon return it reflect the driver
 * internal state and can be used with dma_async_is_complete() to check
 * internal state and can be used with dma_async_is_complete() to check
 * the status of multiple cookies without re-checking hardware state.
 * the status of multiple cookies without re-checking hardware state.
 */
 */
static enum dma_status
static enum dma_status
atc_is_tx_complete(struct dma_chan *chan,
atc_tx_status(struct dma_chan *chan,
		dma_cookie_t cookie,
		dma_cookie_t cookie,
		dma_cookie_t *done, dma_cookie_t *used)
		struct dma_tx_state *txstate)
{
{
	struct at_dma_chan	*atchan = to_at_dma_chan(chan);
	struct at_dma_chan	*atchan = to_at_dma_chan(chan);
	dma_cookie_t		last_used;
	dma_cookie_t		last_used;
	dma_cookie_t		last_complete;
	dma_cookie_t		last_complete;
	enum dma_status		ret;
	enum dma_status		ret;


	dev_vdbg(chan2dev(chan), "is_tx_complete: %d (d%d, u%d)\n",
			cookie, done ? *done : 0, used ? *used : 0);

	spin_lock_bh(&atchan->lock);
	spin_lock_bh(&atchan->lock);


	last_complete = atchan->completed_cookie;
	last_complete = atchan->completed_cookie;
@@ -838,10 +834,15 @@ atc_is_tx_complete(struct dma_chan *chan,


	spin_unlock_bh(&atchan->lock);
	spin_unlock_bh(&atchan->lock);


	if (done)
	if (txstate) {
		*done = last_complete;
		txstate->last = last_complete;
	if (used)
		txstate->used = last_used;
		*used = last_used;
		txstate->residue = 0;
	}

	dev_vdbg(chan2dev(chan), "tx_status: %d (d%d, u%d)\n",
		 cookie, last_complete ? last_complete : 0,
		 last_used ? last_used : 0);


	return ret;
	return ret;
}
}
@@ -1087,7 +1088,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
	/* set base routines */
	/* set base routines */
	atdma->dma_common.device_alloc_chan_resources = atc_alloc_chan_resources;
	atdma->dma_common.device_alloc_chan_resources = atc_alloc_chan_resources;
	atdma->dma_common.device_free_chan_resources = atc_free_chan_resources;
	atdma->dma_common.device_free_chan_resources = atc_free_chan_resources;
	atdma->dma_common.device_is_tx_complete = atc_is_tx_complete;
	atdma->dma_common.device_tx_status = atc_tx_status;
	atdma->dma_common.device_issue_pending = atc_issue_pending;
	atdma->dma_common.device_issue_pending = atc_issue_pending;
	atdma->dma_common.dev = &pdev->dev;
	atdma->dma_common.dev = &pdev->dev;


+13 −12
Original line number Original line Diff line number Diff line
@@ -426,7 +426,7 @@ static inline u32 coh901318_get_bytes_in_lli(struct coh901318_lli *in_lli)
 * absolute measures, but for a rough guess you can still call
 * absolute measures, but for a rough guess you can still call
 * it.
 * it.
 */
 */
u32 coh901318_get_bytes_left(struct dma_chan *chan)
static u32 coh901318_get_bytes_left(struct dma_chan *chan)
{
{
	struct coh901318_chan *cohc = to_coh901318_chan(chan);
	struct coh901318_chan *cohc = to_coh901318_chan(chan);
	struct coh901318_desc *cohd;
	struct coh901318_desc *cohd;
@@ -503,8 +503,6 @@ u32 coh901318_get_bytes_left(struct dma_chan *chan)


	return left;
	return left;
}
}
EXPORT_SYMBOL(coh901318_get_bytes_left);



/*
/*
 * Pauses a transfer without losing data. Enables power save.
 * Pauses a transfer without losing data. Enables power save.
@@ -1136,9 +1134,8 @@ coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
}
}


static enum dma_status
static enum dma_status
coh901318_is_tx_complete(struct dma_chan *chan,
coh901318_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
			 dma_cookie_t cookie, dma_cookie_t *done,
		 struct dma_tx_state *txstate)
			 dma_cookie_t *used)
{
{
	struct coh901318_chan *cohc = to_coh901318_chan(chan);
	struct coh901318_chan *cohc = to_coh901318_chan(chan);
	dma_cookie_t last_used;
	dma_cookie_t last_used;
@@ -1150,10 +1147,14 @@ coh901318_is_tx_complete(struct dma_chan *chan,


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


	if (done)
	if (txstate) {
		*done = last_complete;
		txstate->last = last_complete;
	if (used)
		txstate->used = last_used;
		*used = last_used;
		txstate->residue = coh901318_get_bytes_left(chan);
	}

	if (ret == DMA_IN_PROGRESS && cohc->stopped)
		ret = DMA_PAUSED;


	return ret;
	return ret;
}
}
@@ -1356,7 +1357,7 @@ static int __init coh901318_probe(struct platform_device *pdev)
	base->dma_slave.device_alloc_chan_resources = coh901318_alloc_chan_resources;
	base->dma_slave.device_alloc_chan_resources = coh901318_alloc_chan_resources;
	base->dma_slave.device_free_chan_resources = coh901318_free_chan_resources;
	base->dma_slave.device_free_chan_resources = coh901318_free_chan_resources;
	base->dma_slave.device_prep_slave_sg = coh901318_prep_slave_sg;
	base->dma_slave.device_prep_slave_sg = coh901318_prep_slave_sg;
	base->dma_slave.device_is_tx_complete = coh901318_is_tx_complete;
	base->dma_slave.device_tx_status = coh901318_tx_status;
	base->dma_slave.device_issue_pending = coh901318_issue_pending;
	base->dma_slave.device_issue_pending = coh901318_issue_pending;
	base->dma_slave.device_control = coh901318_control;
	base->dma_slave.device_control = coh901318_control;
	base->dma_slave.dev = &pdev->dev;
	base->dma_slave.dev = &pdev->dev;
@@ -1376,7 +1377,7 @@ static int __init coh901318_probe(struct platform_device *pdev)
	base->dma_memcpy.device_alloc_chan_resources = coh901318_alloc_chan_resources;
	base->dma_memcpy.device_alloc_chan_resources = coh901318_alloc_chan_resources;
	base->dma_memcpy.device_free_chan_resources = coh901318_free_chan_resources;
	base->dma_memcpy.device_free_chan_resources = coh901318_free_chan_resources;
	base->dma_memcpy.device_prep_dma_memcpy = coh901318_prep_memcpy;
	base->dma_memcpy.device_prep_dma_memcpy = coh901318_prep_memcpy;
	base->dma_memcpy.device_is_tx_complete = coh901318_is_tx_complete;
	base->dma_memcpy.device_tx_status = coh901318_tx_status;
	base->dma_memcpy.device_issue_pending = coh901318_issue_pending;
	base->dma_memcpy.device_issue_pending = coh901318_issue_pending;
	base->dma_memcpy.device_control = coh901318_control;
	base->dma_memcpy.device_control = coh901318_control;
	base->dma_memcpy.dev = &pdev->dev;
	base->dma_memcpy.dev = &pdev->dev;
+1 −1
Original line number Original line Diff line number Diff line
@@ -698,7 +698,7 @@ int dma_async_device_register(struct dma_device *device)


	BUG_ON(!device->device_alloc_chan_resources);
	BUG_ON(!device->device_alloc_chan_resources);
	BUG_ON(!device->device_free_chan_resources);
	BUG_ON(!device->device_free_chan_resources);
	BUG_ON(!device->device_is_tx_complete);
	BUG_ON(!device->device_tx_status);
	BUG_ON(!device->device_issue_pending);
	BUG_ON(!device->device_issue_pending);
	BUG_ON(!device->dev);
	BUG_ON(!device->dev);


+9 −8
Original line number Original line Diff line number Diff line
@@ -819,9 +819,9 @@ static int dwc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd)
}
}


static enum dma_status
static enum dma_status
dwc_is_tx_complete(struct dma_chan *chan,
dwc_tx_status(struct dma_chan *chan,
	      dma_cookie_t cookie,
	      dma_cookie_t cookie,
		dma_cookie_t *done, dma_cookie_t *used)
	      struct dma_tx_state *txstate)
{
{
	struct dw_dma_chan	*dwc = to_dw_dma_chan(chan);
	struct dw_dma_chan	*dwc = to_dw_dma_chan(chan);
	dma_cookie_t		last_used;
	dma_cookie_t		last_used;
@@ -841,10 +841,11 @@ dwc_is_tx_complete(struct dma_chan *chan,
		ret = dma_async_is_complete(cookie, last_complete, last_used);
		ret = dma_async_is_complete(cookie, last_complete, last_used);
	}
	}


	if (done)
	if (txstate) {
		*done = last_complete;
		txstate->last = last_complete;
	if (used)
		txstate->used = last_used;
		*used = last_used;
		txstate->residue = 0;
	}


	return ret;
	return ret;
}
}
@@ -1346,7 +1347,7 @@ static int __init dw_probe(struct platform_device *pdev)
	dw->dma.device_prep_slave_sg = dwc_prep_slave_sg;
	dw->dma.device_prep_slave_sg = dwc_prep_slave_sg;
	dw->dma.device_control = dwc_control;
	dw->dma.device_control = dwc_control;


	dw->dma.device_is_tx_complete = dwc_is_tx_complete;
	dw->dma.device_tx_status = dwc_tx_status;
	dw->dma.device_issue_pending = dwc_issue_pending;
	dw->dma.device_issue_pending = dwc_issue_pending;


	dma_writel(dw, CFG, DW_CFG_DMA_EN);
	dma_writel(dw, CFG, DW_CFG_DMA_EN);
Loading