Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: core: fix dead loop of mmc_retune

When get a CRC error, start the mmc_retune, it will issue CMD19/CMD21
to do tune, assume there were 10 clock phase need to try, phase 0 to
phase 6 is ok, phase 7 to phase 9 is NG, we try it from 0 to 9, so
the last CMD19/CMD21 will get CRC error, host->need_retune was set and
cause mmc_retune was called, then dead loop of mmc_retune

Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: bd11e8bd03ca ("mmc: core: Flag re-tuning is needed on CRC errors")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Chaotian Jing and committed by
Ulf Hansson
031277d4 fd546ee6

+4 -2
+4 -2
drivers/mmc/core/core.c
··· 134 134 int err = cmd->error; 135 135 136 136 /* Flag re-tuning needed on CRC errors */ 137 - if (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) || 137 + if ((cmd->opcode != MMC_SEND_TUNING_BLOCK && 138 + cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200) && 139 + (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) || 138 140 (mrq->data && mrq->data->error == -EILSEQ) || 139 - (mrq->stop && mrq->stop->error == -EILSEQ)) 141 + (mrq->stop && mrq->stop->error == -EILSEQ))) 140 142 mmc_retune_needed(host); 141 143 142 144 if (err && cmd->retries && mmc_host_is_spi(host)) {