From patchwork Fri Nov 4 17:32:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 80902 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp92343qge; Fri, 4 Nov 2016 10:32:48 -0700 (PDT) X-Received: by 10.37.86.194 with SMTP id k185mr15306061ybb.48.1478280768350; Fri, 04 Nov 2016 10:32:48 -0700 (PDT) Return-Path: Received: from mail-yw0-x22b.google.com (mail-yw0-x22b.google.com. [2607:f8b0:4002:c05::22b]) by mx.google.com with ESMTPS id t189si3949478ywt.378.2016.11.04.10.32.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Nov 2016 10:32:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2607:f8b0:4002:c05::22b as permitted sender) client-ip=2607:f8b0:4002:c05::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2607:f8b0:4002:c05::22b as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-yw0-x22b.google.com with SMTP id h14so96903449ywa.2 for ; Fri, 04 Nov 2016 10:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=SfydWO6YBa6/rb1W9rIDlUbxy88D8b73jsU6pk0rbrk=; b=dYtFmwWO3QXSxJtVhBQcr72Os3stVQdPR/fxPDx6edkfaLDU7+J842RaPyf+Nwg6AA b5ZpXKzb1RLp+BfoLJB1NoDBZNY45QnxE0yf6bnk2uqnPPCLipm1sYZ4aF5vbHLQoz2K LdU0QuZGs8FMDgUT0xTPz/7o/bL5ZnW67d1Gg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SfydWO6YBa6/rb1W9rIDlUbxy88D8b73jsU6pk0rbrk=; b=WyZ3+NRDsuy0GFjeqM/R1aGnb3lJOdxbUhSE6OhYajdjGsh79BRvndC5oPxJen5aBU h/dW/nlqnHOe2BaQbjONEXi/vDqPKvSfw17dMSX2OF6Kg4CsrHEuQNKFlOS6UKpb5ooo YbT/1SzPZzF2nfufnSN9+7RXF894V6ffc6/mN5VlV7nBbGPaJmN790TB1EGsMqL4hw/U eYOrtjjIHJzKlhd3/4uQsS40620NhBP/yCo0M7KXao9pC2v3sD5UBlNrMnUs5MNvDWYJ fg7lGoPtEwwu4GyGgzjuwbmWGn13L5AdD5jc/LrzAF0vlyEW6589PIpRFo8/YDnYiAP1 zTBQ== X-Gm-Message-State: ABUngvfhatIABymY/glpps+D93lt4UBkv1+hOfDNAeYj/r1Vwn1YCTy7ToM9bRiKDeeVcy4dGnk= X-Received: by 10.36.52.203 with SMTP id z194mr2518886itz.121.1478280767874; Fri, 04 Nov 2016 10:32:47 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([198.233.217.214]) by smtp.gmail.com with ESMTPSA id q6sm5143832ioe.12.2016.11.04.10.32.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Nov 2016 10:32:46 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Linus Walleij , Chaotian Jing , Stephen Boyd , Subject: [PATCH] mmc: mmc: Use 500ms as the default generic CMD6 timeout Date: Fri, 4 Nov 2016 18:32:33 +0100 Message-Id: <1478280753-2482-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In the eMMC 4.51 version of the spec, an EXT_CSD field called GENERIC_CMD6_TIME[248] was added. This allows cards to specify the maximum time it may need to move out from its busy state, when a CMD6 command has been sent. In cases when the card is compliant to versions < 4.51 of the eMMC spec, obviously the core needs to use a fall-back value for this timeout, which currently is set to 10 minutes. This value is completely in the wrong range and importantly in some cases it causes a card initialization to take more than 10 minute to complete. Earlier this scenario was avoided as the mmc core used CMD13 to poll the card, to find out when it stopped signaling busy. Commit 08573eaf1a70 ("mmc: mmc: do not use CMD13 to get status after speed mode switch") changed this behavior. Instead of reverting that commit, which would cause other issues, let's instead start by picking a simple solution for the problem, by using a 500ms default generic CMD6 timeout. The reason for using exactly 500ms, comes from observations that shows it's quite common for cards to specify 250ms. 500ms is two times that value so likely it should be enough for most cards. Cc: # v4.8+ Fixes: 08573eaf1a70 ("mmc: mmc: do not use CMD13 to get status after speed mode switch") Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.1 Tested-by: Stephen Boyd diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index e811bd9..9355366 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -26,6 +26,8 @@ #include "mmc_ops.h" #include "sd_ops.h" +#define DEFAULT_CMD6_TIMEOUT_MS 500 + static const unsigned int tran_exp[] = { 10000, 100000, 1000000, 10000000, 0, 0, 0, 0 @@ -571,6 +573,7 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) card->erased_byte = 0x0; /* eMMC v4.5 or later */ + card->ext_csd.generic_cmd6_time = DEFAULT_CMD6_TIMEOUT_MS; if (card->ext_csd.rev >= 6) { card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;