Received: by 10.223.164.221 with SMTP id h29csp3839807wrb; Thu, 19 Oct 2017 04:56:28 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TEKft8Uyh0X2jrtK/fF3i84Vvdsh795v7N2lTQXSi9rt/JpWvf0gQxYz//yQr+A3R5g9RM X-Received: by 10.101.68.69 with SMTP id e5mr1162392pgq.282.1508414188175; Thu, 19 Oct 2017 04:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508414188; cv=none; d=google.com; s=arc-20160816; b=PA2XramC+gKADDFy0DtehMZawU8t5RsQbTw6jzVEb/3JO68is7ZgobHIkkBabYoZkD MqUAQJVysqIyawTIXupnl8cUQKCU+lex9Kl+XMtO3gjOhVZn0Ubw13TbDbLYHuMlg71Q Fz2O2VYW4Vg8P/LOvkWC4GjBY8b1aLl6ZlTHFwyAZHNhwpcn/K8fBptyN/4aOPQNe0v+ uHrwDPPtOEAr1yJvyxwZX8LgqakHidhYExUb2EsLm4/BXCr5FnNp0xaayF5k5+OlvHS+ AZS3eDnefGGrkiC7rjSkNjW3w07MM87A305EyzkUuD8aXtNbwS1oqfs8XsDySQj0eQPp M6nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=wzfSOnnmj1m7a0TD8ESYgaC3DgcTvLgeAK8LaUEjCAM=; b=oKnSeFdhY/q0zu8uFJRELlef2t+6VXUKr0pirq1Ql1ao0kNZGN4/tXYLDgde+Rqzy+ Lk6Ewf+QGAVmkJay+6ulAq1HOHSJR88rI1yg1SpYuse1CJZEZfi+I2e0uP5vljUdsuTO uQbbcdG6GvtgxrH0Tl7QpBp7OChzS5ohJLyP2SQXiRYA8Ndn7YNP5HVEaHz5GUQVKd5M L8NMhtQvi5yFIKMuzaGd8W88fLhobdIXjLB1ffNcURiz/Eaqe1Yc5NEWsez6T32o9aDG t8D+XbPSuAoLFqGEEd+dCwZKnelFpAilqke+kD1zJCrAAphv8fcJPff5hrJqcA+hTd63 iuVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=wDe+hh0Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m68si8422090pgm.67.2017.10.19.04.56.13; Thu, 19 Oct 2017 04:56:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=wDe+hh0Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752942AbdJSLzu (ORCPT + 99 others); Thu, 19 Oct 2017 07:55:50 -0400 Received: from galahad.ideasonboard.com ([185.26.127.97]:49795 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751680AbdJSLzs (ORCPT ); Thu, 19 Oct 2017 07:55:48 -0400 Received: from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id EB6EA200AD; Thu, 19 Oct 2017 13:55:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1508414108; bh=KSHdyOL361/lQ7RO/KcfyYfIjVx97fLLgr0r4Fy0yNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wDe+hh0Z9xMDVpsdyjuP/TAlYmx7qwQ5JbKcpius0jYobO+omxiDwv+RW1wBSOirf elCABr+BjYizT1mGDTLqItlGPNVtb6zoflIORhO5P2RSBhW5YKGMpmRa9bAEg62EIB h+GC6zeK7dtAckPnZas1ACVzazn0ydHgZImRSSA4= From: Laurent Pinchart To: Kuninori Morimoto Cc: Geert Uytterhoeven , Dan Williams , Vinod Koul , Niklas =?ISO-8859-1?Q?S=F6derlund?= , dmaengine@vger.kernel.org, "linux-kernel@vger.kernel.org" , Hiroyuki Yokoyama Subject: Re: [PATCH v3] dmaengine: rcar-dmac: use TCRB instead of TCR for residue Date: Thu, 19 Oct 2017 14:56:10 +0300 Message-ID: <1829561.1ekuWUXXN0@avalon> In-Reply-To: <87bml4c5e0.wl%kuninori.morimoto.gx@renesas.com> References: <87bml4c5e0.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Morimoto-san, Thank you for the patch. On Thursday, 19 October 2017 04:15:13 EEST Kuninori Morimoto wrote: > From: Hiroyuki Yokoyama > > SYS/RT/Audio DMAC includes independent data buffers for reading > and writing. Therefore, the read transfer counter and write transfer > counter have different values. > TCR indicates read counter, and TCRB indicates write counter. > The relationship is like below. > > TCR TCRB > [SOURCE] -> [DMAC] -> [SINK] > > In the MEM_TO_DEV direction, what really matters is how much data has > been written to the device. If the DMA is interrupted between read and > write, then, the data doesn't end up in the destination, so shouldn't > be counted. TCRB is thus the register we should use in this cases. > > In the DEV_TO_MEM direction, the situation is more complex. Both the > read and write side are important. What matters from a data consumer > point of view is how much data has been written to memory. > On the other hand, if the transfer is interrupted between read and > write, we'll end up losing data. It can also be important to report. > > In the MEM_TO_MEM direction, what matters is of course how much data > has been written to memory from data consumer point of view. > Here, because read and write have independent data buffers, it will > take a while for TCR and TCRB to become equal. Thus we should check > TCRB in this case, too. > > Thus, all cases we should check TCRB instead of TCR. > > Without this patch, Sound Capture has noise after PluseAudio support > (= 07b7acb51d2 ("ASoC: rsnd: update pointer more accurate")), because > the recorder will use wrong residue counter which indicates transferred > from sound device, but in reality the data was not yet put to memory > and recorder will record it. > > Signed-off-by: Hiroyuki Yokoyama > [Kuninori: added detail information in log] > Signed-off-by: Kuninori Morimoto Reviewed-by: Laurent Pinchart > --- > v2 -> v3 > > - Code is back to same as v1 > - log has more detail explanation > - From: is back to Yokoyama-san again > > drivers/dma/sh/rcar-dmac.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c > index 2b2c7db..50c4950 100644 > --- a/drivers/dma/sh/rcar-dmac.c > +++ b/drivers/dma/sh/rcar-dmac.c > @@ -1310,7 +1310,7 @@ static unsigned int rcar_dmac_chan_get_residue(struct > rcar_dmac_chan *chan, } > > /* Add the residue for the current chunk. */ > - residue += rcar_dmac_chan_read(chan, RCAR_DMATCR) << desc->xfer_shift; > + residue += rcar_dmac_chan_read(chan, RCAR_DMATCRB) << desc->xfer_shift; > > return residue; > } -- Regards, Laurent Pinchart From 1581670902044056703@xxx Thu Oct 19 07:41:56 +0000 2017 X-GM-THRID: 1581646621197538005 X-Gmail-Labels: Inbox,Category Forums