Skip to content

Commit

Permalink
mmc: core: Improve fallback to speed modes if eMMC HS200 fails
Browse files Browse the repository at this point in the history
In the error path of mmc_select_hs200() we are trying our best to restore
the card/host into a valid state. This makes sense, especially if we
encounter a simple switch error (-EBADMSG). However, rather than then
continue with using the legacy speed mode, let's try the other better speed
modes first. Additionally, let's update the card->mmc_avail_type to avoid
us from trying a broken HS200 mode again.

In an Amlogic S905W based TV box where the switch to HS200 mode fails for
the eMMC, this allows us to use the eMMC in DDR mode in favor of the legacy
mode, which greatly improves the performance.

Suggested-by: Heiner Kallweit <[email protected]>
Signed-off-by: Ulf Hansson <[email protected]>
Tested-by: Heiner Kallweit <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
storulf committed Mar 15, 2022
1 parent e23b2f5 commit 3b6c472
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1523,13 +1523,23 @@ static int mmc_select_timing(struct mmc_card *card)
if (!mmc_can_ext_csd(card))
goto bus_speed;

if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400ES)
if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400ES) {
err = mmc_select_hs400es(card);
else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200)
goto out;
}

if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200) {
err = mmc_select_hs200(card);
else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS)
if (err == -EBADMSG)
card->mmc_avail_type &= ~EXT_CSD_CARD_TYPE_HS200;
else
goto out;
}

if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS)
err = mmc_select_hs(card);

out:
if (err && err != -EBADMSG)
return err;

Expand Down

0 comments on commit 3b6c472

Please sign in to comment.