Skip to content

Commit fe72d08

Browse files
beanhuostorulf
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent f6f6070 commit fe72d08

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/mmc/core/mmc_ops.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,15 @@ void mmc_run_bkops(struct mmc_card *card)
959959
*/
960960
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
961961
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",
964971
mmc_hostname(card->host), err);
965972

966973
mmc_retune_release(card->host);

0 commit comments

Comments
 (0)