From patchwork Thu Oct 19 01:15:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10015671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 85D4E600CC for ; Thu, 19 Oct 2017 01:15:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 781A628D6D for ; Thu, 19 Oct 2017 01:15:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B42128D72; Thu, 19 Oct 2017 01:15:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6A2E28D6D for ; Thu, 19 Oct 2017 01:15:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751038AbdJSBPX (ORCPT ); Wed, 18 Oct 2017 21:15:23 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:22994 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750946AbdJSBPV (ORCPT ); Wed, 18 Oct 2017 21:15:21 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 19 Oct 2017 10:15:18 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 720BA684BE; Thu, 19 Oct 2017 10:15:18 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.43,399,1503327600"; d="scan'208";a="260930030" Received: from mail-sg2apc01lp0244.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.244]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 19 Oct 2017 10:15:16 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=v5ZUAJuL+FKYyYva0rBKXGIQ7d8xiZhFxCLa1cimx8U=; b=k67rkB2UMoIUpA2CUxOeyKBChtdoFjEJFIJ4LIuwEee6DvqtlTyor9SNUm7CuWt7I6qAsK8yiJ1rL2GWxAnadBBAtyJUvvhtmSi5TQ8Obr9HnOtdDYSLx8WmwXp33gc6AZB+knbqCKFcXe6mAydwvYZty28gZYdh5BZbyJoHEZI= Received: from morimoto-PC.renesas.com (211.11.155.138) by PS1PR0601MB1881.apcprd06.prod.outlook.com (2603:1096:803:8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Thu, 19 Oct 2017 01:15:13 +0000 Message-ID: <87bml4c5e0.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3] dmaengine: rcar-dmac: use TCRB instead of TCR for residue User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Geert Uytterhoeven , Laurent Pinchart , Dan Williams , Vinod Koul Cc: Niklas =?ISO-8859-1?Q?S=F6derlund?= , dmaengine@vger.kernel.org, "linux-kernel@vger.kernel.org" , Hiroyuki Yokoyama MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Thu, 19 Oct 2017 01:15:13 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: KAWPR01CA0060.jpnprd01.prod.outlook.com (2603:1096:402:b::20) To PS1PR0601MB1881.apcprd06.prod.outlook.com (2603:1096:803:8::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99ea9c41-364e-48b1-3805-08d5168ed9c1 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603229)(201703131423075)(201703031133081)(201702281549075); SRVR:PS1PR0601MB1881; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1881; 3:I4WjSiaz3j+lWRkXRa/yk9l23Fo288qSfDDCJ9W4QcTFHK8C58KmEm6CzOmlRX/msSP8KVVvz5Glp/jh4S/d+bAClcdyR26/2Ailano00ISJzHwiMaMzrHFcPTr4Im1gkjqk+No9y4zQDzAhQIi1YiSmRVQsVoWHpOCarhIbRYmAq2dT5RBqvP/y85TakqDiE94x8f2sDN41Q3zTPDRKThjuvdADbvFvLl3ZzC4v26JvN6MfvnDn2ab3mFWf90sb; 25:xAL9X63U+dgMRh8t0+GUtLZkT22tPst/edm2jPmUa+A1IdJ3nzwUWPCFFxWiA0LAGSalRFo7joTet8KJhbEsmax5tQjwq1Vovmiz1kks/iyiMRiHjen7P+iBWXiVeQitAP6VUCdTt/LMd4j/Rpq9yy10g1t34W6GWAxHSX8KnGQB1WrlexiTL/BNCJaeRWq44nFtztcI8rb+XhbdLPfrXj3gRUC7iobZRv9KSofNljOer6F8FsMiBqV69WV0NiSUgBCFGm8IhZRneTYnMpj2tS5iaMcSqmORRKclBzKv2dQ0A+TC9TAbppR5Xjs5RMR/8i8WRhn/rL8uH427HeYW0g==; 31:uKFQjETVhTc5hXVwdrelkgCb62e10iRPySlDngABSpefOScADhmzY6DTFLXLvV5FpekLPRJXsgYdq47nxbtoY84ysIIi5cTz3NBmF+/O+wtZRJ1DhBj3m3H+aYC0BeV9y1p4fWwF00o2iq9SXiyJHnLYoYejjhmG5mrZXQ7t+YaLhF8Xi0kihGs6sarRYMybGdrIOH6Nxwlwegg0XjTsBwev/R5c8Zna/gB8ghFfv/k= X-MS-TrafficTypeDiagnostic: PS1PR0601MB1881: X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1881; 20:0+zOfdWs9xnonhPNf48PocjAw+ZD47bycEpf/MEe8yoxX+QCxs1zRuSiOVuFF6UtWuA5VPyD5dZh3DhVKAxUWy/16zbnITs70JYoLYG6z1SshVHt2Y7qdeA5V5lELBTK3QGr4wAiPq5ZvPOo46V780fT6J3XKQBIxJjrm7Sqx2WT8xBGgo1zY6NFytRGEi3fYsU+eUxQ5Em4N8wYOYCFV2odLkoJB32B+OFE4aqaHwoPhozytNWghfczLZ0rKSE0Bhc5UHb4EIMIWiJAf32bf34WrovMt/zlrYHVVGFp4aD4Ut7JoPqyWW4O5VL02BSQuAQLkBFHJpR3/Q0Zt6/2NtIEz1piW2/KDr9bjsDbhfLhkY7UcwuhoJCm5tL35So3V1U0/Q6KcteefHa4FUbUWaQcwAzuj/BxMDBRr/X3ZYc2VaYLyJGPE2XGkgRJNiou50utSo5nKe9W1R9iN4h2c2sPEcNC19Jyao92Kq0X4zS573qvD6E22r8AEwFrMpkl; 4:VBd30+Hcbsmq1/kERbvNikMAzZ8DKKl35XJF9GWqK7fbRMSItmpdH5CSSzrdel1QsvwogAtl1EKzf5gshwgTW9YJpP5C0rT9uPQc9n/uiFV7bDVv09zdE64HBYeH0GFAiuyJSKL7/cJ08ove3inz6rUrJ3qMt7hrEcGeG2OPaLJLcv9BSFeLYm8vjKCJ8ei4LZMNeZKd/EmochJBuquM3pHdUWBT249cpAuHFwfvshV1u0PCRn+wm9G0N57/MvUt X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:PS1PR0601MB1881; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:PS1PR0601MB1881; X-Forefront-PRVS: 0465429B7F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(376002)(39860400002)(346002)(199003)(189002)(81156014)(305945005)(81166006)(8936002)(8676002)(3846002)(54356999)(50986999)(23726003)(6116002)(101416001)(106356001)(7736002)(105586002)(53416004)(33646002)(97736004)(69596002)(68736007)(6486002)(5660300001)(189998001)(50466002)(58126008)(53936002)(83506001)(25786009)(110136005)(16586007)(54906003)(316002)(16526018)(107886003)(47776003)(478600001)(36756003)(86362001)(66066001)(4326008)(2906002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR0601MB1881; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; PS1PR0601MB1881; 23:M+jCJNO+jtttZFPAQwRFfGcI8vxIaaGv5tup4SG?= =?us-ascii?Q?F0Co/KxA1urSn+m1/9DnycfhJydCzNzWYQ+rsl9MNelKnvk9i15k1+zbn4SB?= =?us-ascii?Q?XwWNeGiRk0zG2y3CBXUpOXdV9Nwwgxfps4G8D+yfdbJodd1rctQZDN6OsnBY?= =?us-ascii?Q?BV/Gx5eLUjEDVn9gScQV7Iphgu3UFTW109EhKtjfwqy/sOcqzI7U/D8XLNgJ?= =?us-ascii?Q?+iWMR7zOu5HSlmUTtDhq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HpvX/rcT+Od8Eci7M+mpOyHAx3l6UDL+h81uP5NZoqv2yNbbyhivKQahJ2ldymN68yvtvxj9I7iUx7Ry0eXl2EkJw= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2017 01:15:13.1810 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR0601MB1881 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Geert Uytterhoeven 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; }