[RFC 2/3] dmaengine: omap-dma: Prevent race between vchan_complete() and terminate_all

From: Peter Ujfalusi
Date: Wed Feb 10 2016 - 01:55:44 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/omap-dma.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index bfdf29aa3428..1912be81e56d 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -980,7 +980,9 @@ static int omap_dma_terminate_all(struct dma_chan *chan)
unsigned long flags;
LIST_HEAD(head);

+ tasklet_disable(&c->vc.task);
spin_lock_irqsave(&c->vc.lock, flags);
+ vchan_terminate(&c->vc);

/*
* Stop DMA activity: we assume the callback will not be called
@@ -1003,6 +1005,7 @@ static int omap_dma_terminate_all(struct dma_chan *chan)
vchan_get_all_descriptors(&c->vc, &head);
spin_unlock_irqrestore(&c->vc.lock, flags);
vchan_dma_desc_free_list(&c->vc, &head);
+ tasklet_enable(&c->vc.task);

return 0;
}
--
2.7.1


--------------010201030304020808000908
Content-Type: text/x-patch;
name="0003-dmaengine-edma-Prevent-race-between-vchan_complete-a.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="0003-dmaengine-edma-Prevent-race-between-vchan_complete-a.pa";
filename*1="tch"