From patchwork Sat Jul 9 15:40:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 71702 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp954085qgy; Sat, 9 Jul 2016 08:40:55 -0700 (PDT) X-Received: by 10.28.146.9 with SMTP id u9mr3759584wmd.52.1468078855679; Sat, 09 Jul 2016 08:40:55 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id qr5si2999437wjc.265.2016.07.09.08.40.55; Sat, 09 Jul 2016 08:40:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 06980A74FF; Sat, 9 Jul 2016 17:40:53 +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 K15SVoe1s9Q2; Sat, 9 Jul 2016 17:40:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 38C1E4BDE9; Sat, 9 Jul 2016 17:40:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BF53A4BDE9 for ; Sat, 9 Jul 2016 17:40:49 +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 CvSGFCVA2OLt for ; Sat, 9 Jul 2016 17:40:49 +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 conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by theia.denx.de (Postfix) with ESMTPS id 18DFE4BDBD for ; Sat, 9 Jul 2016 17:40:45 +0200 (CEST) Received: from grover.sesame (FL1-119-242-215-193.osk.mesh.ad.jp [119.242.215.193]) (authenticated) by conuserg-08.nifty.com with ESMTP id u69FeUCx013964; Sun, 10 Jul 2016 00:40:35 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com u69FeUCx013964 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1468078835; bh=ec/As+F1YuPNaBf2NkEpobmBbH5p7kZUVV6ZVfZRP/g=; h=From:To:Cc:Subject:Date:From; b=fDwneo/v2fUcW5NmcZydKLHtS8VfU/Tzn+kq3qtT3Ynbcf5w+YI9QT7gMqgz1YmHy CeRgLqXpn0ZYWLi5x0XU2wPwWv56iST41Lfnjyt9mtiN513ApEg43OAvcy5OZAf3ap 303veNvXO0icIrnpprXOnNAAye5gYJnGejXctSwm1pBe5kD6l7NkNeuCXWcAMSJVUu +tk+YQV4DYfJ0bhjAad0acw9PBnBMLkl790ZqrgpiIMkCTw3ZdKNKI6R1r3iBxdt6K v0HA0d6MP3m0wjeiURH3WV2jLhp+hUoKzT5cBjb8AZ5GiXldNLR8MVyDz7B5vydDWV mG+mZU3ZCQAVg== X-Nifty-SrcIP: [119.242.215.193] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Sun, 10 Jul 2016 00:40:22 +0900 Message-Id: <1468078822-6609-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Cc: Pantelis Antoniou Subject: [U-Boot] [PATCH v2] mmc: sdhci: clean up timeout detection 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" The current timeout detection logic is not very nice; it calls get_timer(start) in the while() loop, and then calls it again after the loop to check if a timeout error happened. Because of the time difference between the two calls of get_timer(), the timeout detected after the loop may not be true. Signed-off-by: Masahiro Yamada Acked-by: Jaehoon Chung --- Changes in v2: - Fix a typo : get_time() -> get_timer() in git-log drivers/mmc/sdhci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 604f18d..0a1882d 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -243,17 +243,17 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, stat = sdhci_readl(host, SDHCI_INT_STATUS); if (stat & SDHCI_INT_ERROR) break; - } while (((stat & mask) != mask) && - (get_timer(start) < SDHCI_READ_STATUS_TIMEOUT)); - if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) { - if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) - return 0; - else { - printf("%s: Timeout for status update!\n", __func__); - return TIMEOUT; + if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) { + if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) { + return 0; + } else { + printf("%s: Timeout for status update!\n", + __func__); + return TIMEOUT; + } } - } + } while ((stat & mask) != mask); if ((stat & (SDHCI_INT_ERROR | mask)) == mask) { sdhci_cmd_done(host, cmd);