From patchwork Mon Oct 16 07:28:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10007845 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 6145B60235 for ; Mon, 16 Oct 2017 07:28:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 540F023B34 for ; Mon, 16 Oct 2017 07:28:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47AE726E69; Mon, 16 Oct 2017 07:28:44 +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 B4C8123B34 for ; Mon, 16 Oct 2017 07:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751136AbdJPH2n (ORCPT ); Mon, 16 Oct 2017 03:28:43 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:65436 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750880AbdJPH2l (ORCPT ); Mon, 16 Oct 2017 03:28:41 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie4.idc.renesas.com with ESMTP; 16 Oct 2017 16:28:38 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id D942183A56; Mon, 16 Oct 2017 16:28:38 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.43,385,1503327600"; d="scan'208";a="260651770" Received: from mail-hk2apc01lp0209.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.209]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 16 Oct 2017 16:28:37 +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=NsxuJlDIySDSdYUjqMUrLU5jHi/jEq9SL/LUJvRFTJU=; b=Pu9ur8vhn8qFBsQEtgSU4jQ4BWnJpSqbKmjQ+0YX9lx3CYQypImir3z8P0oXzVb/GPsjZLFZiITSaoiJkPkVbrTL7bgOcWm6/Z3B15mC9+9vPPovq8nat1pVggz+SnoDFCEgWOs5LHfioU0fBZTnQNpeL1+WK8a32opSerpT4FQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.138) by SG2PR0601MB1887.apcprd06.prod.outlook.com (2603:1096:3:9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Mon, 16 Oct 2017 07:28:35 +0000 Message-ID: <87d15nmude.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH] dmaengine: rcar-dmac: use DMATCRB when xxx_TO_MEM direction User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Geert Uytterhoeven , Dan Williams , Vinod Koul , Laurent Pinchart 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: Mon, 16 Oct 2017 07:28:35 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: HK2PR04CA0048.apcprd04.prod.outlook.com (2603:1096:202:14::16) To SG2PR0601MB1887.apcprd06.prod.outlook.com (2603:1096:3:9::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c6916612-d8f2-4f07-eb24-08d5146783e4 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:SG2PR0601MB1887; X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 3:JnpVnZYpdEK12nDBLYciEQRUHKJw5fFjs3dQMMt+0gtKmGv8mbtHvu3b6BBXcOW6iCqCpl2MJCcTK2lbvp2T4ywGkVgYd3z/V3KA1gGKyOF+i5YFQxhUY7tvE/pjNbS9zpvqn31ePCF8C2yxPQSC1RMGhyDwus56RDcFr7H6ItSRTnMbjaNLmrj1qyyMmab1ci7DF4Z9VaGd6t/wGzFZr/Ca0cO2DHpEWoNeaT077qA6fr/DYT7+KhDgtvxjLP3i; 25:3bhWmEna3zxXkyoGBmpKG9nTXg9ME+oV/rFjSMolsI9qDMNWQ23gND6ovRSLGgW84TmD8cnnuO8Qzzo1udUIbh8rjK5oIsPCmLtLleNnx7Vkzxs6iAh55hyJshCemOkrIKVTtqEDDtHPeIwUs6lbBH+pZgvMms6mDcTEjb2gFJRxAoaE/eI4a5ruFGkLdbZ2RDFv37pipR3hTpzO1v11tZJBZsHtojA9mj8Ipl8VYti4m4LJmLMXfy5DnnWim39GGr7Fhwk0DW6egUONtAeSbMQYexKOwYcn8scY9tkfKVjC4LRh5nV6OE9Y0XCTMtGuAeR87pLwQvXDKVqD2ZdyQQ==; 31:pKNfZua4TsZyEaUwEwS8Cbu+JeId6txcC07yFu8AS6aQwy7UvC8tXnDpgWsIkVHiTokwoGpLl4CLoVm/6S7Thm3oEJGFqNdWX3sFokxJW7vLMamlU387awvafvDZhGnLf1gdo641RLIi7md+wpP27fZnTtucwlLD15IFqxYSMUv4BWaDWbwMozZfOIfCvLVzk3dug/n9z8xToGGC8gKUCfu9m8u/vzN1zfP1CzRauyk= X-MS-TrafficTypeDiagnostic: SG2PR0601MB1887: X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 20:9BLGaujg2Frnh8s9RDTf7oCwvHmsBfwiKSDgb0IRhpqQJWZE/6gUPFDADn4RXk/11R8HOLGROht5+ht97B1Lx1cBNQS+Ld/ie1xIvYrQR1d0D4YCoidd75Tg5G3V2s0zJfEyqd3jBk/ZFSq5AOpAdFJ3OpcXQVZ1P6WyKcHS3jMKCIR/zE7hm7oijyI5BmQD2i78AOmb0aCF4cGuShnuTIfZG7OMZryjQML/8P9gp+waYlgIkfrFjs5Lv2SPlJg1tvhYiLnedk5wFyY9bxW7tGhj2lujHyQN8Fy7LUKGhwRB01dHkeHxrBzYQ8xJI4xdenma4cKdS0llHhNpOWG/fRQPvdEoW6L5p9ac6CbxHvlSbOyvhI/ECquzYIBthNyegeENwNcTccldIH+DqVu591344Ze5KiaCk+0nFMKhsL+JeBMnx1cJPInLsJLw391Skk2z6tHDcI2fy0no9+y0/AU/wy66IWHtyr9FP4zpMYjWLNn6tpDaD3vjOoPXZi2H; 4:UL5TECK//oUclx/VKZrYQvfYNpqzJj0vMFYfxC4hWtEtlffjjs3RHkFLBfCtsYIFtYe/fVpvwLwusOUPio4kGb0xNmNIM97vp0NZV2vdZT+62fcmo4xUJYNRxzMPB6K453mpQaM9rUMhVzIaR2gqdlXjf+z6m+6oErpVC8llbyKZlF+ka4hmt50EP5oHj4sXlY20APER7QUHy1Iu45gIBgUkyPaxixW+YDj2e5ZMzoG5r7JTIbUnZuxXEpgZ5GzV 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)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SG2PR0601MB1887; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SG2PR0601MB1887; X-Forefront-PRVS: 0462918D61 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(376002)(346002)(39860400002)(189002)(199003)(50986999)(68736007)(83506001)(8936002)(189998001)(8676002)(54356999)(81156014)(81166006)(6486002)(101416001)(33646002)(2906002)(86362001)(53936002)(106356001)(53416004)(105586002)(50466002)(4326008)(107886003)(66066001)(3846002)(23726003)(6116002)(36756003)(16526018)(316002)(54906003)(110136005)(58126008)(16586007)(47776003)(5660300001)(97736004)(25786009)(305945005)(69596002)(7736002)(478600001)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR0601MB1887; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR0601MB1887; 23:HzIym0BcsShCJNBGG0Eu1rG7+KZO/8cl62MvLPd?= =?us-ascii?Q?EHLi+g5je0Yo+m54vUUUdYvg4wypfKHxuk/9fq+QmShjeVHQZZ683pN4xYSj?= =?us-ascii?Q?IIzKbXO1pTXBBEb5gQw1Qvfy8YimCrrxp/SuyT9glEseDRY561clEyaCfrqI?= =?us-ascii?Q?DwLDUCoigZkP6Zbt9ZZbTHMilTSfGutu0oANtvUNR7n5Wj0IfB1K/mroGno+?= =?us-ascii?Q?WnN8XptRsjyvX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N/JSetj5/4vJ5HqNPB4GohSSl6iUlFIgOGzAw8epdCASHiGF4h3pkTQ6C/9QXCWPhv32spXFXkKD/tn6JvVeIy6lnwD8GVM9tvvtOnWJ8c6In2cidygEFC1+SWNZ3t7VNgC0/Ik9Wc5L9RFuBCGyySDY= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2017 07:28:35.9329 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR0601MB1887 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto 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 [Kuninori: add detail info on log, care direction] Signed-off-by: Kuninori Morimoto --- 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; }