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: 10721775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E45D15A6 for ; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D1232A810 for ; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 315C52A827; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB3562A810 for ; Mon, 10 Dec 2018 16:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728017AbeLJQwv (ORCPT ); Mon, 10 Dec 2018 11:52:51 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35860 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbeLJQwu (ORCPT ); Mon, 10 Dec 2018 11:52:50 -0500 Received: by mail-lf1-f67.google.com with SMTP id a16so8530478lfg.3 for ; Mon, 10 Dec 2018 08:52:48 -0800 (PST) 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=A8IBgv+/bY7DWOjA7PEj1acRuoS+5iMxxbt3iMKfb6Fk4RftRwA19F6ChpB+paCgPX YS9nrjn3BUzSK+TceliFEOPvCQm+UPIAGsjgHrvzVx6cSxhJd0J3onBT7FoWE9JHQell VvJTXCIhZ5inPqdjilcT0o6Ya1W4fzcpBb2EP/J5FwxpTO39gBmG2BOQX3HAW5bMvwH8 Zg0UtcL2NGsFS6u6cuEZAYv+M0XljR61otcdB6wcqARs+IRWiz1CdwBcuqZCWGGo4nq2 5iCaUsKWxXpqnFN8XCX6v9DM8TKkj3TMpJqqk2DtI5Q1NYjGmkEOoMRD8QDYiCQUaq90 GNWw== X-Gm-Message-State: AA+aEWYjvAdqzV+LBsPJ7dATl+ur17h6xUtEUhziDbSCp/hN9BHjIiGX kzSXrKapr/ITfUHRKvDqhc/MmzRBvfnTQA== 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) 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> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;