Skip to content

Commit 9d5dcef

Browse files
diandersstorulf
authored andcommitted
mmc: sdhci-msm: Add retries when all tuning phases are found valid
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: 415b5a7 ("mmc: sdhci-msm: Add platform_execute_tuning implementation") Signed-off-by: Douglas Anderson <[email protected]> Reviewed-by: Veerabhadrarao Badiganti <[email protected]> Acked-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/20200827075809.1.If179abf5ecb67c963494db79c3bc4247d987419b@changeid Signed-off-by: Ulf Hansson <[email protected]>
1 parent 2cf9bfe commit 9d5dcef

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

drivers/mmc/host/sdhci-msm.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ static void sdhci_msm_set_cdr(struct sdhci_host *host, bool enable)
11661166
static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode)
11671167
{
11681168
struct sdhci_host *host = mmc_priv(mmc);
1169-
int tuning_seq_cnt = 3;
1169+
int tuning_seq_cnt = 10;
11701170
u8 phase, tuned_phases[16], tuned_phase_cnt = 0;
11711171
int rc;
11721172
struct mmc_ios ios = host->mmc->ios;
@@ -1222,6 +1222,22 @@ static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode)
12221222
} while (++phase < ARRAY_SIZE(tuned_phases));
12231223

12241224
if (tuned_phase_cnt) {
1225+
if (tuned_phase_cnt == ARRAY_SIZE(tuned_phases)) {
1226+
/*
1227+
* All phases valid is _almost_ as bad as no phases
1228+
* valid. Probably all phases are not really reliable
1229+
* but we didn't detect where the unreliable place is.
1230+
* That means we'll essentially be guessing and hoping
1231+
* we get a good phase. Better to try a few times.
1232+
*/
1233+
dev_dbg(mmc_dev(mmc), "%s: All phases valid; try again\n",
1234+
mmc_hostname(mmc));
1235+
if (--tuning_seq_cnt) {
1236+
tuned_phase_cnt = 0;
1237+
goto retry;
1238+
}
1239+
}
1240+
12251241
rc = msm_find_most_appropriate_phase(host, tuned_phases,
12261242
tuned_phase_cnt);
12271243
if (rc < 0)

0 commit comments

Comments
 (0)