mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
dmaengine: stm32-dma: use vchan_terminate_vdesc() in .terminate_all
[ Upstream commit d80cbef35b
]
To avoid race with vchan_complete, use the race free way to terminate
running transfer.
Move vdesc->node list_del in stm32_dma_start_transfer instead of in
stm32_mdma_chan_complete to avoid another race in vchan_dma_desc_free_list.
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Link: https://lore.kernel.org/r/20200129153628.29329-9-amelie.delaunay@st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f60007c9e9
commit
cdf63c29af
1 changed files with 6 additions and 3 deletions
|
@ -488,8 +488,10 @@ static int stm32_dma_terminate_all(struct dma_chan *c)
|
|||
|
||||
spin_lock_irqsave(&chan->vchan.lock, flags);
|
||||
|
||||
if (chan->busy) {
|
||||
stm32_dma_stop(chan);
|
||||
if (chan->desc) {
|
||||
vchan_terminate_vdesc(&chan->desc->vdesc);
|
||||
if (chan->busy)
|
||||
stm32_dma_stop(chan);
|
||||
chan->desc = NULL;
|
||||
}
|
||||
|
||||
|
@ -545,6 +547,8 @@ static void stm32_dma_start_transfer(struct stm32_dma_chan *chan)
|
|||
if (!vdesc)
|
||||
return;
|
||||
|
||||
list_del(&vdesc->node);
|
||||
|
||||
chan->desc = to_stm32_dma_desc(vdesc);
|
||||
chan->next_sg = 0;
|
||||
}
|
||||
|
@ -622,7 +626,6 @@ static void stm32_dma_handle_chan_done(struct stm32_dma_chan *chan)
|
|||
} else {
|
||||
chan->busy = false;
|
||||
if (chan->next_sg == chan->desc->num_sgs) {
|
||||
list_del(&chan->desc->vdesc.node);
|
||||
vchan_cookie_complete(&chan->desc->vdesc);
|
||||
chan->desc = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue