Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp49324pxk; Tue, 15 Sep 2020 17:26:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcUf4NkulWH/50udWZq97eEfWrfFiWWDbXTYT9+pTOpLzcLA8i5nmnXTe8+mq8sQ+mmt4M X-Received: by 2002:aa7:d40f:: with SMTP id z15mr25476355edq.247.1600216007862; Tue, 15 Sep 2020 17:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600216007; cv=none; d=google.com; s=arc-20160816; b=qYkybJ2p/V894fd/Y1jrOEfNgkhc+K1+fmHjecxtUQFzzJAFA7RVEdwyq+M7r8E7y7 CxMTC5NGrw0qGyBAnrmfSVoLirZM4gjARpi2ki7r04yfB3RSM/ZSa5pf4zz7owaTvm4o SjWbyoNyLbBxigWVgGEOEewZVAtztM3UKY5ezeGJTHq53k3MtpEnyGPMpYZd8N3e7Wvv krwLgIARZUjAJtjg5NPtUgpCcHBUJCc4t48ZttytmupTwkpFxElMar00AWXmvnLAN+3v t1fAtVstxLSjREh7YXbvgPnmtIVctJiCD9Ikn0gfENvZMn5dRf+sr5UBKp0W+QzX+mte 4zeA== 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=OtGYkK/QDXFgleeaKXfpbpxH8YfchJe1af5obCwow2A=; b=uhjpa8PN/K7+dDwHRv44h7U4/wgAemVdjhNgqTyZb09Rj9eDnqWrbIkz8A6TBXl3HN gI9GXtH348hy7NuxzX6QBHHJvHjIp6RROoE2uJX6FhBmCcY6iqeSifbBcbzpojdfczqB LBrhisk/TTMu5jYgqW6k0enz9t7EJF8RHnIWKwZnEX5DRlfkRdDtw0/fGtswlcmNiQr0 THik+hP611cA9IWhsBqgKnsfVWzwrixNFO4brueqopw2+Mx87I9bwV5ipXGOhGFGJ4Ru n3zV/TQTRvKTbRTPhohk9KAZxMgkY3QewwRBHDnYbbRQrb4Sym4oQUu/uQZH+mEI5+il 78Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1Nygd3K4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si10495453ejv.525.2020.09.15.17.26.25; Tue, 15 Sep 2020 17:26:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1Nygd3K4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbgIPAZC (ORCPT + 99 others); Tue, 15 Sep 2020 20:25:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:60526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbgIOORJ (ORCPT ); Tue, 15 Sep 2020 10:17:09 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 4BFCD21D41; Tue, 15 Sep 2020 14:15:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179315; bh=hy4Cg3Bcba56r9+MqDFiwn1/6C4+ITl2oHpjXOmdoNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Nygd3K4OZySLYiN6FPb3hUaHNiOzaaljukDb/t9hDyYCSQsaus9javX++RVLBNoH TrJ7CIsHSbiYVaeHxb7cHikvlroSvIwSloaFEUG83XAagAcLoRVGugR2BqKWJD5UUJ 1C+jK3bbTUADCU0/bonpAFC+SNWCLef+bfG855WM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Veerabhadrarao Badiganti , Adrian Hunter , Ulf Hansson , Sasha Levin Subject: [PATCH 4.19 12/78] mmc: sdhci-msm: Add retries when all tuning phases are found valid Date: Tue, 15 Sep 2020 16:12:37 +0200 Message-Id: <20200915140634.150306549@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140633.552502750@linuxfoundation.org> References: <20200915140633.552502750@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Douglas Anderson [ Upstream commit 9d5dcefb7b114d610aeb2371f6a6f119af316e43 ] As the comments in this patch say, if we tune and find all phases are valid it's _almost_ as bad as no phases being found valid. Probably all phases are not really reliable but we didn't detect where the unreliable place is. That means we'll essentially be guessing and hoping we get a good phase. This is not just a problem in theory. It was causing real problems on a real board. On that board, most often phase 10 is found as the only invalid phase, though sometimes 10 and 11 are invalid and sometimes just 11. Some percentage of the time, however, all phases are found to be valid. When this happens, the current logic will decide to use phase 11. Since phase 11 is sometimes found to be invalid, this is a bad choice. Sure enough, when phase 11 is picked we often get mmc errors later in boot. I have seen cases where all phases were found to be valid 3 times in a row, so increase the retry count to 10 just to be extra sure. Fixes: 415b5a75da43 ("mmc: sdhci-msm: Add platform_execute_tuning implementation") Signed-off-by: Douglas Anderson Reviewed-by: Veerabhadrarao Badiganti Acked-by: Adrian Hunter Link: https://lore.kernel.org/r/20200827075809.1.If179abf5ecb67c963494db79c3bc4247d987419b@changeid Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/sdhci-msm.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 643fd1a1b88be..4970cd40813b2 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -1060,7 +1060,7 @@ static void sdhci_msm_set_cdr(struct sdhci_host *host, bool enable) static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode) { struct sdhci_host *host = mmc_priv(mmc); - int tuning_seq_cnt = 3; + int tuning_seq_cnt = 10; u8 phase, tuned_phases[16], tuned_phase_cnt = 0; int rc; struct mmc_ios ios = host->mmc->ios; @@ -1124,6 +1124,22 @@ retry: } while (++phase < ARRAY_SIZE(tuned_phases)); if (tuned_phase_cnt) { + if (tuned_phase_cnt == ARRAY_SIZE(tuned_phases)) { + /* + * All phases valid is _almost_ as bad as no phases + * valid. Probably all phases are not really reliable + * but we didn't detect where the unreliable place is. + * That means we'll essentially be guessing and hoping + * we get a good phase. Better to try a few times. + */ + dev_dbg(mmc_dev(mmc), "%s: All phases valid; try again\n", + mmc_hostname(mmc)); + if (--tuning_seq_cnt) { + tuned_phase_cnt = 0; + goto retry; + } + } + rc = msm_find_most_appropriate_phase(host, tuned_phases, tuned_phase_cnt); if (rc < 0) -- 2.25.1