All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: core: Improve fallback to speed modes if eMMC HS200 fails
@ 2022-03-03 16:45 Ulf Hansson
  2022-03-14 10:54 ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2022-03-03 16:45 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Heiner Kallweit
  Cc: Adrian Hunter, Wolfram Sang, Yann Gautier, linux-kernel

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 <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/mmc.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 141f851c9f58..6e7db45cb8e0 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: core: Improve fallback to speed modes if eMMC HS200 fails
  2022-03-03 16:45 [PATCH] mmc: core: Improve fallback to speed modes if eMMC HS200 fails Ulf Hansson
@ 2022-03-14 10:54 ` Ulf Hansson
  2022-03-14 22:02   ` Heiner Kallweit
  0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2022-03-14 10:54 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: linux-mmc, Adrian Hunter, Wolfram Sang, Yann Gautier,
	linux-kernel, Ulf Hansson

On Thu, 3 Mar 2022 at 17:45, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> 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 <hkallweit1@gmail.com>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

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

> ---
>  drivers/mmc/core/mmc.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 141f851c9f58..6e7db45cb8e0 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: core: Improve fallback to speed modes if eMMC HS200 fails
  2022-03-14 10:54 ` Ulf Hansson
@ 2022-03-14 22:02   ` Heiner Kallweit
  2022-03-15 12:22     ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Heiner Kallweit @ 2022-03-14 22:02 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Adrian Hunter, Wolfram Sang, Yann Gautier, linux-kernel

On 14.03.2022 11:54, Ulf Hansson wrote:
> On Thu, 3 Mar 2022 at 17:45, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>>
>> 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 <hkallweit1@gmail.com>
>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> Heiner, does this solve your problems? Can you perhaps run some tests
> at your side to see how it works for you?
> 

Tested-by: Heiner Kallweit <hkallweit1@gmail.com>

> Kind regards
> Uffe
> 
Heiner

>> ---
>>  drivers/mmc/core/mmc.c | 16 +++++++++++++---
>>  1 file changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index 141f851c9f58..6e7db45cb8e0 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -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
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: core: Improve fallback to speed modes if eMMC HS200 fails
  2022-03-14 22:02   ` Heiner Kallweit
@ 2022-03-15 12:22     ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2022-03-15 12:22 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: linux-mmc, Adrian Hunter, Wolfram Sang, Yann Gautier, linux-kernel

On Mon, 14 Mar 2022 at 23:02, Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> On 14.03.2022 11:54, Ulf Hansson wrote:
> > On Thu, 3 Mar 2022 at 17:45, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >>
> >> 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 <hkallweit1@gmail.com>
> >> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> >
> > Heiner, does this solve your problems? Can you perhaps run some tests
> > at your side to see how it works for you?
> >
>
> Tested-by: Heiner Kallweit <hkallweit1@gmail.com>

Thanks! Patch applied for next.

[...]

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-15 12:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03 16:45 [PATCH] mmc: core: Improve fallback to speed modes if eMMC HS200 fails Ulf Hansson
2022-03-14 10:54 ` Ulf Hansson
2022-03-14 22:02   ` Heiner Kallweit
2022-03-15 12:22     ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.