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

mmc: core: Issue HPI in case the BKOPS timed out

If the BKOPS timed out, the card is probably still busy in the
R1_STATE_PRG. Rather than continue as nothing has happened and hitting and
error for the next command being sent, let's try to abort the running BKOPS
by sending a HPI command to get back into R1_STATE_TRAN.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Link: https://lore.kernel.org/r/20210817224208.153652-2-huobean@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Bean Huo and committed by
Ulf Hansson
fe72d08a f6f60707

+9 -2
+9 -2
drivers/mmc/core/mmc_ops.c
··· 959 959 */ 960 960 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 961 961 EXT_CSD_BKOPS_START, 1, MMC_BKOPS_TIMEOUT_MS); 962 - if (err) 963 - pr_warn("%s: Error %d starting bkops\n", 962 + /* 963 + * If the BKOPS timed out, the card is probably still busy in the 964 + * R1_STATE_PRG. Rather than continue to wait, let's try to abort 965 + * it with a HPI command to get back into R1_STATE_TRAN. 966 + */ 967 + if (err == -ETIMEDOUT && !mmc_interrupt_hpi(card)) 968 + pr_warn("%s: BKOPS aborted\n", mmc_hostname(card->host)); 969 + else if (err) 970 + pr_warn("%s: Error %d running bkops\n", 964 971 mmc_hostname(card->host), err); 965 972 966 973 mmc_retune_release(card->host);