From patchwork Mon Jul 27 20:39:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 500652 X-Patchwork-Delegate: panto@antoniou-consulting.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5466B1402BA for ; Tue, 28 Jul 2015 06:40:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 798F04B712; Mon, 27 Jul 2015 22:39:59 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pBbpHHYn2KMk; Mon, 27 Jul 2015 22:39:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 874DF4B6FA; Mon, 27 Jul 2015 22:39:58 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 41B914B6DE for ; Mon, 27 Jul 2015 22:39:50 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 34aqxp6S9jP2 for ; Mon, 27 Jul 2015 22:39:50 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTPS id 1080A4B6DA for ; Mon, 27 Jul 2015 22:39:46 +0200 (CEST) Received: from mail.nefkom.net (unknown [192.168.8.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3mgCg61scRz3hjC2; Mon, 27 Jul 2015 22:39:45 +0200 (CEST) X-Auth-Info: YTvpI/Quz3NWSKI98dA+OxApNX6XnRk+AIT+zouIRjI= Received: from chi.lan (unknown [195.140.253.167]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3mgCg550hgzvdWS; Mon, 27 Jul 2015 22:39:45 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Mon, 27 Jul 2015 22:39:38 +0200 Message-Id: <1438029579-9352-3-git-send-email-marex@denx.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438029579-9352-1-git-send-email-marex@denx.de> References: <1438029579-9352-1-git-send-email-marex@denx.de> Cc: Marek Vasut , Tom Rini , Pantelis Antoniou Subject: [U-Boot] [PATCH 3/4] mmc: dw_mmc: Improve handling of data transfer failure X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In case the data transfer failure happens, instead of returning immediatelly, make sure the DMA is disabled, status register is cleared and the bounce buffer is stopped. Signed-off-by: Marek Vasut Cc: Dinh Nguyen Cc: Pantelis Antoniou Cc: Tom Rini --- drivers/mmc/dw_mmc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 0f61f16..fcd5784 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -110,7 +110,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct dwmci_host *host = mmc->priv; ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac, data ? DIV_ROUND_UP(data->blocks, 8) : 0); - int flags = 0, i; + int ret = 0, flags = 0, i; unsigned int timeout = 100000; u32 retry = 10000; u32 mask, ctrl; @@ -218,20 +218,22 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, /* Error during data transfer. */ if (mask & (DWMCI_DATA_ERR | DWMCI_DATA_TOUT)) { printf("%s: DATA ERROR!\n", __func__); - bounce_buffer_stop(&bbstate); - return -1; + ret = -EINVAL; + break; } /* Data arrived correctly. */ - if (mask & DWMCI_INTMSK_DTO) + if (mask & DWMCI_INTMSK_DTO) { + ret = 0; break; + } /* Check for timeout. */ if (get_timer(start) > timeout) { printf("%s: Timeout waiting for data!\n", __func__); - bounce_buffer_stop(&bbstate); - return TIMEOUT; + ret = TIMEOUT; + break; } } @@ -246,7 +248,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, udelay(100); - return 0; + return ret; } static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)