Skip to content

Commit

Permalink
mmc: core: Issue HPI in case the BKOPS timed out
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bean Huo authored and Ulf Hansson committed Aug 24, 2021
1 parent f6f6070 commit fe72d08
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/mmc/core/mmc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,15 @@ void mmc_run_bkops(struct mmc_card *card)
*/
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BKOPS_START, 1, MMC_BKOPS_TIMEOUT_MS);
if (err)
pr_warn("%s: Error %d starting bkops\n",
/*
* If the BKOPS timed out, the card is probably still busy in the
* R1_STATE_PRG. Rather than continue to wait, let's try to abort
* it with a HPI command to get back into R1_STATE_TRAN.
*/
if (err == -ETIMEDOUT && !mmc_interrupt_hpi(card))
pr_warn("%s: BKOPS aborted\n", mmc_hostname(card->host));
else if (err)
pr_warn("%s: Error %d running bkops\n",
mmc_hostname(card->host), err);

mmc_retune_release(card->host);
Expand Down

0 comments on commit fe72d08

Please sign in to comment.