From patchwork Mon Jul 2 09:18:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 10500777 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 068AB60325 for ; Mon, 2 Jul 2018 09:19:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9E74285CE for ; Mon, 2 Jul 2018 09:19:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDCF62868D; Mon, 2 Jul 2018 09:19:06 +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=-5.3 required=2.0 tests=AXB_X_OUTLOOKPROT_ENVSDR, BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, 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 470EE285CE for ; Mon, 2 Jul 2018 09:19:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753698AbeGBJTE (ORCPT ); Mon, 2 Jul 2018 05:19:04 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:10422 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753009AbeGBJTD (ORCPT ); Mon, 2 Jul 2018 05:19:03 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie2.idc.renesas.com with ESMTP; 02 Jul 2018 18:19:01 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 7DB1F8E948; Mon, 2 Jul 2018 18:19:01 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.51,298,1526310000"; d="scan'208";a="284197698" Received: from mail-ty1jpn01lp0175.outbound.protection.outlook.com (HELO JPN01-TY1-obe.outbound.protection.outlook.com) ([23.103.139.175]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-GCM-SHA384; 02 Jul 2018 18:19:01 +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:X-MS-Exchange-SenderADCheck; bh=ZL6QcYbhVM9uEMyXsRCl2lYyrW5mziThh2KBfDn+SA4=; b=Fbuoj2I39alBDtwLiSw6epFvoVt7AcfrUiGlzgc4buobsfg410FZbMB0WnRslU6a2+2vaIg67kpB1Vwl6qLUc75/ye8omJc6LL8vyJ4MzYsseJbWoWKXyw6BvP4/ehG2g1amLCAmWOKZ9wupNj+0Nauz/aoLkMcWm91nGxaQJoY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost.localdomain (211.11.155.144) by OSAPR01MB2292.jpnprd01.prod.outlook.com (2603:1096:603:1c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.25; Mon, 2 Jul 2018 09:19:00 +0000 From: Yoshihiro Shimoda To: vinod.koul@intel.com Cc: dmaengine@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH] dma: sh: rcar-dmac: avoid to write CHCR.TE to 1 if TCR is set to 0 Date: Mon, 2 Jul 2018 18:18:03 +0900 Message-Id: <1530523083-2106-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TYXPR01CA0063.jpnprd01.prod.outlook.com (2603:1096:403:a::33) To OSAPR01MB2292.jpnprd01.prod.outlook.com (2603:1096:603:1c::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6d24d3f5-3eba-445f-785c-08d5dffcd89b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(48565401081)(5600053)(711020)(4534165)(4627221)(201703031133081)(8990107)(2017052603328)(7153060)(7193020); SRVR:OSAPR01MB2292; X-Microsoft-Exchange-Diagnostics: 1; OSAPR01MB2292; 3:myHo74KU3dowSkTDBqd97iDdbTbgdmobGEIfRmFtbEFT6m6ttqc8WNr8loi8q4gOiOnT1knMDjn/KcRQKdHUwo1zE9yc5zQwXSchN5Nk9nIe0NfOE9jnS3rz+9V2sJA0NyUXkl9n2uX9My/bhgjXxxIEw5lO94IdlqTPE+xdpEvaZ6d/Ni9CaMy0POQG7sH6X1N4yU/OFuYlbBL84MWWujyjW9SNDfqCo5RKOEBlbgOrl35tgHjDcrq/1Ku6j79E; 25:sspfxQh5iHLlKfps9PcpdIsoQrmmNlet2gcXCPrprk/FBBnkrZOWWFxyCb0hdcewMQVQL2/HHqYHQdOpRGuy0dIha2AG5n+MOqljGLDDvkQRSyNP7x7+6fNhoYL23m1mcbG/TgL3fZ+9T9Qzwb16VbUieyKcPzbRzsrs7w277fiy09ViBomy7zdl1o/pxCeabbAK2rFZc1NOO9OvFbojOkmqy8Et4y9jAqOXm7taoeukTPtSD4htlP9deJOsTAV1SNdJ+MZkViBd2MezRdq4DrACDsRSdyMD33FscoxK2ksFIrWVRyMWK8dLLYiDJSbPxVYIsDz64+EFArVec9NShw==; 31:pGYmwwccsPywqO0LOhlWG/tDuexWAxImwx3VRS4ppaqnVI9LZUH5R9PhQdhlv+0zr7yWNVdu1+8pj9hhpjMsFyzW3JFljEjLCyVBohCbgi1CamgAIuXYUxbYuW03ZJuj2QwGFM2XMRXaDtVZ5PZpLzfN9eWnp9rRGvMr7EEQDKTnn0KROMjgLkz2+RWlPFWVwof2fiLY2I/gMDO2hRrzM2VRw7m3QgcOPk4WnLjJpTk= X-MS-TrafficTypeDiagnostic: OSAPR01MB2292: X-Microsoft-Exchange-Diagnostics: 1; OSAPR01MB2292; 20:aTK/IIyZVWmBKn3cZSeRfq3KVU/phN9gSN3iy/7wAxvjY0CdiZDvjrWSHGlgwJR2bP52zCINPaNKvRBP6AD17NoMHIBd6tU1u+AlRMxJGEcpR7sPV7XuEYL+oB2NZQnPSCInAaqtxRgeHNG+kxHse4D8zKT0fOWq/viU/XgCkHyT3qtOds07bxf30Q9ln3OYSWOyQwUXyG9jqoSy02CczwGa030o6Q8oF4/LVg9eMynR3dwB/VEBMHIFOW5FLZ1NfmyXDqXHVZbQ1DAUBzMeE6K7cMpP7NjlxxpoJfRZl3eENKu5UTZt1T0Q2sGfGERfou+dSxrvhWyaikexgV7TaoX6NEycVYAe9iFZIsxejZ+481KlPWM4wljTOe7tFOmlFKskDB26+Dir6Irv8w+q97GqJW+7iDfc/NcWzHNMsM037rnwx1QB7u3W+NH/tf1MBPwe89H9UOCslD0/HT8zZE+tRcdzzeAFoock5Q2KpjRYtS1Q8wjV+tFDVYnWF2eZ; 4:bZXiIFOfJhI86hAbPxphER6xFkKiQTKsAfIipyR4PbY3PGMTOSYEl0b9laGIwtr+WUfccrJey4lCEUUa4hH0pwpuzTJkNWZjIawWG6OpdJJSA0pGaBzwZ2foe03z0i2y+EBdZfb04rQ45dqjZdFJF35ZJC2wQdw2um8BpXOly/tXnlBA+mTVIpG8FcvmOle2IMXWTGUkvpXKsJDLogK/IciuMEyv702zQiftfBe1E4dVKTLdLVVAjRAzJU+DILMceCqZ7fcqWEJYr8SjuMq9aw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(3231254)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061750153)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:OSAPR01MB2292; BCL:0; PCL:0; RULEID:; SRVR:OSAPR01MB2292; X-Forefront-PRVS: 07215D0470 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(366004)(39860400002)(346002)(136003)(376002)(396003)(189003)(199004)(78352004)(66066001)(8676002)(42882007)(53936002)(498600001)(106356001)(36756003)(81156014)(81166006)(105586002)(107886003)(6486002)(575784001)(50226002)(68736007)(47776003)(6506007)(2616005)(25786009)(305945005)(52116002)(6116002)(16586007)(8936002)(6916009)(316002)(5660300001)(6512007)(50466002)(2361001)(486006)(3846002)(386003)(48376002)(7736002)(51416003)(16526019)(2351001)(2906002)(476003)(956004)(4326008)(1857600001)(26005)(97736004)(3720700003); DIR:OUT; SFP:1102; SCL:1; SRVR:OSAPR01MB2292; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:0; A:0; Received-SPF: None (protection.outlook.com: localhost.localdomain does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; OSAPR01MB2292; 23:TP5FvA7tpIS0pjbJQ6h17aOZ5pt/WlwoxpQ3gFU3y?= =?us-ascii?Q?GdDPBfMvLx3pkkjMZxYtI60me8I0utAMiHKLEgCOTDl+FcrGC46Z7U+xiFoR?= =?us-ascii?Q?J2ZvB88wJSl99GzM9X5mM/3zXSbkUmsEnlBdJOdjBtObl+pQRnlPGRwHzJkX?= =?us-ascii?Q?EAvgZR7At5vOIA14FcHJ5/V6cY6J8cuZ9a7gnWNWayfOmGKKXZ/94p0O0LDj?= =?us-ascii?Q?IR3bsLEne6lSGzK8fpeN/4gn4/Sv5CGiyYKWzTW37LsTWMLPXY9xYbnYMOu2?= =?us-asc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b59eDMcOHjAibX7Rbc6lzggUT/QQOEew7bkLTLnvwnqhk8G15gKd9wmXMASgFQn4gw7uKALUjys9As0YmEU5jrIn6mfw60kwgEBuMN4V7FunZtk3zY83R2AA17HnUg=; 24:XoOv8r0ZSIUXVbGF+EW6NtXsL2wZTq89G+3/AtNOJORqWui4euQspV5ESelmycEYD/VTO0cOi8y4jXOxnGGS0EFFrlqy/hVt7oiKfVSWf1I= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; OSAPR01MB2292; 7:PJLeWeNNJyLgZJEIQVuRxWWLfPX6JqaT+Y5iZmvOswoZ4FA6ITt/HgIW8kfEIhFHYrSNBPwOYli6M8oarDQjFYrc423V85nHn0yDfClGyB70DDK1SMdldHTtKG3VgIAc4dM0JZ7pjH20qFRlJk+pg9KXMxFdzt95fNtNaMwT92I6OS/5exGrkDj5yUNfMkKhjEv8Gexn4siA5trw0U6qEIP6X02kiJfizG9pEXUE7h/C5rwJWo3dh+ixpwQKS6jI; 20:+TlJrVb4M7S7zK0yMFvChdRquhMzElaOYtSB/vedR9dMw/n87zVrDx21nP92OM7Tq7JJGUQe5Gcuw7OYCeZQKXhKXrpT28PwT1cjzD2TybHscrj46eOkovEP6+85gQ3beaZAW0MqEYTmPXwDC0u9WB2tS5C4rBz7zoDSBieGiYs= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2018 09:19:00.0675 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d24d3f5-3eba-445f-785c-08d5dffcd89b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSAPR01MB2292 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes an issue that unexpected retransfering happens if TCR is set to 0 before rcar_dmac_sync_tcr() writes DE bit to the CHCR register. For example, sh-sci driver can reproduce this issue like below: In rx_timer_fn(): /* CHCR DE bit may be set to 1 */ dmaengine_tx_status() rcar_dmac_tx_status() rcar_dmac_chan_get_residue() rcar_dmac_sync_tcr() /* TCR is possible to be set to 0 */ According to the description of commit 73a47bd0da66 ("dmaengine: rcar-dmac: use TCRB instead of TCR for residue"), "this buffered data will be transferred if CHCR::DE bit was cleared". So, this patch doesn't need to check TCRB register. Fixes: 73a47bd0da66 ("dmaengine: rcar-dmac: use TCRB instead of TCR for residue") Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven --- This patch is based on the latest slave-dma / fixes branch. This issue can be reproduced by the following commands on r8a7795 Salvator-XS and Windows Teraterm :) : # stty 921600 (Change Teraterm baud rate) # cat > rx.txt (Send 5MiB file by Teraterm. After a few minutes later, we cannot input any commands by the serial console.) drivers/dma/sh/rcar-dmac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 2a2ccd9..8305a1c 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -774,8 +774,9 @@ static void rcar_dmac_sync_tcr(struct rcar_dmac_chan *chan) /* make sure all remaining data was flushed */ rcar_dmac_chcr_de_barrier(chan); - /* back DE */ - rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr); + /* back DE if remain data exists */ + if (rcar_dmac_chan_read(chan, RCAR_DMATCR)) + rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr); } static void rcar_dmac_chan_halt(struct rcar_dmac_chan *chan)