diff mbox series

mmc: core: improve fallback in mmc_select_timing()

Message ID fae9ee4b-6b93-95ac-abf3-f97c62e07b9d@gmail.com (mailing list archive)
State New, archived
Headers show
Series mmc: core: improve fallback in mmc_select_timing() | expand

Commit Message

Heiner Kallweit Feb. 18, 2022, 7 a.m. UTC
I have a system (cheap Amlogic S905W based TV box) where the eMMC chip
refuses to switch to HS200 timing. That's not nice, but my bigger
problem is that the system then falls back to the very slow default
mode, even though DDR52 is supported and works well.

Therefore, if setting a mode fails with EBADMSG (switch error), try the
next (in descending performance order) mode instead of immediately
falling back to the slowest mode.

With the patch it looks like this on my system:

mmc1: mmc_select_hs200 failed, error -74
mmc1: new DDR MMC card at address 0001
mmcblk1: mmc1:0001 DG4008 7.28 GiB

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/mmc/core/mmc.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

Comments

Ulf Hansson March 1, 2022, 1:50 p.m. UTC | #1
On Fri, 18 Feb 2022 at 08:00, Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> I have a system (cheap Amlogic S905W based TV box) where the eMMC chip
> refuses to switch to HS200 timing. That's not nice, but my bigger
> problem is that the system then falls back to the very slow default
> mode, even though DDR52 is supported and works well.
>
> Therefore, if setting a mode fails with EBADMSG (switch error), try the
> next (in descending performance order) mode instead of immediately
> falling back to the slowest mode.
>
> With the patch it looks like this on my system:
>
> mmc1: mmc_select_hs200 failed, error -74
> mmc1: new DDR MMC card at address 0001
> mmcblk1: mmc1:0001 DG4008 7.28 GiB
>

Overall, I think the approach seems very much reasonable!

Although, I want to have a closer look at the impact on the different
scenarios, as mmc_select_timing() is being called during power
management and reset too.

Allow me a day or so, then I will get back to this, either with some
more detailed suggestions or I may post a patch.

Kind regards
Uffe

> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/mmc/core/mmc.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index bbbbcaf70..c0272192d 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1523,11 +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)
> +               if (!err)
> +                       goto bus_speed;
> +               if (err != -EBADMSG)
> +                       return err;
> +       }
> +
> +       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)
> +                       goto bus_speed;
> +               if (err != -EBADMSG)
> +                       return err;
> +       }
> +
> +       if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS)
>                 err = mmc_select_hs(card);
>
>         if (err && err != -EBADMSG)
> --
> 2.35.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index bbbbcaf70..c0272192d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1523,11 +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)
+		if (!err)
+			goto bus_speed;
+		if (err != -EBADMSG)
+			return err;
+	}
+
+	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)
+			goto bus_speed;
+		if (err != -EBADMSG)
+			return err;
+	}
+
+	if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS)
 		err = mmc_select_hs(card);
 
 	if (err && err != -EBADMSG)