]> git.karo-electronics.de Git - linux-beck.git/commitdiff
dmaengine: virt-dma: Add synchronization helper function
authorLars-Peter Clausen <lars@metafoo.de>
Tue, 20 Oct 2015 09:46:29 +0000 (11:46 +0200)
committerVinod Koul <vinod.koul@intel.com>
Mon, 16 Nov 2015 02:58:52 +0000 (08:28 +0530)
Add a synchronize helper function for the virt-dma library. The function
makes sure that any scheduled descriptor complete callbacks have finished
running before the function returns.

This needs to be called by drivers using virt-dma in their
device_synchronize() callback. Depending on the driver additional
operations might be necessary in addition to calling vchan_synchronize() to
ensure proper synchronization.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/virt-dma.h

index 2fa47745a41f1ae9a4f2b834604127b0bca0e06f..edbb5751572b5e75e9bebfd47ad4e8622ecf2070 100644 (file)
@@ -151,4 +151,17 @@ static inline void vchan_free_chan_resources(struct virt_dma_chan *vc)
        vchan_dma_desc_free_list(vc, &head);
 }
 
+/**
+ * vchan_synchronize() - synchronize callback execution to the current context
+ * @vc: virtual channel to synchronize
+ *
+ * Makes sure that all scheduled or active callbacks have finished running. For
+ * proper operation the caller has to ensure that no new callbacks are scheduled
+ * after the invocation of this function started.
+ */
+static inline void vchan_synchronize(struct virt_dma_chan *vc)
+{
+       tasklet_kill(&vc->task);
+}
+
 #endif