From patchwork Thu Nov 16 04:33:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10060707 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 EFB13604D3 for ; Thu, 16 Nov 2017 04:33:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E120A2A759 for ; Thu, 16 Nov 2017 04:33:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D59C92A75B; Thu, 16 Nov 2017 04:33:52 +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 54FDF2A759 for ; Thu, 16 Nov 2017 04:33:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932995AbdKPEdu (ORCPT ); Wed, 15 Nov 2017 23:33:50 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:39819 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756304AbdKPEdg (ORCPT ); Wed, 15 Nov 2017 23:33:36 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 16 Nov 2017 13:33:33 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id DDFBF79B63; Thu, 16 Nov 2017 13:33:33 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.44,402,1505746800"; d="scan'208";a="262422187" Received: from mail-sg2apc01lp0245.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.245]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 16 Nov 2017 13:33:33 +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=u31GB2TjYmZDO5kZ6UaMyaRnFzFCdeDPCaHztr65MJY=; b=YpBtC/wVv+60qPi74re+StT9MCn68tUzoV/eHx4rnBuWEbFKjXOUywDGByb85Hp6Nu4wUdfU4eBwavxsHtWDhHX5FE4HCq+ib/BOJkkK01SzoVnNegnNv9UPMtcxZ4ZxlfbKyjYOMASBGq819EdG6Z386WAUoR/WVfGb6YFeEx0= 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 SG2PR0601MB1885.apcprd06.prod.outlook.com (2603:1096:3:9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12; Thu, 16 Nov 2017 04:33:30 +0000 Message-ID: <87o9o2g8ab.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/2 v2] dmaengine: rcar-dmac: ensure CHCR DE bit is actually 0 after clear 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: <87po8ig8eg.wl%kuninori.morimoto.gx@renesas.com> References: <87po8ig8eg.wl%kuninori.morimoto.gx@renesas.com> Date: Thu, 16 Nov 2017 04:33:30 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: TY1PR01CA0168.jpnprd01.prod.outlook.com (2603:1096:402::20) To SG2PR0601MB1885.apcprd06.prod.outlook.com (2603:1096:3:9::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 41d7be5a-5fa5-4d78-0766-08d52cab30c8 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603258); SRVR:SG2PR0601MB1885; X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1885; 3:pY+I8qU/DuN3H9vWT3kYgmbTEwX59dCg9WbNP+W0LrKdZeu1FmyQa3hjBIVPTXnAIYJGpgpmHaxsExX1JffZ1aP0MqNolLgfqbpjpSGVFWfslxJ9zdfFcD2oMk2xcpy2spvh5m07cpdzwO9noyXh4asC3PuIdOZJgMpjBjwYheMv5XR2qjVVGAhfYaBVQe0hFMacuJU3I/kldWXlO4Hm7g3uqIzv1vzOMnFu/m4ipV2fSsJ6ftyjWEQigXlA2EML; 25:0afcauRf7wPTg1y9K21dY7X32ksYGZQkRWRFCi5smKw2Zkq2/EqYlhELLQ1RQr4GICT3DGnhGtKKqhfig6S5/93mpOVxq1luVQEwlpD2EnHgroAvh6sUYdqkqKofKsYe8kc3s/FiQvGTEu5LVp8VeXD/mkD2qQ7Lo5DdZqyv7KRhoC2jLLc/x0CQ/HOD6uSYiVFYTGvev01DYQO0bXdr5H8GrcPE15qE3uaOvhUCYjcQ0PP1b5+U8F4UJAPn/29l3TLQGDWBhjj+8o+UlDxQbvWfB5AHnhZoB5Lseg+shwEl7E8bAFX+MUNZDfCStTa0l3gIiseX2zBBLmBJOJvXGQ==; 31:soTnhPXBOTBNPeEz0iq9ciSjp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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)(8121501046)(5005006)(3231022)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SG2PR0601MB1885; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SG2PR0601MB1885; X-Forefront-PRVS: 0493852DA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(376002)(346002)(189002)(199003)(8936002)(83506002)(5660300001)(81166006)(8676002)(81156014)(6486002)(50986999)(106356001)(105586002)(2950100002)(97736004)(16526018)(54356999)(4326008)(53416004)(107886003)(101416001)(23726003)(33646002)(3846002)(50466002)(76176999)(53936002)(6116002)(66066001)(47776003)(36756003)(110136005)(58126008)(16586007)(54906003)(189998001)(7736002)(2906002)(316002)(305945005)(69596002)(478600001)(68736007)(25786009)(86362001)(2004002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR0601MB1885; 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; SG2PR0601MB1885; 23:PSooGRlZfGNH9VKQ9K7sT7CrocV9pPRSRd7o3xU?= =?us-ascii?Q?lgWKQf1NKX2gToc0pidijtys7Pe59EU4OqjfB+ER/Hgst8DRtcBZzRFqnwRa?= =?us-ascii?Q?8ylEY0VodYLM1KwMTljBvaBWNzR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Z7PoucLF0giEjsA7uy5rqGodwbgRTFj+Ep5lsQXWMTX+C/lrQSH36KUEtbUP27Fp0Z6Mx3h/WWiuTGNJwVkoAJ+tiomGJz2Yq5Tfe2azQNv8ePe3CoxHqyjgCwkPhB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1885; 20:sihTGxDg7vXfMrzkcmLNvQXEDBZ2ZRkIEt8WLDdsRbk5W+Cq/lELOGdV+MZCHkwvSi09k/XUx3DMPbYyB90J2aL5X9mT2yvb08r1X03pXjLdG5OVvK5TJpL36BnvDxmJAagP95d8mrpYdaJ8CyEFtfj+YbSCLF1ANcgQRcvQ/PE= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2017 04:33:30.3957 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41d7be5a-5fa5-4d78-0766-08d52cab30c8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR0601MB1885 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 shink device. Because of this behavoir, 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 cleared. This patch adds new rcar_dmac_chcr_de_barrier() and call it after CHCR register access. Tested-by: Hiroyuki Yokoyama Tested-by: Ryo Kodama Signed-off-by: Kuninori Morimoto --- 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..16ebd5d 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; + 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);