Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8209841imu; Fri, 28 Dec 2018 12:49:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN4BpmyEQIKfBCHE+d/6e7V6LSezdY6lOoO38A7vXWycYJ7lDXmQN5OP3Ygs9XHr+gG7qpwk X-Received: by 2002:a17:902:b093:: with SMTP id p19mr28812142plr.135.1546030193173; Fri, 28 Dec 2018 12:49:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546030193; cv=none; d=google.com; s=arc-20160816; b=tvUNl01Uu/6ptWRB99n05zAo/TTgTP6gtyNVxg+GHy/LPMpv0dprILnHyOkHi7hLQB U9o5CGnvQG3FgUP2r2HueHA4n16iZfDbSNyqACa3a/PHE/ut7UrCVz7LAQl24iq0EeXr Ea1Zk+2vfVaitROXAvdHqo1V6LLBvCK93jC/ivdmAChquSRV7tlcCzZ7vI/x0nPEwgXk yEeYU/EBWQuAXCuxD3lQOEx6D0W69uQArPxf+ZB0CclpKuBjF/0AIwqN6DS+b7WaiIwX H29IrKyJG0Wi6P59NOmniTtF9qFQHjdCXOXJ0n5JPuwfhYHaJNjN8qt6qUefxymDgnlx g7zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cu0J8QIkT/IxiQozJL/Pib3h9xosAVwztiDN7R07Yao=; b=E9e13NZVGQGVGXgnns37ic7Oi7+d2zlhx5kugNf66AFIii4biFsCEgRbv61awD1wK2 GLYVILmcYg3CbcdfjYKpLDCT/gxHMJsZYZuuR3lxbT+5jYqI/H/ksXmxepleCIZ9+eHU B2Ub+NwhUt/5L7gJAiYDGS/IkHP4ooQK8dF+NSsYshTEvQ89GFo/X8S26YGiInYrx0Te FQ3WFVCAJUd2mW8vfTUUrVakErsX/RPNveH9ZSnCVV9TtahMqTp5zlTOddaE783eUMxU CWFnqpq3+XV1y7bHzmVEVP4+UMLDgU4oJWNUWGjUJHJfx8mqP2Hmfdnk8xqEWqNQu/GE 2G+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C9PeHV4X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p66si7334771pfp.144.2018.12.28.12.49.37; Fri, 28 Dec 2018 12:49:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C9PeHV4X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732293AbeL1Lxc (ORCPT + 99 others); Fri, 28 Dec 2018 06:53:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:53254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732247AbeL1Lx0 (ORCPT ); Fri, 28 Dec 2018 06:53:26 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CEBD920879; Fri, 28 Dec 2018 11:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545998005; bh=/+brTRHRjqDBbBu/uLsP1nmJjpnyTfltWBQORYRx0JE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C9PeHV4XAfU2VvY8h4dZZuqkBZTgusXQrJZUbaXBuHEtVQ8s8JiOOSBQaa1x1PXxN GUufsHqtZsyKLaBG0XVr+zkG0n3Ll2BE6nHpMD3DxYujB3Y5o5KRCBk/TyINjh8wUr oQKcNsSOEdPVTODimmTv2tRY1AirGkHdfMZPVX5k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sjoerd Simons , Andreas Dannenberg , Faiz Abbas , Ulf Hansson Subject: [PATCH 4.19 16/46] mmc: core: Use a minimum 1600ms timeout when enabling CACHE ctrl Date: Fri, 28 Dec 2018 12:52:10 +0100 Message-Id: <20181228113125.722066548@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181228113124.971620049@linuxfoundation.org> References: <20181228113124.971620049@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ulf Hansson commit e3ae3401aa19432ee4943eb0bbc2ec704d07d793 upstream. 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 Cc: Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/mmc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- 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, @@ -1789,13 +1790,18 @@ static int mmc_init_card(struct mmc_host } /* - * 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;