Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp498091pxa; Thu, 27 Aug 2020 08:00:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/YcNA8KYp90sQzpiN3cjqNZplPlMCtHQr3PqLkYof/ge2okjwWI1MzS3xR5tzgAiXcHLm X-Received: by 2002:a05:6402:b99:: with SMTP id cf25mr7325608edb.235.1598540449626; Thu, 27 Aug 2020 08:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598540449; cv=none; d=google.com; s=arc-20160816; b=PBHEAOldLsgmJYx3mLmjIm6IpRgE+6eysw3U42m2UoXA+Wlod83KTz8b+9DhktT+7A ZNjJIAkZBGXuWj2IEj87YKFXe7+9D/zLLBrGWEmBDMPh47mHjKLWONxNZcZas+fjh5UN VVOeCctjVkeMhQIGRZl0B5S1/DCA53/pXX12jJDj+cubepBB6PSAqcRSoVB/AAFtCBOi zPz2UgxFPYYfRfakNJ3Lxstoo1osvFD+QQUp8oGZn2OpKySrZtGADbc3RgEl0SZtd5Lm r6D+xys5Zn5/9WDe+AmRv2hp2x+Dp2EcxJNPVA8fNdFKbCbvDv+4GLpI8osr/XQjaB9L foUQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=WuL1dIUKsXBKS74w29uHtR6KbU+GU+6B3P99Ro425TA=; b=O7rwCMGeykTMUUOCUDOOqEpqTtrkcizS9/NEH45+SqbVW2K+HTR9Q6tXH63AvqL5qJ DAtY6R5PrNIeBq4pxr1r215k2I01jfLSqnuKirVHyMjXQBwVR39vhewnC029r31zGin6 e840PzOKAL1dfqQGkbl2Fd32XkLbvWkYx8tblt/20Q9APg8fZcIIMglFdNMpWmEhfq7b DY1meBHHyNecYOiRueugPqoFLd+xOt/DvuyO/QzUcamywRWWO04HMKZd+uGFsvCCjQje ZcKFP0XGgV8Jort5ALCpIi2bwsL32ikfZpQkGfGKl+krC9obWU4CXNW8ka6EbQB46yfC 1vEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ghTzCFJC; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si1433837ejc.196.2020.08.27.08.00.26; Thu, 27 Aug 2020 08:00:49 -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=@chromium.org header.s=google header.b=ghTzCFJC; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726794AbgH0O74 (ORCPT + 99 others); Thu, 27 Aug 2020 10:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbgH0O7m (ORCPT ); Thu, 27 Aug 2020 10:59:42 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2306DC061232 for ; Thu, 27 Aug 2020 07:59:42 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id y206so3702729pfb.10 for ; Thu, 27 Aug 2020 07:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WuL1dIUKsXBKS74w29uHtR6KbU+GU+6B3P99Ro425TA=; b=ghTzCFJCnPmQ+DImiDILpCS6WX5yhT8MFpZj9RUpmJjv3EXxiJN5WUqT8L4MXcuwxD pDNzURkebg9gNy52q5ZsI/Dui3sJhS0Z/2W9PKez79BQdhhRwnf5Mb6p8J4gRu4Gxh8v SveFSFYljkwpakvd+DNDZCZJZwc8Vmf6chJRE= 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:mime-version :content-transfer-encoding; bh=WuL1dIUKsXBKS74w29uHtR6KbU+GU+6B3P99Ro425TA=; b=GJFowid9+fTCMqZtWfdeCrcAej47JBoNLAiL3pZCDJ860MdrLQ3yo2VUxMM2uT1j1d b9H7BXK0r7iux3sgeDoBS6dUVp9fImOjuKE+g/GkOAnn5sKv9OQH0exzDB432kU5jQVf 8tM6sHTg/dV6U3yKy5D+p50UH7WOvpgQmN6F6yTt/SeAEf2i0SWcWshakYQmtr2vD1f2 D77Hx0GAbGfr+ifbP7x7qXpDl7nd4Bn6TmBl6Y/lBbojYaK3ool8RgkrzXtFmW/Fyz4s oqPJhogB4XrzZpIgMBsnqiDGvJMKhGhHtJ6fushbDyhqep8Hx0A9yzIFhwx8k5WwSaPM 8C4A== X-Gm-Message-State: AOAM532zFXC41FnkZDlowVPuYKnmuyNw39Ll9r+m/XVn2k3kIDQkLALh eNeu9OcI7kw4Ed5XDdH7s7eqvw== X-Received: by 2002:aa7:9427:: with SMTP id y7mr17053693pfo.12.1598540381631; Thu, 27 Aug 2020 07:59:41 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id u123sm3113198pfb.209.2020.08.27.07.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2020 07:59:41 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson Cc: vbadigan@codeaurora.org, Douglas Anderson , Adrian Hunter , 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 Subject: [PATCH] mmc: sdhci-msm: Add retries when all tuning phases are found valid Date: Thu, 27 Aug 2020 07:58:41 -0700 Message-Id: <20200827075809.1.If179abf5ecb67c963494db79c3bc4247d987419b@changeid> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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