Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f00e1c5 authored by Dirk Behme's avatar Dirk Behme Committed by Greg Kroah-Hartman
Browse files

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



commit 907bd68a2edc491849e2fdcfe52c4596627bca94 upstream.

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: 3544d287 ("dmaengine: rcar-dmac: use result of updated get_residue in tx_status")
Signed-off-by: default avatarDirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: default avatarAchim Dahlhoff <Achim.Dahlhoff@de.bosch.com>
Signed-off-by: default avatarHiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: default avatarYao Lihua <ylhuajnu@outlook.com>
Reviewed-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: <stable@vger.kernel.org> # v4.8+
Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f7b467ad
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1367,6 +1367,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)
@@ -1374,10 +1375,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);