All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mmc: core: Don't set HS200 clock rate prematurely
@ 2022-04-22  0:23 Brian Norris
  2022-04-22  9:10 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Norris @ 2022-04-22  0:23 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Lin, linux-mmc, Douglas Anderson, Luca Weiss, linux-kernel,
	Heiner Kallweit, Adrian Hunter, Brian Norris

Commit 1c7ec586fe55 ("mmc: core: Set HS clock speed before sending HS
CMD13") fixes problems with certain eMMC, but introduced new ones with
others:

  qcom-msm8974-fairphone-fp2:

  [    1.868608] mmc0: SDHCI controller on f9824900.sdhci [f9824900.sdhci] using ADMA 64-bit
  [    1.925220] mmc0: mmc_select_hs200 failed, error -110
  [    1.925285] mmc0: error -110 whilst initialising MMC card

It appears we've overshot the acceptable clock rate here; while JESD84
suggests that we can bump to 52 MHz before switching (CMD6) to HS400, it
does *not* say we can switch to 200 MHz before switching to HS200 (see
page 45 / table 28). Use the HS bounds (typically 52 MHz) instead of the
HS200 bounds (which are only applicable after we successfully switch).

Link: https://lore.kernel.org/lkml/11962455.O9o76ZdvQC@g550jk/
Fixes: 1c7ec586fe55 ("mmc: core: Set HS clock speed before sending HS CMD13")
Reported-by: Luca Weiss <luca@z3ntu.xyz>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Apologies for the quick resend; I fumbled the commit/send, even though I
had already updated the comments...

Changes in v2:
 * Updated comments

 drivers/mmc/core/mmc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 9ab915b5737a..82ca62c8669c 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1485,13 +1485,15 @@ static int mmc_select_hs200(struct mmc_card *card)
 			goto err;
 
 		/*
-		 * Bump to HS200 timing and frequency. Some cards don't
-		 * handle SEND_STATUS reliably at the initial frequency.
+		 * Bump to HS timing and frequency. Some cards don't handle
+		 * SEND_STATUS reliably at the initial frequency.
+		 * NB: We can't move to full (HS200) speeds until after we've
+		 * successfully switched over.
 		 */
 		old_timing = host->ios.timing;
 		old_clock = host->ios.clock;
 		mmc_set_timing(host, MMC_TIMING_MMC_HS200);
-		mmc_set_bus_speed(card);
+		mmc_set_clock(card->host, card->ext_csd.hs_max_dtr);
 
 		/*
 		 * For HS200, CRC errors are not a reliable way to know the
-- 
2.36.0.rc2.479.g8af0fa9b8e-goog


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

* Re: [PATCH v2] mmc: core: Don't set HS200 clock rate prematurely
  2022-04-22  0:23 [PATCH v2] mmc: core: Don't set HS200 clock rate prematurely Brian Norris
@ 2022-04-22  9:10 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2022-04-22  9:10 UTC (permalink / raw)
  To: Brian Norris
  Cc: Shawn Lin, linux-mmc, Douglas Anderson, Luca Weiss, linux-kernel,
	Heiner Kallweit, Adrian Hunter

On Fri, 22 Apr 2022 at 02:23, Brian Norris <briannorris@chromium.org> wrote:
>
> Commit 1c7ec586fe55 ("mmc: core: Set HS clock speed before sending HS
> CMD13") fixes problems with certain eMMC, but introduced new ones with
> others:
>
>   qcom-msm8974-fairphone-fp2:
>
>   [    1.868608] mmc0: SDHCI controller on f9824900.sdhci [f9824900.sdhci] using ADMA 64-bit
>   [    1.925220] mmc0: mmc_select_hs200 failed, error -110
>   [    1.925285] mmc0: error -110 whilst initialising MMC card
>
> It appears we've overshot the acceptable clock rate here; while JESD84
> suggests that we can bump to 52 MHz before switching (CMD6) to HS400, it
> does *not* say we can switch to 200 MHz before switching to HS200 (see
> page 45 / table 28). Use the HS bounds (typically 52 MHz) instead of the
> HS200 bounds (which are only applicable after we successfully switch).
>
> Link: https://lore.kernel.org/lkml/11962455.O9o76ZdvQC@g550jk/
> Fixes: 1c7ec586fe55 ("mmc: core: Set HS clock speed before sending HS CMD13")
> Reported-by: Luca Weiss <luca@z3ntu.xyz>
> Signed-off-by: Brian Norris <briannorris@chromium.org>

Rather than applying this incremental patch, I decided to drop the
offending commit from my branch. Please submit a new version of that
patch and make sure to incorporate credits and information provided by
Luca, as a part of the new commit message.

The main reason for this step is that I think we want a clean patch
that we can use for stable kernels too.

Moreover, this also means you can drop the changes in mmc_set_clock()
that was introduced in 1c7ec586fe55().

Kind regards
Uffe

> ---
> Apologies for the quick resend; I fumbled the commit/send, even though I
> had already updated the comments...
>
> Changes in v2:
>  * Updated comments
>
>  drivers/mmc/core/mmc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 9ab915b5737a..82ca62c8669c 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1485,13 +1485,15 @@ static int mmc_select_hs200(struct mmc_card *card)
>                         goto err;
>
>                 /*
> -                * Bump to HS200 timing and frequency. Some cards don't
> -                * handle SEND_STATUS reliably at the initial frequency.
> +                * Bump to HS timing and frequency. Some cards don't handle
> +                * SEND_STATUS reliably at the initial frequency.
> +                * NB: We can't move to full (HS200) speeds until after we've
> +                * successfully switched over.
>                  */
>                 old_timing = host->ios.timing;
>                 old_clock = host->ios.clock;
>                 mmc_set_timing(host, MMC_TIMING_MMC_HS200);
> -               mmc_set_bus_speed(card);
> +               mmc_set_clock(card->host, card->ext_csd.hs_max_dtr);
>
>                 /*
>                  * For HS200, CRC errors are not a reliable way to know the
> --
> 2.36.0.rc2.479.g8af0fa9b8e-goog
>

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

end of thread, other threads:[~2022-04-22  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22  0:23 [PATCH v2] mmc: core: Don't set HS200 clock rate prematurely Brian Norris
2022-04-22  9:10 ` 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.