[RFC 3/3] dmaengine: edma: Prevent race between vchan_complete() and terminate_all

From: Peter Ujfalusi
Date: Wed Feb 10 2016 - 01:56:01 EST


Implement protection against vchan_complete() calling the client callback
after the channel has been terminated.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@xxxxxx>
---
drivers/dma/edma.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index 290e1a721c5b..edbf3a5d04b7 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -842,7 +842,9 @@ static int edma_terminate_all(struct dma_chan *chan)
unsigned long flags;
LIST_HEAD(head);

+ tasklet_disable(&echan->vchan.task);
spin_lock_irqsave(&echan->vchan.lock, flags);
+ vchan_terminate(&echan->vchan);

/*
* Stop DMA activity: we assume the callback will not be called
@@ -865,6 +867,7 @@ static int edma_terminate_all(struct dma_chan *chan)
vchan_get_all_descriptors(&echan->vchan, &head);
spin_unlock_irqrestore(&echan->vchan.lock, flags);
vchan_dma_desc_free_list(&echan->vchan, &head);
+ tasklet_enable(&echan->vchan.task);

return 0;
}
--
2.7.1


--------------010201030304020808000908--