dmaengine: sh: rcar-dmac: Fix glitch in dmaengine_tx_status
authorAchim Dahlhoff <Achim.Dahlhoff@de.bosch.com>
Fri, 12 Apr 2019 05:29:14 +0000 (07:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 May 2019 07:58:55 +0000 (09:58 +0200)
commit129c337c665909cac36303d11f2f4a1619fed3a0
treeac322b85b06bddbb57970cddbf879479513040ab
parent0f00e1c599b329bdede72457f99b625d243d5e5f
dmaengine: sh: rcar-dmac: Fix glitch in dmaengine_tx_status

commit 6e7da74775348d96e2d7efaf3f91410e18c481ef upstream.

The tx_status poll in the rcar_dmac driver reads the status register
which indicates which chunk is busy (DMACHCRB). Afterwards the point
inside the chunk is read from DMATCRB. It is possible that the chunk
has changed between the two reads. The result is a non-monotonous
increase of the residue. Fix this by introducing a 'safe read' logic.

Fixes: 73a47bd0da66 ("dmaengine: rcar-dmac: use TCRB instead of TCR for residue")
Signed-off-by: Achim Dahlhoff <Achim.Dahlhoff@de.bosch.com>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: <stable@vger.kernel.org> # v4.16+
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dma/sh/rcar-dmac.c