dma: cppi41: delete channel from pending list when stop channel
Subsystems (3)
Peter,
Quoted 81 lines · Peter Ujfalusi
Hi,
On 28/11/2018 13.15, Peter Ujfalusi wrote:
forgot to fix up Vinod's email address.
Quoted 75 lines · Bin Liu
Can you fix up the subject line to:
dmaengine: ti: cppi4: delete channel from pending list when stop channelQuoted 9 lines
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 listThere are cases in which the cppi channel could be in the pending state when
cppi41_dma_issue_pending()is called aftercppi41_runtime_suspend()is called.Quoted 6 lines
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 whencppi41_runtime_resume()is called the channels in .pending list will be transitioned to busy state.Removing channels from the .pending list solves the problem.
So, let me see if I understand this correctly:
- client issued a transfer _after_ the cppi4 driver is suspended
-cppi41_dma_issue_pending()will place it to pending list and will not start the transfer right away ascdd->is_suspendedis true.
- on resume the cppi4 will pick up the pending transfers from the pending listThis is so far a sane thing to do.
If I guess right, then after the
issue_pendingthe client driver will callterminate_all, presumably from it's suspend callback?As per the purpose of
terminate_allwe should terminated all future transfers on the channel, so clearing the pending list is the correct thing to do.With the fixed subject:
Reviewed-by Peter Ujfalusi <[email protected]>I have one question:
Quoted 18 lines
Fixes 975faaeb9985 ("dma: cppi41: start tear down only if channel is busy")Cc [email protected] # v3.15+Signed-off-by Bin Liu <[email protected]>--- drivers/dma/ti/cppi41.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/dma/ti/cppi41.c +2
-1@@ -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;drivers/dma/ti/cppi41.c static int cppi41_stop_chan(struct dma_chan *chan) · line 737
Quoted 10 lines
drivers/dma/ti/cppi41.c +10
-0+ +/* +* 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);If we delete from the pending list, are we going to leak memory? I'm not familiar with the cppi4, it might not be an issue for it.
Here is no memory leak.
The elements added to the pending list are cppi41 channels which are allocated in driver _probe(). No dynamic memory allocation happening when operating this pending list.
Regards,
-Bin.