Commit 4689d35c authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Vinod Koul

dmaengine: ti: omap-dma: Improved memcpy polling support

When a DMA client driver does not set the DMA_PREP_INTERRUPT because it
does not want to use interrupts for DMA completion or because it can not
rely on DMA interrupts due to executing the memcpy when interrupts are
disabled it will poll the status of the transfer.

If the interrupts are enabled then the cookie will be set completed in the
interrupt handler so only check in HW completion when the polling is really
needed.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20190716082459.1222-3-peter.ujfalusi@ti.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent aac86703
...@@ -91,6 +91,7 @@ struct omap_desc { ...@@ -91,6 +91,7 @@ struct omap_desc {
bool using_ll; bool using_ll;
enum dma_transfer_direction dir; enum dma_transfer_direction dir;
dma_addr_t dev_addr; dma_addr_t dev_addr;
bool polled;
int32_t fi; /* for OMAP_DMA_SYNC_PACKET / double indexing */ int32_t fi; /* for OMAP_DMA_SYNC_PACKET / double indexing */
int16_t ei; /* for double indexing */ int16_t ei; /* for double indexing */
...@@ -816,26 +817,20 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan, ...@@ -816,26 +817,20 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan,
struct virt_dma_desc *vd; struct virt_dma_desc *vd;
enum dma_status ret; enum dma_status ret;
unsigned long flags; unsigned long flags;
struct omap_desc *d = NULL;
ret = dma_cookie_status(chan, cookie, txstate); ret = dma_cookie_status(chan, cookie, txstate);
if (ret == DMA_COMPLETE)
if (!c->paused && c->running) {
uint32_t ccr = omap_dma_chan_read(c, CCR);
/*
* The channel is no longer active, set the return value
* accordingly
*/
if (!(ccr & CCR_ENABLE))
ret = DMA_COMPLETE;
}
if (ret == DMA_COMPLETE || !txstate)
return ret; return ret;
spin_lock_irqsave(&c->vc.lock, flags); spin_lock_irqsave(&c->vc.lock, flags);
if (c->desc && c->desc->vd.tx.cookie == cookie)
d = c->desc;
if (!txstate)
goto out;
if (c->desc && c->desc->vd.tx.cookie == cookie) { if (d) {
struct omap_desc *d = c->desc;
dma_addr_t pos; dma_addr_t pos;
if (d->dir == DMA_MEM_TO_DEV) if (d->dir == DMA_MEM_TO_DEV)
...@@ -852,8 +847,22 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan, ...@@ -852,8 +847,22 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan,
txstate->residue = 0; txstate->residue = 0;
} }
if (ret == DMA_IN_PROGRESS && c->paused) out:
if (ret == DMA_IN_PROGRESS && c->paused) {
ret = DMA_PAUSED; ret = DMA_PAUSED;
} else if (d && d->polled && c->running) {
uint32_t ccr = omap_dma_chan_read(c, CCR);
/*
* The channel is no longer active, set the return value
* accordingly and mark it as completed
*/
if (!(ccr & CCR_ENABLE)) {
struct omap_desc *d = c->desc;
ret = DMA_COMPLETE;
omap_dma_start_desc(c);
vchan_cookie_complete(&d->vd);
}
}
spin_unlock_irqrestore(&c->vc.lock, flags); spin_unlock_irqrestore(&c->vc.lock, flags);
...@@ -1181,7 +1190,10 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_memcpy( ...@@ -1181,7 +1190,10 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_memcpy(
d->ccr = c->ccr; d->ccr = c->ccr;
d->ccr |= CCR_DST_AMODE_POSTINC | CCR_SRC_AMODE_POSTINC; d->ccr |= CCR_DST_AMODE_POSTINC | CCR_SRC_AMODE_POSTINC;
d->cicr = CICR_DROP_IE | CICR_FRAME_IE; if (tx_flags & DMA_PREP_INTERRUPT)
d->cicr |= CICR_FRAME_IE;
else
d->polled = true;
d->csdp = data_type; d->csdp = data_type;
......
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