dmaengine: xgene-dma: move unmap to before callback
authorDave Jiang <dave.jiang@intel.com>
Mon, 25 Jul 2016 17:34:19 +0000 (10:34 -0700)
committerVinod Koul <vinod.koul@intel.com>
Mon, 8 Aug 2016 02:41:43 +0000 (08:11 +0530)
Completion callback should happen after dma_descriptor_unmap() has
happened. This allow the cache invalidate to happen and ensure that
the data accessed by the upper layer is in memory that was from DMA
rather than stale data. On some architecture this is done by the
hardware, however we should make the code consistent to not cause
confusion.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Cc: Rameshwar Prasad Sahu <rsahu@apm.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/xgene-dma.c

index d66ed11..8b693b7 100644 (file)
@@ -606,12 +606,11 @@ static void xgene_dma_run_tx_complete_actions(struct xgene_dma_chan *chan,
                return;
 
        dma_cookie_complete(tx);
+       dma_descriptor_unmap(tx);
 
        /* Run the link descriptor callback function */
        dmaengine_desc_get_callback_invoke(tx, NULL);
 
-       dma_descriptor_unmap(tx);
-
        /* Run any dependencies */
        dma_run_dependencies(tx);
 }