Commit d64e9a2c authored by Stephen Barber's avatar Stephen Barber Committed by Vinod Koul

dmaengine: pl330: fix residual for non-running BUSY descriptors

Only one descriptor in the work list should be running at
any given time, but it's possible to have an enqueued BUSY
descriptor that has not yet transferred any data, or for
a BUSY descriptor to linger briefly before transitioning
to DONE. These cases should be handled to keep residual
calculations consistent even with the non-running BUSY
descriptors in the work list.
Signed-off-by: default avatarStephen Barber <smbarber@chromium.org>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 29b4817d
...@@ -2274,7 +2274,7 @@ pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie, ...@@ -2274,7 +2274,7 @@ pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
{ {
enum dma_status ret; enum dma_status ret;
unsigned long flags; unsigned long flags;
struct dma_pl330_desc *desc, *running = NULL; struct dma_pl330_desc *desc, *running = NULL, *last_enq = NULL;
struct dma_pl330_chan *pch = to_pchan(chan); struct dma_pl330_chan *pch = to_pchan(chan);
unsigned int transferred, residual = 0; unsigned int transferred, residual = 0;
...@@ -2291,6 +2291,8 @@ pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie, ...@@ -2291,6 +2291,8 @@ pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
if (pch->thread->req_running != -1) if (pch->thread->req_running != -1)
running = pch->thread->req[pch->thread->req_running].desc; running = pch->thread->req[pch->thread->req_running].desc;
last_enq = pch->thread->req[pch->thread->lstenq].desc;
/* Check in pending list */ /* Check in pending list */
list_for_each_entry(desc, &pch->work_list, node) { list_for_each_entry(desc, &pch->work_list, node) {
if (desc->status == DONE) if (desc->status == DONE)
...@@ -2298,6 +2300,15 @@ pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie, ...@@ -2298,6 +2300,15 @@ pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
else if (running && desc == running) else if (running && desc == running)
transferred = transferred =
pl330_get_current_xferred_count(pch, desc); pl330_get_current_xferred_count(pch, desc);
else if (desc->status == BUSY)
/*
* Busy but not running means either just enqueued,
* or finished and not yet marked done
*/
if (desc == last_enq)
transferred = 0;
else
transferred = desc->bytes_requested;
else else
transferred = 0; transferred = 0;
residual += desc->bytes_requested - transferred; residual += desc->bytes_requested - transferred;
......
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