From patchwork Thu Nov 17 07:53:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9433603 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 B1DE76021C for ; Thu, 17 Nov 2016 07:53:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3282292C0 for ; Thu, 17 Nov 2016 07:53:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9806C292C6; Thu, 17 Nov 2016 07:53:56 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 DC65E292C0 for ; Thu, 17 Nov 2016 07:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752307AbcKQHxz (ORCPT ); Thu, 17 Nov 2016 02:53:55 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:59351 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751567AbcKQHxy (ORCPT ); Thu, 17 Nov 2016 02:53:54 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGS00WZM0LP1F60@mailout2.samsung.com> for linux-mmc@vger.kernel.org; Thu, 17 Nov 2016 16:53:49 +0900 (KST) X-AuditID: cbfee61a-f79916d0000062de-50-582d620d2cd6 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id FE.DF.25310.D026D285; Thu, 17 Nov 2016 16:53:49 +0900 (KST) Received: from localhost.localdomain ([10.113.62.216]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGS003DR0LP0Q70@mmp2.samsung.com>; Thu, 17 Nov 2016 16:53:49 +0900 (KST) From: Jaehoon Chung To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, shawn.lin@rock-chips.com, Jaehoon Chung Subject: [PATCH] mmc: dw_mmc: fix the error handling for dma operation Date: Thu, 17 Nov 2016 16:53:47 +0900 Message-id: <20161117075347.9061-1-jh80.chung@samsung.com> X-Mailer: git-send-email 2.10.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHLMWRmVeSWpSXmKPExsVy+t9jQV3eJN0IgyWr5C1u/GpjtTjyv5/R 4s6T9awWx9eGO7B43Lm2h83j76z9LB59W1YxenzeJBfAEuVmk5GamJJapJCal5yfkpmXbqsU GuKma6GkkJeYm2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jG0HVjMX3Oeo6LpW1sA4 jb2LkZNDQsBE4umJw0wQtpjEhXvr2UBsIYFZjBKfZ4l0MXIB2T8YJVZPvAuWYBPQkdj+7ThY g4iArMTPPxfA4swCcRKLjv4EGyos4CZx6PNvsDiLgKrE+VXbwGxeASuJc697WSCWyUtcuHqK ZQIj9wJGhlWMEqkFyQXFSem5hnmp5XrFibnFpXnpesn5uZsYwWH3TGoH48Fd7ocYBTgYlXh4 J9zWiRBiTSwrrsw9xCjBwawkwiuVoBshxJuSWFmVWpQfX1Sak1p8iNEU6ICJzFKiyfnAmMgr iTc0MTcxNzawMLe0NDFSEudtnP0sXEggPbEkNTs1tSC1CKaPiYNTqoHRLoxp0Wn2bccjWd2a Ml4ymG84tE9FdJ+KfUHAcaUl0c7mCQodfCbpbIwHD+gwn9/8Mlg84Vxq3P6jRstXqr+VuXSd o+6e/4nLuSJTczYc3pCwIjHvRtmOxf53syqMynjTW1Y23Y3OKX8TZzy3N5BpVtfPbLad4tsl j7j73tJlEzhQwHb54mclluKMREMt5qLiRABLVuwYUQIAAA== X-MTR: 20000000000000000@CPGS Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When OWN bit of dma descriptor is not cleared, then it returns -EINVAL. Then it has to fall back to PIO mode for current transfer. Host controller was already set to bits relevant to DMA operation. If needs to use the PIO mode, Host controller has to stop the DMA operation. (It's more stable than now.) When it occurred error, it's not running any request. Fixes: 3b2a067b98b4 ("mmc: dw_mmc: avoid race condition of cpu and IDMAC") Signed-off-by: Jaehoon Chung Reviewed-by: Shawn Lin --- drivers/mmc/host/dw_mmc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 9341b18..080003b 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1058,6 +1058,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) spin_unlock_irqrestore(&host->irq_lock, irqflags); if (host->dma_ops->start(host, sg_len)) { + host->dma_ops->stop(host); /* We can't do DMA, try PIO for this one */ dev_dbg(host->dev, "%s: fall back to PIO mode for current transfer\n",