Skip to contentSkip to conversation

mmc: core: Improve fallback to speed modes if eMMC HS200 fails

PATCH In review Ulf Hansson 2 participants 4 messages Mar 3, 2022 – Mar 15, 2022 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: core: Improve fallback to speed modes if eMMC HS200 fails

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.

---
 drivers/mmc/core/mmc.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/mmc/core/mmc.c +13 -3
index 141f851c9f58..6e7db45cb8e0 100644
@@ -1518,13 +1518,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;
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 8 lines · Ulf Hansson

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.

Quoted 6 lines

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.

Heiner, does this solve your problems? Can you perhaps run some tests at your side to see how it works for you?

Kind regards
Uffe

Quoted 38 lines
---
 drivers/mmc/core/mmc.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/mmc/core/mmc.c +13 -4
index 141f851c9f58..6e7db45cb8e0 100644
@@ -1518,13 +1518,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;
 
--

2.25.1

Tested-by
#2 lore raw
Quoted 13 lines · Ulf Hansson
Quoted 12 lines · Ulf Hansson

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.

Quoted 6 lines
Quoted 2 lines

Heiner, does this solve your problems? Can you perhaps run some tests at your side to see how it works for you?

Quoted 3 lines

Kind regards
Uffe

Heiner

Quoted 38 lines
Quoted 38 lines
---
 drivers/mmc/core/mmc.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/mmc/core/mmc.c +13 -4
index 141f851c9f58..6e7db45cb8e0 100644
@@ -1518,13 +1518,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;
 
--

2.25.1

#3 lore raw
Quoted 15 lines · Heiner Kallweit
Quoted 13 lines · Ulf Hansson
Quoted 12 lines · Ulf Hansson

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.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Heiner, does this solve your problems? Can you perhaps run some tests at your side to see how it works for you?

Thanks! Patch applied for next.

[...]

Kind regards
Uffe