Commit 6fa7e0e8 authored by Sanjay R Mehta's avatar Sanjay R Mehta Committed by Vinod Koul
Browse files

dmaengine: ptdma: fix concurrency issue with multiple dma transfer



The command should be submitted only if the engine is idle,
for this, the next available descriptor is checked and set the flag
to false in case the descriptor is non-empty.

Signed-off-by: default avatarSanjay R Mehta <sanju.mehta@amd.com>
Link: https://lore.kernel.org/r/1643814880-3882-2-git-send-email-Sanju.Mehta@amd.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 614c8bec
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -233,9 +233,14 @@ static void pt_issue_pending(struct dma_chan *dma_chan)
	struct pt_dma_chan *chan = to_pt_chan(dma_chan);
	struct pt_dma_chan *chan = to_pt_chan(dma_chan);
	struct pt_dma_desc *desc;
	struct pt_dma_desc *desc;
	unsigned long flags;
	unsigned long flags;
	bool engine_is_idle = true;


	spin_lock_irqsave(&chan->vc.lock, flags);
	spin_lock_irqsave(&chan->vc.lock, flags);


	desc = pt_next_dma_desc(chan);
	if (desc)
		engine_is_idle = false;

	vchan_issue_pending(&chan->vc);
	vchan_issue_pending(&chan->vc);


	desc = pt_next_dma_desc(chan);
	desc = pt_next_dma_desc(chan);
@@ -243,7 +248,7 @@ static void pt_issue_pending(struct dma_chan *dma_chan)
	spin_unlock_irqrestore(&chan->vc.lock, flags);
	spin_unlock_irqrestore(&chan->vc.lock, flags);


	/* If there was nothing active, start processing */
	/* If there was nothing active, start processing */
	if (desc)
	if (engine_is_idle)
		pt_cmd_callback(desc, 0);
		pt_cmd_callback(desc, 0);
}
}