Skip to content

Commit

Permalink
dmaengine: cppi41: delete channel from pending list when stop channel
Browse files Browse the repository at this point in the history
The driver defines three states for a cppi channel.
- idle: .chan_busy == 0 && not in .pending list
- pending: .chan_busy == 0 && in .pending list
- busy: .chan_busy == 1 && not in .pending list

There are cases in which the cppi channel could be in the pending state
when cppi41_dma_issue_pending() is called after cppi41_runtime_suspend()
is called.

cppi41_stop_chan() has a bug for these cases to set channels to idle state.
It only checks the .chan_busy flag, but not the .pending list, then later
when cppi41_runtime_resume() is called the channels in .pending list will
be transitioned to busy state.

Removing channels from the .pending list solves the problem.

Fixes: 975faae ("dma: cppi41: start tear down only if channel is busy")
Cc: [email protected] # v3.15+
Signed-off-by: Bin Liu <[email protected]>
Reviewed-by: Peter Ujfalusi <[email protected]>
Signed-off-by: Vinod Koul <[email protected]>
  • Loading branch information
liubiin authored and vinodkoul committed Dec 5, 2018
1 parent 6406885 commit 5986154
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion drivers/dma/ti/cppi41.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,22 @@ static int cppi41_stop_chan(struct dma_chan *chan)

desc_phys = lower_32_bits(c->desc_phys);
desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
if (!cdd->chan_busy[desc_num])
if (!cdd->chan_busy[desc_num]) {
struct cppi41_channel *cc, *_ct;

/*
* channels might still be in the pendling list if
* cppi41_dma_issue_pending() is called after
* cppi41_runtime_suspend() is called
*/
list_for_each_entry_safe(cc, _ct, &cdd->pending, node) {
if (cc != c)
continue;
list_del(&cc->node);
break;
}
return 0;
}

ret = cppi41_tear_down_chan(c);
if (ret)
Expand Down

0 comments on commit 5986154

Please sign in to comment.