Received: by 10.223.185.116 with SMTP id b49csp1069392wrg; Sat, 3 Mar 2018 14:41:18 -0800 (PST) X-Google-Smtp-Source: AG47ELuCjLZJQt2p0ChhFQg4byVJXPntJvRi49C9Unm0mfWOU5oM9KBWCdRXJF7/Ex5NqTQo3ZOv X-Received: by 2002:a17:902:4601:: with SMTP id o1-v6mr8890649pld.210.1520116878395; Sat, 03 Mar 2018 14:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520116878; cv=none; d=google.com; s=arc-20160816; b=03aDFcFuyeIIBQtpR0AOzFpVRHRx1b9pqo6Nz8LQa83B85apHGEn83Gk3S1satgi0g /sCt5IcAdbIYXFDzCPmV0WDi7NO3fhJRq3ejvF8K6u9FDcsSQKf+Y/eQ281RVVhM93Xj G2Zp+yjiDQfo98dQBCKileEMisDYViWAvhXXa1XafROsAXnVBZuceRTvuh3YPGDBsjuJ IHQG4XZUiDXqcNmGG43s8b6V4jSmbfQOcVuO/yyFIUT/Ov65XkSL+lccWgeftoduCGSH ClLZiMqkhSYCf3DJQIimkW1KmZtwqsjbU6VdkbnIVAq3qR5HloaeN2pegYhVf5PWuEFe yUxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=yVjjtiWKWqy3obQLuTNG71Kkl88vrfeNYNa3D5P2KC8=; b=ZerT16cvX1rPfDIE+k2lwCNbMvEolxySSWcUgH9KaZltVC/2pDIY1vRaAjZuP4S1L0 WdFxIL9/nybXMczjEL5vPmA/pzESyFkJC0IxQz2vsgHRzLMQgSBKqHSRxRfzRZm4XsqE ZLSqe202GDMoHUEe9ROdfd5lzB/aVk6TV2euXfRYcEcKpHyBWVCJfztqerzxRQvefEvk 4EwtHsSDZllM1pb5EKevJXhrq+HftqDTQXVRXb32sk0gjnNpRXoGrUcTyrsm75PiDHXd aH5dPBpYw5ZdLie7xHhLy+YuN0HZ8UFfGYIjCcYAyF6Kdy+LA7Os2MX/vdNGaiAIQjgz JWOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=megSsTKE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k185si6096690pgd.533.2018.03.03.14.41.04; Sat, 03 Mar 2018 14:41:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=megSsTKE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935036AbeCCWjL (ORCPT + 99 others); Sat, 3 Mar 2018 17:39:11 -0500 Received: from mail-by2nam01on0114.outbound.protection.outlook.com ([104.47.34.114]:65056 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934197AbeCCWjF (ORCPT ); Sat, 3 Mar 2018 17:39:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=yVjjtiWKWqy3obQLuTNG71Kkl88vrfeNYNa3D5P2KC8=; b=megSsTKExKGFfkOOztqfBiLJS9soggQ8iVBj3xeQGcA9VtM3q4RjFfuYWRW1PK5sFwi7wXT0xmSTL/d5ZHotgq3Cwn25AUNWJCAnR7NNe4l2+5LRotOPnPj8PkLsWaBRA/kK2fqrbGMhzFhho9zaIMHqojP3MyOOHevtgbiQm/s= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0938.namprd21.prod.outlook.com (52.132.146.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Sat, 3 Mar 2018 22:38:43 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:38:43 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jiada Wang , Vinod Koul , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 034/115] dmaengine: imx-sdma: add 1ms delay to ensure SDMA channel is stopped Thread-Topic: [PATCH AUTOSEL for 4.4 034/115] dmaengine: imx-sdma: add 1ms delay to ensure SDMA channel is stopped Thread-Index: AQHTsz9TOm0n6iIbGUKC+14bBirp9g== Date: Sat, 3 Mar 2018 22:31:08 +0000 Message-ID: <20180303223010.27106-34-alexander.levin@microsoft.com> References: <20180303223010.27106-1-alexander.levin@microsoft.com> In-Reply-To: <20180303223010.27106-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB0938;7:qI9FdGlvv+Of7cCS7N8Z1Cb06ORJYKbaLupZkAubWGA83gnHTAZ+04LOsKo9MJPVvfFXfhbMjW65xPbAOzeW43GN0MJ5nbvO7+5gx9+tOR62vSS8DcjP3XWOb1pUKkydtPaIj8F8lMJ74q/3DpBQ21fUP91HrX6azSnDYk/tQ8pJI24u8SBZJZ4NvpXmXJrPeFL6KF0txFEtq3qwKJjvejk68Z4b4JtkNwJWRo6Xp0IKC52cCQR3gsyEFwY5bFVq x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 744ff752-ff81-4fee-86e5-08d5815784a0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB0938; x-ms-traffictypediagnostic: MW2PR2101MB0938: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231220)(944501244)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB0938;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0938; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(366004)(396003)(346002)(376002)(199004)(189003)(54906003)(4326008)(72206003)(22452003)(478600001)(25786009)(66066001)(6436002)(6512007)(14454004)(53936002)(2906002)(6486002)(105586002)(99286004)(10290500003)(3846002)(106356001)(6116002)(305945005)(5660300001)(110136005)(1076002)(36756003)(316002)(2900100001)(2501003)(5250100002)(10090500001)(59450400001)(102836004)(68736007)(2950100002)(26005)(97736004)(186003)(6506007)(8676002)(107886003)(3660700001)(6666003)(7736002)(86362001)(81166006)(86612001)(81156014)(76176011)(8936002)(3280700002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0938;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: LSscY1DIj61dWkSuf1P0lx0cQbH9hQJbiCHkMSC9F3HVDzEAdYT24+V5zOQNq6sj80I1PbjzAKRh+T4OPCAhBs4UgP8sSSQZg2r0II5SjbobJvq1CMNo9oqmCm7vbEmN2TpYlPPGogWX/1+afth1wRst5jLMIXJhOxP/SwPKq5k= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 744ff752-ff81-4fee-86e5-08d5815784a0 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:31:08.5884 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0938 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiada Wang [ Upstream commit 7f3ff14b7eb1ffad132117f08a1973b48e653d43 ] sdma_disable_channel() cannot ensure dma is stopped to access module's FIFOs. There is chance SDMA core is running and accessing BD when disable of corresponding channel, this may cause sometimes even after call of .sdma_disable_channel(), SDMA core still be running and accessing module's FIFOs. According to NXP R&D team a delay of one BD SDMA cost time (maximum is 1ms) should be added after disable of the channel bit, to ensure SDMA core has really been stopped after SDMA clients call .device_terminate_all. This patch introduces adds a new function sdma_disable_channel_with_delay() which simply adds 1ms delay after call sdma_disable_channel(), and set it as .device_terminate_all. Signed-off-by: Jiada Wang Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/imx-sdma.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 0f6fd42f55ca..f8d740a6740d 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -911,6 +911,21 @@ static int sdma_disable_channel(struct dma_chan *chan) return 0; } =20 +static int sdma_disable_channel_with_delay(struct dma_chan *chan) +{ + sdma_disable_channel(chan); + + /* + * According to NXP R&D team a delay of one BD SDMA cost time + * (maximum is 1ms) should be added after disable of the channel + * bit, to ensure SDMA core has really been stopped after SDMA + * clients call .device_terminate_all. + */ + mdelay(1); + + return 0; +} + static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac) { struct sdma_engine *sdma =3D sdmac->sdma; @@ -1793,7 +1808,7 @@ static int sdma_probe(struct platform_device *pdev) sdma->dma_device.device_prep_slave_sg =3D sdma_prep_slave_sg; sdma->dma_device.device_prep_dma_cyclic =3D sdma_prep_dma_cyclic; sdma->dma_device.device_config =3D sdma_config; - sdma->dma_device.device_terminate_all =3D sdma_disable_channel; + sdma->dma_device.device_terminate_all =3D sdma_disable_channel_with_delay= ; sdma->dma_device.src_addr_widths =3D BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); sdma->dma_device.dst_addr_widths =3D BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); sdma->dma_device.directions =3D BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV)= ; --=20 2.14.1