linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: rcar-dmac: use DMATCRB when xxx_TO_MEM direction
@ 2017-10-16  7:28 Kuninori Morimoto
  2017-10-16  8:49 ` Laurent Pinchart
  0 siblings, 1 reply; 10+ messages in thread
From: Kuninori Morimoto @ 2017-10-16  7:28 UTC (permalink / raw)
  To: Geert Uytterhoeven, Dan Williams, Vinod Koul, Laurent Pinchart
  Cc: Niklas Söderlund, dmaengine, linux-kernel@vger.kernel.org,
	Hiroyuki Yokoyama


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

SYS/RT/Audio DMAC have both TCR/TCRB.
Its difference is transfer counter value of read (= TCR)
or write (= TCRB). The relationship is like below.

         TCR       TCRB
 [SOURCE] -> [DMAC] -> [DESTINATION]

Thus, for residue calculation, we want to read
TCRB when MEM_TO_MEM/DEV_TO_MEM
TCR  when MEM_TO_DEV
Otherwise, Sound Capture has noise after PluseAudio support
(= 07b7acb51d2 ("ASoC: rsnd: update pointer more accurate"))

Signed-off-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
[Kuninori: add detail info on log, care direction]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

 - fixup Subject
 - care direction
 - From Kuninori Morimoto

 drivers/dma/sh/rcar-dmac.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 2b2c7db..f5d7bb7 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1246,6 +1246,7 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
 	enum dma_status status;
 	unsigned int residue = 0;
 	unsigned int dptr = 0;
+	u32 reg;
 
 	if (!desc)
 		return 0;
@@ -1309,8 +1310,17 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
 		residue += chunk->size;
 	}
 
-	/* Add the residue for the current chunk. */
-	residue += rcar_dmac_chan_read(chan, RCAR_DMATCR) << desc->xfer_shift;
+	/*
+	 * Add the residue for the current chunk
+	 *
+	 *         TCR       TCRB
+	 * [SOURCE] -> [DMAC] -> [DESTINATION]
+	 *
+	 * MEM_TO_xxx : TCR
+	 * xxx_TO_MEM : TCRB
+	 */
+	reg = (desc->direction == DMA_MEM_TO_DEV) ? RCAR_DMATCR : RCAR_DMATCRB;
+	residue += rcar_dmac_chan_read(chan, reg) << desc->xfer_shift;
 
 	return residue;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-10-20  6:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-16  7:28 [PATCH] dmaengine: rcar-dmac: use DMATCRB when xxx_TO_MEM direction Kuninori Morimoto
2017-10-16  8:49 ` Laurent Pinchart
2017-10-17  0:12   ` Kuninori Morimoto
2017-10-17  0:18     ` Kuninori Morimoto
2017-10-17 11:55       ` Laurent Pinchart
2017-10-18  0:01         ` Kuninori Morimoto
2017-10-18 13:46           ` Laurent Pinchart
2017-10-18 13:47             ` Geert Uytterhoeven
2017-10-19  0:49               ` Kuninori Morimoto
2017-10-20  6:12           ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).