Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp318494pxk; Wed, 2 Sep 2020 02:05:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6GI6BTlsZbRIOfSRmxd0l/hEuv5ROBNqRaTroGpp2NxpNk7JIyLwJzQJuCgANvZkaoGuQ X-Received: by 2002:aa7:cb83:: with SMTP id r3mr1935353edt.35.1599037522490; Wed, 02 Sep 2020 02:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599037522; cv=none; d=google.com; s=arc-20160816; b=huYiyVlf6/CgsWcf/FMoSl1fH9MfmyXgywAE7Jz1+GkH63K6ZoAYcBL+YrhdIiNPnq CrDtyLULGiG/63N1eE43asZDQd1XbVcQzlhubs7gETy5h7cqquabFLR4FcpkfNI3nuHc /xAkKTSSHI7bbl5iTKqfYmcVv7+mr/bMw3U4LIhnCmz5gB3gUG4qIJe4aXDwEN9qMI1c GwOqiqNpchiYY/CXF9nF3Sozjumk/NWZZRccvsVnazRcFloruHQaUjlckw1DqNUGs94j 6moM/EDNX41vJy6rkCnEtAHtjc4N15kox+tDo2xfNnHYvzzWHOncnzH64l5zxkrIcKzf 5ErA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=upktra/6N5emKh7zvhc7gnHBaffqMLEbCV10tmOPScE=; b=nEsK2Pi4RZslfrVHkJXef4sUdHIt5qus3R+Q3jUESGUiKxvNC4hblV1fTaofeLYLY4 VuMtCh4BxhvXDPzT1lIeTtfk59ERUxadmVOPyZ7B5oIRR8eVR2ASW2/27nv+UpnKUqFg Sd9CG04bOLsL0ZlqC5W+EMHBF7s47axocyIXN24W4ZjprM9ce4YNKv/8bGSUkevLJRsu JBFVBRDcaZEnrWz8kA7s1C0Ol0H93BEtGK8O6ypNnRFqIGCzq6MBjmd9C8OnZcPz2Q8u b2mcTSnjow2dC2jfC5UND0OYdIQoYM4d42nFajwWGwnaSwGd1/wgZ4c9z6EeVUIyWS42 7dvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ccyj7iwV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d15si2338163ejr.178.2020.09.02.02.04.59; Wed, 02 Sep 2020 02:05:22 -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=@linaro.org header.s=google header.b=ccyj7iwV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726802AbgIBJED (ORCPT + 99 others); Wed, 2 Sep 2020 05:04:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbgIBJDj (ORCPT ); Wed, 2 Sep 2020 05:03:39 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8193EC061244 for ; Wed, 2 Sep 2020 02:03:39 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id z46so1334546uac.13 for ; Wed, 02 Sep 2020 02:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=upktra/6N5emKh7zvhc7gnHBaffqMLEbCV10tmOPScE=; b=ccyj7iwV1I8JjY1UHxeji0yJ0pPCBmQh8EC8+5I+78EMJ9CJTqGDgzaHKVJGcpJGUL hN/9an7B8iC9RUmg2KYdm3DT1NQjzLHOhZdZzmiOWNfSIO4AtpSo8XFy+Nv81tpUbOgi xtUNNIXTRFi/ir0DDVeTakmrL/ktIE7C9ruWEnSo7RQw9vytDoJIQto9IHkd8NgzSSua HELp1r21BKjxocLn6wedYf4i5s2I7HlGoXQzcuCbbHY2lZtvhg40gFv4d0xC1bBUzeAi Ey+JweUb4u3rDmoX4NS3Y6z864knovorET27+g1K4ysBlA5wfSwI+z1sFEoICVsd55Uz 8Deg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=upktra/6N5emKh7zvhc7gnHBaffqMLEbCV10tmOPScE=; b=e5zAK5S7Uxqhvh2PQ2gBwcno3IzJh1GpN9/qWWOGaw0+rWFaa/pPHhP7JNdXHp7kr/ NDcVE7aJyB1MuB0eBzPIWByPL4gYw/DVqLWSAK+lF0oUy8nFD+PdhCpGztWCdtPrPT8d Cy3/dMgNWgG4coU14nN59c761cB7JmmN2NaXk1ID9tt7WLiEexV9gxtcQEVHszc0bZlt ySi2MP8aoO/6q+4LfB8oXPBGVEK8+1qqgZE/30HCetAXgK2RzdZqcqQbLKsHf/bHYlW9 QSWjBuqciUSsfZD6hYIpYliaS+fS53zhtG4XiVYxqWTK4W0jHdh51//uaJr9OPUk79YH Ic3w== X-Gm-Message-State: AOAM530oTsHSC1Hd3wsKrsNB605zTNzwujQbW55ISXbP0bVuwPpEGXWz QASHpfg/GK8YiTPLcaE7j79iJ0HMchWcSWZl7BfN+A== X-Received: by 2002:a9f:2431:: with SMTP id 46mr3660526uaq.129.1599037418663; Wed, 02 Sep 2020 02:03:38 -0700 (PDT) MIME-Version: 1.0 References: <20200827075809.1.If179abf5ecb67c963494db79c3bc4247d987419b@changeid> In-Reply-To: <20200827075809.1.If179abf5ecb67c963494db79c3bc4247d987419b@changeid> From: Ulf Hansson Date: Wed, 2 Sep 2020 11:03:02 +0200 Message-ID: Subject: Re: [PATCH] mmc: sdhci-msm: Add retries when all tuning phases are found valid To: Douglas Anderson Cc: Veerabhadrarao Badiganti , Adrian Hunter , Andy Gross , Asutosh Das , Bjorn Andersson , Chris Ball , Georgi Djakov , Venkat Gopalakrishnan , linux-arm-msm , Linux Kernel Mailing List , "linux-mmc@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 Aug 2020 at 16:59, 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 Applied for fixes and by adding a stable tag, thanks! Kind regards Uffe > --- > > 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) > -- > 2.28.0.297.g1956fa8f8d-goog >