From patchwork Tue Apr 2 10:04:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabbasov, Andrew" X-Patchwork-Id: 232988 X-Patchwork-Delegate: sbabic@denx.de 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 B6E602C0145 for ; Tue, 2 Apr 2013 23:30:08 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1BD704A262; Tue, 2 Apr 2013 14:30:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 R1ZCLdNjegIL; Tue, 2 Apr 2013 14:30:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AD2C84A26A; Tue, 2 Apr 2013 14:30:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A1A6C4A204 for ; Tue, 2 Apr 2013 12:05:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 ll+10KqAPQtm for ; Tue, 2 Apr 2013 12:05:31 +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 relay1.mentorg.com (relay1.mentorg.com [192.94.38.131]) by theia.denx.de (Postfix) with ESMTP id 5D0E54A200 for ; Tue, 2 Apr 2013 12:05:29 +0200 (CEST) Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UMy5l-0003JJ-RK from Andrew_Gabbasov@mentor.com for u-boot@lists.denx.de; Tue, 02 Apr 2013 03:05:25 -0700 Received: from sb-u1010-ivi.alm.mentorg.com ([134.86.96.16]) by svr-orw-fem-01.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 2 Apr 2013 03:05:25 -0700 From: Andrew Gabbasov To: u-boot@lists.denx.de Date: Tue, 2 Apr 2013 05:04:55 -0500 Message-Id: <1364897095-28227-1-git-send-email-andrew_gabbasov@mentor.com> X-Mailer: git-send-email 1.7.10.4 X-OriginalArrivalTime: 02 Apr 2013 10:05:25.0681 (UTC) FILETIME=[988E4A10:01CE2F89] X-Mailman-Approved-At: Tue, 02 Apr 2013 14:30:01 +0200 Subject: [U-Boot] [PATCH] mx6: fsl_esdhc: Fix waiting for DMA operation completion X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de On iMX6 sometimes the Transfer Complete interrupt occurs earlier than the DMA part completes its operation. If immediately after that the read data is used for some data verification, those obtained data may be incomplete, which causes intermittent verification failures. For example, when the default environment command tries to load and run boot script from FAT partition on SD/MMC card, it sometimes fails, reporting invalid partition table, or unknown partition type, or something else of that kind. Such errors disappear if the build configuration has CONFIG_SYS_FSL_ESDHC_USE_PIO, or if some delay is added after transfer completion. Adding extra waiting for DMA completion after Transfer Complete event fixes this issue. Signed-off-by: Andrew Gabbasov --- drivers/mmc/fsl_esdhc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index d2a505e..806c6dd 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -402,6 +402,12 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) return COMM_ERR; } while (!(irqstat & IRQSTAT_TC) && (esdhc_read32(®s->prsstat) & PRSSTAT_DLA)); +#ifdef CONFIG_MX6 + /* In imx6 TC (data end) interrupt sometimes occur earlier + than DMA completes. In this case just wait a little more. */ + while (!(irqstat & (IRQSTAT_DINT | IRQSTAT_DMAE))) + irqstat = esdhc_read32(®s->irqstat); +#endif #endif }