From patchwork Thu Nov 10 21:56:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton staaf X-Patchwork-Id: 125015 X-Patchwork-Delegate: afleming@freescale.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 B93B8B6F99 for ; Fri, 11 Nov 2011 10:01:30 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5FB362897F; Fri, 11 Nov 2011 00:01:28 +0100 (CET) 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 bY4d68UF-cYC; Fri, 11 Nov 2011 00:01:27 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 789332832E; Fri, 11 Nov 2011 00:01:26 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6DB432832E for ; Fri, 11 Nov 2011 00:01:21 +0100 (CET) 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 yP901zNj+L4N for ; Fri, 11 Nov 2011 00:01:20 +0100 (CET) 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-gx0-f202.google.com (mail-gx0-f202.google.com [209.85.161.202]) by theia.denx.de (Postfix) with ESMTPS id 56316282CB for ; Fri, 11 Nov 2011 00:01:19 +0100 (CET) Received: by ggnu2 with SMTP id u2so311394ggn.3 for ; Thu, 10 Nov 2011 15:01:17 -0800 (PST) Received: by 10.100.51.16 with SMTP id y16mr2215833any.44.1320962225716; Thu, 10 Nov 2011 13:57:05 -0800 (PST) Received: by 10.100.51.16 with SMTP id y16mr2215805any.44.1320962225530; Thu, 10 Nov 2011 13:57:05 -0800 (PST) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id r38si3762367ano.2.2011.11.10.13.57.05 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 10 Nov 2011 13:57:05 -0800 (PST) Received: from wpaz33.hot.corp.google.com (wpaz33.hot.corp.google.com [172.24.198.97]) by wpzn3.hot.corp.google.com (Postfix) with ESMTPS id 797A910004D; Thu, 10 Nov 2011 13:57:05 -0800 (PST) Received: from servo.mtv.corp.google.com (servo.mtv.corp.google.com [172.22.72.56]) by wpaz33.hot.corp.google.com with ESMTP id pAALv3bO009719; Thu, 10 Nov 2011 13:57:04 -0800 Received: by servo.mtv.corp.google.com (Postfix, from userid 99248) id CF1534A190; Thu, 10 Nov 2011 13:57:03 -0800 (PST) From: Anton Staaf To: u-boot@lists.denx.de Date: Thu, 10 Nov 2011 13:56:51 -0800 Message-Id: <1320962212-11789-4-git-send-email-robotboy@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1320962212-11789-1-git-send-email-robotboy@chromium.org> References: <1320962212-11789-1-git-send-email-robotboy@chromium.org> X-System-Of-Record: true Cc: Andy Fleming , Anton Staaf , Tom Warren Subject: [U-Boot] [PATCH v3 3/4] Tegra2: mmc: Add data transfer completion timeout X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 Currently when no expected completion condition occures in the mmc_send_cmd while loop that is waiting for a data transfer to complete the MMC driver just hangs. This patch adds an arbitrary 2 second timeout. If nothing we recognize occures within 2 seconds some diagnostic information is printed and we fail out. Signed-off-by: Anton Staaf Cc: Andy Fleming Cc: Tom Warren Cc: Stephen Warren Cc: Albert Aribaud --- drivers/mmc/tegra2_mmc.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/tegra2_mmc.c b/drivers/mmc/tegra2_mmc.c index 159cef1..bbd0ccd 100644 --- a/drivers/mmc/tegra2_mmc.c +++ b/drivers/mmc/tegra2_mmc.c @@ -260,6 +260,8 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, } if (data) { + unsigned long start = get_timer(0); + while (1) { mask = readl(&host->reg->norintsts); @@ -284,6 +286,18 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, /* Transfer Complete */ debug("r/w is done\n"); break; + } else if (get_timer(start) > 2000UL) { + writel(mask, &host->reg->norintsts); + printf("%s: MMC Timeout\n" + " Interrupt status 0x%08x\n" + " Interrupt status enable 0x%08x\n" + " Interrupt signal enable 0x%08x\n" + " Present status 0x%08x\n", + __func__, mask, + readl(&host->reg->norintstsen), + readl(&host->reg->norintsigen), + readl(&host->reg->prnsts)); + return -1; } } writel(mask, &host->reg->norintsts);