From patchwork Mon Dec 10 16:52:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 153299 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3772585ljp; Mon, 10 Dec 2018 08:52:47 -0800 (PST) X-Received: by 2002:a2e:80d3:: with SMTP id r19-v6mr7720659ljg.151.1544460767674; Mon, 10 Dec 2018 08:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544460767; cv=none; d=google.com; s=arc-20160816; b=E0BpFbN1kRZsJT8YYcT7U8WAUWvQen4TQpTYHqsARVd5MyeiPWTjVELyzdDDeIkoPE 2m8RwxDJsT8BfBR+MXe0ycdApl730W0z+h3KgmQQFh0vIktE9SIHcf744UNgn7bXskfh CXMgkasg2Q0I4laM/5/EvTap+4VGpFv679SqdUHehn1YZAAaq5JLsHXp8nHCh+pTEbtr xEZ1Jbsnl375HDF+NgBxGYrL2Th+0W8Q0zqwNdS4ogO9xrb2cROPIAO/TkrLeNFtsWNL /MvqFVHXilZIziZnjlE02FgWBUDaWZAlNYUVLpfZ9c0uH5hNZHyiYa2Rz/3wl5zgU+MS INWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ev/ntoDbh5ybE5JNkNvhwN8PjP40USGqAlYJOPoCA2k=; b=v+vZ61gnxkmI0G3uZX2Wlyj9NlcO4vCwh8zESUXOVLaZU7j2fvqrSFq0TbiILFGaAJ eF6u3v+oVZXi7wA89JdmSBXh2LdUw4yEG6j9tsn0QLzTjf5OGAFrBGs/02m0Gxs/ZwWy Kx5HxJBwix4MGglpcWatiDPVhVDc37UKZljt9RT7YtE1HLyCH1nP3VM/jCsmfwYwcu7m h2IH4eWyc9feNW0vZr2oin09MXugBo4e0dGBytGVRFeNvBzKhr6jAndEx1Zs3PCMmShq xMVqMf1yP0iC7s8LhjZ7TX7IxBdSZshNqJ6NH5SbIDno/I+2ebiNBWGVk3s0VMJ6x/oi BMqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g8Xnjr9Z; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u66sor2953459lff.39.2018.12.10.08.52.47 for (Google Transport Security); Mon, 10 Dec 2018 08:52:47 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g8Xnjr9Z; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ev/ntoDbh5ybE5JNkNvhwN8PjP40USGqAlYJOPoCA2k=; b=g8Xnjr9ZP84dkEnjjAwFKmbVa/KsRHtwFGsAtPZVNyMhYfAjyxAiOBW6I+Mk7PZEdu hS/1GL5X9snAFZHdfuUY4aW8YGquKPihYGAxanDZ390xwfBdnzJCAMtW2FeIgkmxwtSZ XhRY2QmXLYfuv8BNw9PMC5U1TnTcM2Z2mbZEw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ev/ntoDbh5ybE5JNkNvhwN8PjP40USGqAlYJOPoCA2k=; b=VEuhD4GbsJXlWamDpb+Zf4IoaW38fLw8KYwyqR8DIFGOvd7/E/g6MP08DZwlJRIBpz /S5acOrTYV1+oy0Ft5P7vDnt1pAwAoF56mqpanfrWGwmpYRIYIvc9DhPMSkQzAnvha4s 2J2BbVb88CQkLjr9AofqkUUnhi/sMRzyEFvd4YfvNt7c2sJwyaHgKYud0UPkWB//Qwq7 zPROTxSk09gqeK9+g9XU4O0Zbb5yVtLID8OubtCfF/qZiVxLdCLQzAbQ6nzQ9vfT6ATk WZZkn6L4lfOcHslQ0ThEkpdw86Rd3eaFmil7X6dXDWy47/X9yC4bg6oW8FbBq7WhDWf8 l23A== X-Gm-Message-State: AA+aEWbVCAdIAad/8nrwKxHlSCqpX3mXnlkYfaP4UXLeqTASRPGvU3fW D3B3NEpF8YhNESACSh5Ae6ih3nH7 X-Google-Smtp-Source: AFSGD/XrCuze5uCGufZGKatKIQ7GFvCpcrDcsCkEWixTeXx8bXcpRiustuqsbgD4e5rXMBl9t9W+bg== X-Received: by 2002:a19:982:: with SMTP id 124mr7061155lfj.138.1544460767408; Mon, 10 Dec 2018 08:52:47 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id w9sm2194574lfc.66.2018.12.10.08.52.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 08:52:46 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Wolfram Sang , Adrian Hunter , Sjoerd Simons , Faiz Abbas , Jaehoon Chung , Shawn Lin Subject: [PATCH 3/5] mmc: core: Use a minimum 1600ms timeout when enabling CACHE ctrl Date: Mon, 10 Dec 2018 17:52:38 +0100 Message-Id: <20181210165240.23101-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181210165240.23101-1-ulf.hansson@linaro.org> References: <20181210165240.23101-1-ulf.hansson@linaro.org> Some eMMCs from Micron have been reported to need ~800 ms timeout, while enabling the CACHE ctrl after running sudden power failure tests. The needed timeout is greater than what the card specifies as its generic CMD6 timeout, through the EXT_CSD register, hence the problem. Normally we would introduce a card quirk to extend the timeout for these specific Micron cards. However, due to the rather complicated debug process needed to find out the error, let's simply use a minimum timeout of 1600ms, the double of what has been reported, for all cards when enabling CACHE ctrl. Reported-by: Sjoerd Simons Reported-by: Andreas Dannenberg Reported-by: Faiz Abbas Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index cb98d30df409..2510cebd670f 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -30,6 +30,7 @@ #include "pwrseq.h" #define DEFAULT_CMD6_TIMEOUT_MS 500 +#define MIN_CACHE_EN_TIMEOUT_MS 1600 static const unsigned int tran_exp[] = { 10000, 100000, 1000000, 10000000, @@ -1792,13 +1793,18 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, } /* - * If cache size is higher than 0, this indicates - * the existence of cache and it can be turned on. + * If cache size is higher than 0, this indicates the existence of cache + * and it can be turned on. Note that some eMMCs from Micron has been + * reported to need ~800 ms timeout, while enabling the cache after + * sudden power failure tests. Let's extend the timeout to a minimum of + * DEFAULT_CACHE_EN_TIMEOUT_MS and do it for all cards. */ if (card->ext_csd.cache_size > 0) { + unsigned int timeout_ms = MIN_CACHE_EN_TIMEOUT_MS; + + timeout_ms = max(card->ext_csd.generic_cmd6_time, timeout_ms); err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_CACHE_CTRL, 1, - card->ext_csd.generic_cmd6_time); + EXT_CSD_CACHE_CTRL, 1, timeout_ms); if (err && err != -EBADMSG) goto free_card;