diff mbox series

mmc: mmc: Fix partition switch time

Message ID 168bbfd6-0c5b-5ace-ab41-402e7937c46e@intel.com
State New
Headers show
Series mmc: mmc: Fix partition switch time | expand

Commit Message

Adrian Hunter March 3, 2021, 9:26 a.m. UTC
Avoid the following warning by always defining partition switch time:

 [    3.209874] mmc1: unspecified timeout for CMD6 - use generic
 [    3.222780] ------------[ cut here ]------------
 [    3.233363] WARNING: CPU: 1 PID: 111 at drivers/mmc/core/mmc_ops.c:575 __mmc_switch+0x200/0x204

Reported-by: Paul Fertser <fercerpav@gmail.com>
Fixes: 1c447116d017 ("mmc: mmc: Fix partition switch timeout for some eMMCs")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/core/mmc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Ulf Hansson March 4, 2021, 1:50 p.m. UTC | #1
On Wed, 3 Mar 2021 at 10:26, Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> Avoid the following warning by always defining partition switch time:
>
>  [    3.209874] mmc1: unspecified timeout for CMD6 - use generic
>  [    3.222780] ------------[ cut here ]------------
>  [    3.233363] WARNING: CPU: 1 PID: 111 at drivers/mmc/core/mmc_ops.c:575 __mmc_switch+0x200/0x204
>
> Reported-by: Paul Fertser <fercerpav@gmail.com>
> Fixes: 1c447116d017 ("mmc: mmc: Fix partition switch timeout for some eMMCs")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Applied for next and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/mmc.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 0d80b72ddde8..8741271d3971 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -423,10 +423,6 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
>
>                 /* EXT_CSD value is in units of 10ms, but we store in ms */
>                 card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME];
> -               /* Some eMMC set the value too low so set a minimum */
> -               if (card->ext_csd.part_time &&
> -                   card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
> -                       card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
>
>                 /* Sleep / awake timeout in 100ns units */
>                 if (sa_shift > 0 && sa_shift <= 0x17)
> @@ -616,6 +612,17 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
>                 card->ext_csd.data_sector_size = 512;
>         }
>
> +       /*
> +        * GENERIC_CMD6_TIME is to be used "unless a specific timeout is defined
> +        * when accessing a specific field", so use it here if there is no
> +        * PARTITION_SWITCH_TIME.
> +        */
> +       if (!card->ext_csd.part_time)
> +               card->ext_csd.part_time = card->ext_csd.generic_cmd6_time;
> +       /* Some eMMC set the value too low so set a minimum */
> +       if (card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
> +               card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
> +
>         /* eMMC v5 or later */
>         if (card->ext_csd.rev >= 7) {
>                 memcpy(card->ext_csd.fwrev, &ext_csd[EXT_CSD_FIRMWARE_VERSION],
> --
> 2.17.1
>
>
diff mbox series

Patch

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 0d80b72ddde8..8741271d3971 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -423,10 +423,6 @@  static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
 
 		/* EXT_CSD value is in units of 10ms, but we store in ms */
 		card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME];
-		/* Some eMMC set the value too low so set a minimum */
-		if (card->ext_csd.part_time &&
-		    card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
-			card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
 
 		/* Sleep / awake timeout in 100ns units */
 		if (sa_shift > 0 && sa_shift <= 0x17)
@@ -616,6 +612,17 @@  static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
 		card->ext_csd.data_sector_size = 512;
 	}
 
+	/*
+	 * GENERIC_CMD6_TIME is to be used "unless a specific timeout is defined
+	 * when accessing a specific field", so use it here if there is no
+	 * PARTITION_SWITCH_TIME.
+	 */
+	if (!card->ext_csd.part_time)
+		card->ext_csd.part_time = card->ext_csd.generic_cmd6_time;
+	/* Some eMMC set the value too low so set a minimum */
+	if (card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
+		card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
+
 	/* eMMC v5 or later */
 	if (card->ext_csd.rev >= 7) {
 		memcpy(card->ext_csd.fwrev, &ext_csd[EXT_CSD_FIRMWARE_VERSION],