Received: by 10.213.65.68 with SMTP id h4csp13610imn; Mon, 19 Mar 2018 17:54:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELui/nISXfsQ8kEHSqGUTOzBNLdpkRLoI0Q1RA6tW1UrnvsDyFSs/R6FGRdHLwhiwTCUj60L X-Received: by 10.101.83.75 with SMTP id w11mr10370187pgr.197.1521507282616; Mon, 19 Mar 2018 17:54:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521507282; cv=none; d=google.com; s=arc-20160816; b=OHz0s+U+SB7lyOP0Ngfe9Y64k3RF4rv7jZ1jbRgVAWZVqX8OPFdFFYma8TsBRxSoRE mFjRGjGMBbrNOJrutvL664jwpgNajIHsCtGhJuzGqY6isUe/dZgJ9sUgEeHaWW5rOSjD y+cWDR/3qg/7soSaEMRAvt8XycppsuQXbv5qp9fXPG9rGf8Zg7N5yLE5W2L5mPMV6A4x DHTE5QTdyH3vbY6KHlfqp4eWkIeWYt+4/VHQSp6WRVd4yB0ZsNmzmBqEswk209uCs18p mIyrgWOLTv8H2prZN5H6f+MXl4D4g6i4V6Yr34DDPLljXgXxkxmpXbXXyyy+nvzZMcj0 2zWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qvGFm/A+7YBfH9zgKjsnE/CztR9yCwhVjYLh0cNN698=; b=fvHSwL6bn73FNn67CfMtdAiAxDL3tYv19Ogp+fyZm3ytcZ1LFKRrs5uwqtRHWWDXA1 Sbrbw4tYhE6y3DM1+hjCTtnxnpRmHdSXqnJ7kUWYmAGdVC13fCfUJwpmqke51nAlUqpZ bumEm7R8Xavat9mbJEbEvauUnPUZZwxAVgSUbL2/hoyxOuhqcR8jsXNpuZiu1l1OIGU+ WG8UVLME7/H+dzMd92kQbxCviv96dQvz9FVThz+3sbS/gx7HR/wMueM9jF52detE3MC3 EJTSkyP/umHh0WZOtMZylgmzfVcJDhvFswpoCeQtL5eR0Ogkiyx5/p6yAo+Nbwu2x7wz LH0w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8-v6si440121plk.305.2018.03.19.17.54.28; Mon, 19 Mar 2018 17:54:42 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031280AbeCSSW3 (ORCPT + 99 others); Mon, 19 Mar 2018 14:22:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48516 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031219AbeCSSWW (ORCPT ); Mon, 19 Mar 2018 14:22:22 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 935721296; Mon, 19 Mar 2018 18:22:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiada Wang , Vinod Koul , Sasha Levin Subject: [PATCH 4.9 065/241] dmaengine: imx-sdma: add 1ms delay to ensure SDMA channel is stopped Date: Mon, 19 Mar 2018 19:05:30 +0100 Message-Id: <20180319180753.893514315@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/dma/imx-sdma.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -937,6 +937,21 @@ static int sdma_disable_channel(struct d return 0; } +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 = sdmac->sdma; @@ -1828,7 +1843,7 @@ static int sdma_probe(struct platform_de sdma->dma_device.device_prep_slave_sg = sdma_prep_slave_sg; sdma->dma_device.device_prep_dma_cyclic = sdma_prep_dma_cyclic; sdma->dma_device.device_config = sdma_config; - sdma->dma_device.device_terminate_all = sdma_disable_channel; + sdma->dma_device.device_terminate_all = sdma_disable_channel_with_delay; sdma->dma_device.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); sdma->dma_device.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); sdma->dma_device.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);