From patchwork Fri Nov 17 02:00:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10062243 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 8669E60235 for ; Fri, 17 Nov 2017 02:09:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72D462AC7D for ; Fri, 17 Nov 2017 02:09:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 664182AC80; Fri, 17 Nov 2017 02:09:26 +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 A6ABA2AC7D for ; Fri, 17 Nov 2017 02:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755410AbdKQCJZ (ORCPT ); Thu, 16 Nov 2017 21:09:25 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:16222 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754930AbdKQCJX (ORCPT ); Thu, 16 Nov 2017 21:09:23 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 17 Nov 2017 11:09:20 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 10D2D6C4E6; Fri, 17 Nov 2017 11:09:21 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.44,405,1505746800"; d="scan'208";a="262517873" Received: from mail-pu1apc01lp0016.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.16]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 17 Nov 2017 11:09:20 +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=On204IJK3771h3jU7vlwJIj4uHlpNHu8pAAhLnZFmBw=; b=mgKdTc7odK6eu3Fz9e45BzGhpzTIw8SYC8NmHoZOvvzTcHJJpP1IQOdP6UfVYjb0ykPDEC5VRkLyxcJMxJkfQNySbdkVcuVTEUyS4HYC9GWp44Jencj2ij03Zgqkg6hOT7GA/9Ynre9uV60MVV5XmrcKsWGCnpBMaMC1dNf3F+Y= 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.239.5; Fri, 17 Nov 2017 02:09:16 +0000 Date: Fri, 17 Nov 2017 11:00:28 +0900 Message-ID: <87fu9dr7er.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/2 v3] dmaengine: rcar-dmac: ensure CHCR DE bit is actually 0 after clearing User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") 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 In-Reply-To: <87h8ttr7ge.wl%kuninori.morimoto.gx@renesas.com> References: <87h8ttr7ge.wl%kuninori.morimoto.gx@renesas.com> X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: SG2PR06CA0090.apcprd06.prod.outlook.com (2603:1096:3:14::16) To PS1PR0601MB1881.apcprd06.prod.outlook.com (2603:1096:803:8::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4bc06485-77f6-4ce9-6ef2-08d52d60356f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603258); SRVR:PS1PR0601MB1881; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1881; 3:TluFmZW3HHHypzfCMAfji0lfqcxfNKyX4rI6PjPlnAbJmriCAqGpH1CAbvBAg3Nz77qmNpeZGlYJISuPSld84xgsaeTSZxNtt5VIbi/GySS0bbQmk8EHr+e0B2iYfhlpcYCphyL8fKaoxXSFl8t5vBC7e5kXmsUovwma5rERAm/w6URDxs0KLYTXDzYfKisIylpODUIlgP2pJzgmsZ7RFjumnnBFkAnvdwkYAEjQMNRF/aeyb8Y0ClkQAfq7jpZ3; 25:/S/m6ggDWnEuqx9yEWpmsAYE40ccs1lDJlHtOvFyIWe7jUGqDrtaSolo1I5Y+OyJknZSuazXFaqa5oJXBy1H8JxvWw2borJVDi9+nndZquGKwLtxOBcLkERfCdX4kpMCacw1VEp8sWdHduGCS2uzcd9VIPTVghr925TcZk0kCrJVpfW11gT2NnFawZW1SILAcu8ZO6t9xZOygy/zWM3VH4oiFSZXeVeBygZTC7MoRzWejxp9ZfKHz1lmcwXOQH6XiP/t8Cy+CkedJkgUzgXM0Mb/LSePRt7U9VUAos9H36cPq5Yx7DqWXAEu+BMR99FJJzPaAF6Oh3pNoWGY6NEQxg==; 31:YF/F4qLva8/FFfNQbTvQZD7MArqUsiG0OkZ7lw5SPZ/zLdm/ZN9ZV+0yJ3r6G+VAlL7EGTKAKTZt1cUTJX2zBKkzHxM3molUfchgOvsXbFnxJS/I/6WbhX7vg3J1E+qQlrRAeESgyHINjksfH6a1zZYwbmDkGeBoFCBR2ITyV9Mq8T/tUyUDnqriuMEsG8t1/CI7SybrACuZamvT5sgvXCf0JQNpqZ3nWaiXJLeflg0= X-MS-TrafficTypeDiagnostic: PS1PR0601MB1881: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1881; 20:LeMQz9VU6lwpKpVmw3kzGogsCbLNXRDWRauuVMOVgGclbNrTcr2TFwZoQgdDQeNTQmSWr3dJLl+9G1iqHS8iKpYCoBuDVp5PqvZ2gRIjoE/pYKRNatvIxQUFjXcaBoWkRJ1PlED6K1s4BFhqASxmjAlZAJy4GDgwsfeRbOzncW5XYS6/2fXUwRYb2kxAriVKKJcJzc/Es6ofpXNlWyrMd1avOcdCBACCehcXWLpwmzMTjswzLOipj75A2dHMq9O+fZzpeahshuQxr+Ib0YpujpvvRUe/LZ2NTIwmhdznaP5mxQVMVzcun02AUPd2q2ISbdD6Gl5D7mWl3aTjmcJJvivGODDDLi/Ic5ktIXIeMhrSzxNHRbJ3rV8Kne5X0QJBs2kIaIb0RRCTj9jMM8Wew8xHeHIt5ow8YxokTtRU2mYitWtMN9mCq5MubYrdT6/XAFwx0wnGLtpfmOlmEGs958uJrWHzIAm5pSooPIAJTiiA2euI4UyDTBy5Pr1aB1N5; 4:vv08JPXDl9zneYkukuJSW58PKZ14FI3BU3buZouB67/oQnxhMd++Imx3vXWco3hOqoSkqTlyVvcCHYTtpbpb1bzbooeLqSL/0pTKrLKNrWTvU5yUTL+HbAacDemCun9vTP+6KQCoxeHJBVlHus/xG6uXArh8Wsg8wo6nj59h0FNZT1J0RxitXtqdm9GxtMh4PJiqgq0Jel7tCqYX7sI/6Ir+z2d5ExCnHHrTQqmCA+pRv7LnbDzVOQqRxS3yMvScfoFQAwhHOiGotmE31z2vBA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(100000703101)(100105400095)(3231022)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123560025)(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: 049486C505 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(346002)(376002)(39860400002)(189002)(199003)(7736002)(8936002)(6666003)(33646002)(2950100002)(68736007)(101416001)(83506002)(53936002)(8676002)(478600001)(81156014)(81166006)(189998001)(305945005)(50466002)(25786009)(6486002)(4326008)(69596002)(2906002)(66066001)(5660300001)(53416004)(16526018)(107886003)(97736004)(76176999)(54356999)(50986999)(36756003)(110136005)(54906003)(105586002)(575784001)(6116002)(86362001)(106356001)(47776003)(3846002)(16586007)(58126008)(23726003)(316002)(2004002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR0601MB1881; 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; PS1PR0601MB1881; 23:0zQEgu07e243NYIXkIPAt7elm/yNTFObktAbwep?= =?us-ascii?Q?GcEBqJuuZEooV6hiu8ScY29/jUqj9cGer2ohMObPqtWX6lKORpyY5io7ml0D?= =?us-ascii?Q?NELq7xKnTkg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JE2NiskYEJIAh5yVSQG+BZVnbeXkxGi9voAizw8VzEGq4rdk+lxTsTojq0zfingxsMyslWEr2pw5WCKGZa4UJOesCLI/ijV+mmK6N1mGqKDhOoWxNiJmsgkPqbKCWf7IqCtCAiibowCbW1dwZLgDaEAc5O8pcecdVjIlK8hARmgVU+TWZz SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1881; 20:ojEBscg355gRI3l4eO+KwEer5KJX4ZfcxnmpyccqQu3q8KBst00kR9KFiMTYGM8DLKuPtighASkWUdRkjDUd1WTXzmiYe2QpMxuS+e+dNfc3gp3o8Lri/d2ADa57CAp4n0ncLWdI5AwHvzPA2gsKGTky+6sXLyklD3HC+z8ZXS0= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2017 02:09:16.3461 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bc06485-77f6-4ce9-6ef2-08d52d60356f 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: Kuninori Morimoto DMAC reads data from source device, and buffered it until transferable size for sink device. Because of this behavior, DMAC is including buffered data . Now, CHCR DE bit is controlling DMA transfer enable/disable. If DE bit was cleared during data transferring, or during buffering, it will flush buffered data if source device was peripheral device (The buffered data will be removed if source device was memory). Because of this behavior, driver should ensure that DE bit is actually 0 after clearing. This patch adds new rcar_dmac_chcr_de_barrier() and call it after CHCR register access. Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama Tested-by: Ryo Kodama Tested-by: Geert Uytterhoeven --- v2 -> v3 - fixups many typo on gitlog / comment - added Geert's Tested-by drivers/dma/sh/rcar-dmac.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 2b2c7db..c99fd0f 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -741,6 +742,24 @@ static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, /* ----------------------------------------------------------------------------- * Stop and reset */ +static void rcar_dmac_chcr_de_barrier(struct rcar_dmac_chan *chan) +{ + u32 chcr; + unsigned int i; + + /* + * Ensure that the setting of the DE bit is actually 0 after + * clearing it. + */ + for (i = 0; i < 1024; i++) { + chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR); + if (!(chcr & RCAR_DMACHCR_DE)) + return; + udelay(1); + } + + dev_err(chan->chan.device->dev, "CHCR DE check error\n"); +} static void rcar_dmac_chan_halt(struct rcar_dmac_chan *chan) { @@ -749,6 +768,7 @@ static void rcar_dmac_chan_halt(struct rcar_dmac_chan *chan) chcr &= ~(RCAR_DMACHCR_DSE | RCAR_DMACHCR_DSIE | RCAR_DMACHCR_IE | RCAR_DMACHCR_TE | RCAR_DMACHCR_DE); rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr); + rcar_dmac_chcr_de_barrier(chan); } static void rcar_dmac_chan_reinit(struct rcar_dmac_chan *chan) @@ -1481,6 +1501,8 @@ static irqreturn_t rcar_dmac_isr_channel(int irq, void *dev) if (chcr & RCAR_DMACHCR_TE) mask |= RCAR_DMACHCR_DE; rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr & ~mask); + if (mask & RCAR_DMACHCR_DE) + rcar_dmac_chcr_de_barrier(chan); if (chcr & RCAR_DMACHCR_DSE) ret |= rcar_dmac_isr_desc_stage_end(chan);