Skip to contentSkip to conversation

dmaengine: sh: rcar-dmac: With cyclic DMA residue 0 is valid

PATCH New Laurent Pinchart 1 participant 1 message Apr 12, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 dmaengine: sh: rcar-dmac: With cyclic DMA residue 0 is valid

Hi Dirk,

Thank you for the patch.

Quoted 10 lines · Dirk Behme

Having a cyclic DMA, a residue 0 is not an indication of a completed DMA. In case of cyclic DMA make sure that dma_set_residue() is called and with this a residue of 0 is forwarded correctly to the caller.

Fixes 3544d2878817 ("dmaengine: rcar-dmac: use result of updated get_residue in tx_status")
Cc <[email protected]> # v4.8+
Quoted 35 lines

---
Note: Patch done against mainline v5.0

Changes in v2: None

Changes in v3: Move reading rchan into the spin lock protection.

 drivers/dma/sh/rcar-dmac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/sh/rcar-dmac.c +3 -1
index 2b4f25698169..54810ffd95e2 100644
@@ -1368,6 +1368,7 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan,
 	enum dma_status status;
 	unsigned long flags;
 	unsigned int residue;
+	bool cyclic;
 
 	status = dma_cookie_status(chan, cookie, txstate);
 	if (status == DMA_COMPLETE || !txstate)
@@ -1375,10 +1376,11 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan,
 
 	spin_lock_irqsave(&rchan->lock, flags);
 	residue = rcar_dmac_chan_get_residue(rchan, cookie);
+	cyclic = rchan->desc.running ? rchan->desc.running->cyclic : false;
 	spin_unlock_irqrestore(&rchan->lock, flags);
 
 	/* if there's no residue, the cookie is complete */
-	if (!residue)
+	if (!residue && !cyclic)
 		return DMA_COMPLETE;
 
 	dma_set_residue(txstate, residue);