dmaengine: tegra-apb: Prevent race conditions on channel's freeing
authorDmitry Osipenko <digetx@gmail.com>
Sun, 9 Feb 2020 16:33:41 +0000 (19:33 +0300)
committerVinod Koul <vkoul@kernel.org>
Tue, 25 Feb 2020 06:27:33 +0000 (11:57 +0530)
It's incorrect to check the channel's "busy" state without taking a lock.
That shouldn't cause any real troubles, nevertheless it's always better
not to have any race conditions in the code.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Link: https://lore.kernel.org/r/20200209163356.6439-5-digetx@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/tegra20-apb-dma.c

index b18cbfbab004006162551aa67111fb3d45d61d4f..81a2b5f4181fbd3c9e9e39a0df412145023de554 100644 (file)
@@ -1298,8 +1298,7 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc)
 
        dev_dbg(tdc2dev(tdc), "Freeing channel %d\n", tdc->id);
 
-       if (tdc->busy)
-               tegra_dma_terminate_all(dc);
+       tegra_dma_terminate_all(dc);
 
        spin_lock_irqsave(&tdc->lock, flags);
        list_splice_init(&tdc->pending_sg_req, &sg_req_list);