Skip to content

Commit 4aea17f

Browse files
CL WangCharlesWu465
authored andcommitted
dmaengine: andes: atcdmac300: Fix the descriptor timeout issue (torvalds#167)
In v5_advance_work, v5_complete_all() moves the descriptors from the queue to the active_list. If active_list is empty, the operation of this DMA channel is stopped and the DMA channel is set to idle (chan_used = 0). However, if a new descriptor is added to the queue between the calls to v5_complete_all() and the check for list_empty(&v5chan->active_list), this descriptor will not be executed. if (list_is_singular(&v5chan->active_list)) { v5_complete_all(v5chan); } ... if (list_empty(&v5chan->active_list)) v5chan->chan_used = 0; else v5_dostart(v5chan, v5_first_active(v5chan)); The solution is to process the new descriptor in the queue before stopping the DMA channel if there is a new descriptor in the queue. if (list_is_singular(&v5chan->active_list)) { v5_complete_all(v5chan); } ... spin_lock(&v5chan->lock); if (list_empty(&v5chan->active_list)) { if (!list_empty(&v5chan->queue)) { list_move(v5chan->queue.next, &v5chan->active_list); ... Signed-off-by: CL Wang <[email protected]> Reviewed-on: https://gitea.andestech.com/RD-SW/linux/pulls/167 Reviewed-by: Tim Shih-Ting OuYang <[email protected]> Reviewed-by: randolph <[email protected]> Co-authored-by: CL Wang <[email protected]> Co-committed-by: CL Wang <[email protected]>
1 parent 815ca1d commit 4aea17f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

drivers/dma/atcdmac300.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,23 @@ static void v5_advance_work(struct v5_dma_chan *v5chan)
315315
DMA_TRANS_NOERROR);
316316
}
317317

318-
if (list_empty(&v5chan->active_list))
319-
v5chan->chan_used = 0;
320-
else
318+
spin_lock(&v5chan->lock);
319+
if (list_empty(&v5chan->active_list)) {
320+
if (!list_empty(&v5chan->queue)) {
321+
list_move(v5chan->queue.next,
322+
&v5chan->active_list);
323+
spin_unlock(&v5chan->lock);
324+
v5_dostart(v5chan,
325+
v5_first_active(v5chan));
326+
327+
} else {
328+
v5chan->chan_used = 0;
329+
spin_unlock(&v5chan->lock);
330+
}
331+
} else {
332+
spin_unlock(&v5chan->lock);
321333
v5_dostart(v5chan, v5_first_active(v5chan));
334+
}
322335
} else {
323336
/* For cyclic mode */
324337
struct dmaengine_result res;

0 commit comments

Comments
 (0)