From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0825FC433E2 for ; Mon, 31 Aug 2020 14:15:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB76420693 for ; Mon, 31 Aug 2020 14:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbgHaOPn (ORCPT ); Mon, 31 Aug 2020 10:15:43 -0400 Received: from mga06.intel.com ([134.134.136.31]:49705 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbgHaOP3 (ORCPT ); Mon, 31 Aug 2020 10:15:29 -0400 IronPort-SDR: wpvc6XIWW4JxprpMeUgxW4LbsI1aR2CA/vgaEHXx6P2O6JjKGIJyr/foLgxfReygSSlMgeDtte Fx7sge4ut78w== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="218521023" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="218521023" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 07:15:27 -0700 IronPort-SDR: PHl/gAhoCZLGvQ8+jRfi1Aj7+9i3q7M8IlbUE6c6MGOsXf8YdgSSQS8VT8xlUL2vnRKbTQDnCE n5nxMA683F+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="281656222" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.73]) ([10.237.72.73]) by fmsmga007.fm.intel.com with ESMTP; 31 Aug 2020 07:15:22 -0700 Subject: Re: [PATCH] mmc: sdhci-msm: Add retries when all tuning phases are found valid To: Douglas Anderson , Ulf Hansson Cc: vbadigan@codeaurora.org, Andy Gross , Asutosh Das , Bjorn Andersson , Chris Ball , Georgi Djakov , Venkat Gopalakrishnan , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org References: <20200827075809.1.If179abf5ecb67c963494db79c3bc4247d987419b@changeid> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Mon, 31 Aug 2020 17:14:45 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200827075809.1.If179abf5ecb67c963494db79c3bc4247d987419b@changeid> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/08/20 5:58 pm, Douglas Anderson wrote: > 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 Acked-by: Adrian Hunter > --- > > 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 b7e47107a31a..1b78106681e0 100644 > --- a/drivers/mmc/host/sdhci-msm.c > +++ b/drivers/mmc/host/sdhci-msm.c > @@ -1165,7 +1165,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; > @@ -1221,6 +1221,22 @@ static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode) > } 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) >