Skip to content

Commit

Permalink
dmaengine: rcar-dmac: implement device_synchronize()
Browse files Browse the repository at this point in the history
Implement the device_synchronize() callback which wait until a dma
channel is stopped to provide a synchronization point.

This protects the driver from multiple race conditions when terminating
and freeing resources. E.g. the completion callback still running after
device_terminate_all() has completed.

Signed-off-by: Niklas Söderlund <[email protected]>
Signed-off-by: Vinod Koul <[email protected]>
(cherry picked from commit 30c4500)
Signed-off-by: Hiroyuki Yokoyama <[email protected]>
  • Loading branch information
Niklas Söderlund authored and h-yokoya committed Jul 11, 2017
1 parent c0b68cb commit 9a0958a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/dma/sh/rcar-dmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,13 @@ static void rcar_dmac_issue_pending(struct dma_chan *chan)
spin_unlock_irqrestore(&rchan->lock, flags);
}

static void rcar_dmac_device_synchronize(struct dma_chan *chan)
{
struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);

synchronize_irq(rchan->irq);
}

/* -----------------------------------------------------------------------------
* IRQ handling
*/
Expand Down Expand Up @@ -1857,6 +1864,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
engine->device_terminate_all = rcar_dmac_chan_terminate_all;
engine->device_tx_status = rcar_dmac_tx_status;
engine->device_issue_pending = rcar_dmac_issue_pending;
engine->device_synchronize = rcar_dmac_device_synchronize;

ret = dma_async_device_register(engine);
if (ret < 0)
Expand Down

0 comments on commit 9a0958a

Please sign in to comment.