diff mbox series

[v2,1/1] mmc: core: increase the number of retries of the ACMD41

Message ID 20240417084500.152486-1-xiaokeqinhealth@126.com (mailing list archive)
State New
Headers show
Series [v2,1/1] mmc: core: increase the number of retries of the ACMD41 | expand

Commit Message

Felix Qin April 17, 2024, 8:45 a.m. UTC
Extensive testing has shown that a few specific SD cards require
an increase in the number of command retries to successfully
initialize.

More info:
Platform: Rockchip SoC + DW Multimedia host Controller
SD card: Xvv microSD CMH34A17TMA12 (Made in Korea)
Note: The SD card is custom-made by the customer in collaboration
with the wafer foundry.

Signed-off-by: Felix Qin <xiaokeqinhealth@126.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
---
v2: Add more info
---
---
 drivers/mmc/core/sd_ops.c | 4 ++--
 drivers/mmc/core/sd_ops.h | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

Comments

Dragan Simic April 17, 2024, 9:10 a.m. UTC | #1
On 2024-04-17 10:45, Felix Qin wrote:
> Extensive testing has shown that a few specific SD cards require
> an increase in the number of command retries to successfully
> initialize.
> 
> More info:
> Platform: Rockchip SoC + DW Multimedia host Controller
> SD card: Xvv microSD CMH34A17TMA12 (Made in Korea)
> Note: The SD card is custom-made by the customer in collaboration
> with the wafer foundry.
> 
> Signed-off-by: Felix Qin <xiaokeqinhealth@126.com>
> Acked-by: Avri Altman <avri.altman@wdc.com>

Looking good to me.  Thanks for including the additional details.

Reviewed-by: Dragan Simic <dsimic@manjaro.org>

> ---
> v2: Add more info
> ---
> ---
>  drivers/mmc/core/sd_ops.c | 4 ++--
>  drivers/mmc/core/sd_ops.h | 8 ++++++++
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
> index a59cd592f06e..b3b6e8725b80 100644
> --- a/drivers/mmc/core/sd_ops.c
> +++ b/drivers/mmc/core/sd_ops.c
> @@ -127,7 +127,7 @@ int mmc_send_app_op_cond(struct mmc_host *host,
> u32 ocr, u32 *rocr)
>  		cmd.arg = ocr;
>  	cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
> 
> -	for (i = 100; i; i--) {
> +	for (i = SD_APP_OP_COND_RETRIES; i; i--) {
>  		err = mmc_wait_for_app_cmd(host, NULL, &cmd);
>  		if (err)
>  			break;
> @@ -147,7 +147,7 @@ int mmc_send_app_op_cond(struct mmc_host *host,
> u32 ocr, u32 *rocr)
> 
>  		err = -ETIMEDOUT;
> 
> -		mmc_delay(10);
> +		mmc_delay(SD_APP_OP_COND_INTERVAL);
>  	}
> 
>  	if (!i)
> diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h
> index 7667fc223b74..80c5c836ccd1 100644
> --- a/drivers/mmc/core/sd_ops.h
> +++ b/drivers/mmc/core/sd_ops.h
> @@ -10,6 +10,14 @@
> 
>  #include <linux/types.h>
> 
> +/*
> + * Extensive testing has shown that a few specific SD cards require
> + * an increase in the number of command retries to successfully
> + * initialize.
> + */
> +#define SD_APP_OP_COND_RETRIES  200
> +#define SD_APP_OP_COND_INTERVAL 10	/* millisecond */
> +
>  struct mmc_card;
>  struct mmc_host;
Ulf Hansson April 25, 2024, 4:22 p.m. UTC | #2
On Wed, 17 Apr 2024 at 10:45, Felix Qin <xiaokeqinhealth@126.com> wrote:
>
> Extensive testing has shown that a few specific SD cards require
> an increase in the number of command retries to successfully
> initialize.
>
> More info:
> Platform: Rockchip SoC + DW Multimedia host Controller
> SD card: Xvv microSD CMH34A17TMA12 (Made in Korea)
> Note: The SD card is custom-made by the customer in collaboration
> with the wafer foundry.
>
> Signed-off-by: Felix Qin <xiaokeqinhealth@126.com>
> Acked-by: Avri Altman <avri.altman@wdc.com>
> ---
> v2: Add more info
> ---
> ---
>  drivers/mmc/core/sd_ops.c | 4 ++--
>  drivers/mmc/core/sd_ops.h | 8 ++++++++
>  2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
> index a59cd592f06e..b3b6e8725b80 100644
> --- a/drivers/mmc/core/sd_ops.c
> +++ b/drivers/mmc/core/sd_ops.c
> @@ -127,7 +127,7 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
>                 cmd.arg = ocr;
>         cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
>
> -       for (i = 100; i; i--) {
> +       for (i = SD_APP_OP_COND_RETRIES; i; i--) {
>                 err = mmc_wait_for_app_cmd(host, NULL, &cmd);
>                 if (err)
>                         break;
> @@ -147,7 +147,7 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
>
>                 err = -ETIMEDOUT;
>
> -               mmc_delay(10);
> +               mmc_delay(SD_APP_OP_COND_INTERVAL);

Rather than extending the current loop above, I would prefer if we can
move to use __mmc_poll_for_busy(), similar to what we also do for
(e)MMC and MMC_SEND_OP_COND, for example.

To help out a bit, I just posted a patch [1] making that conversion.
Please try it out and explore what values you need to set for the new
defines, "SD_APP_OP_COND_PERIOD_US" and "SD_APP_OP_COND_TIMEOUT_MS",
to make it work for you.

>         }
>
>         if (!i)
> diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h
> index 7667fc223b74..80c5c836ccd1 100644
> --- a/drivers/mmc/core/sd_ops.h
> +++ b/drivers/mmc/core/sd_ops.h
> @@ -10,6 +10,14 @@
>
>  #include <linux/types.h>
>
> +/*
> + * Extensive testing has shown that a few specific SD cards require
> + * an increase in the number of command retries to successfully
> + * initialize.
> + */
> +#define SD_APP_OP_COND_RETRIES  200
> +#define SD_APP_OP_COND_INTERVAL 10     /* millisecond */
> +
>  struct mmc_card;
>  struct mmc_host;
>
> --
> 2.34.1
>

Kind regards
Uffe

[1]
https://lore.kernel.org/all/20240425133034.79599-1-ulf.hansson@linaro.org/
diff mbox series

Patch

diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index a59cd592f06e..b3b6e8725b80 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -127,7 +127,7 @@  int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
 		cmd.arg = ocr;
 	cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
 
-	for (i = 100; i; i--) {
+	for (i = SD_APP_OP_COND_RETRIES; i; i--) {
 		err = mmc_wait_for_app_cmd(host, NULL, &cmd);
 		if (err)
 			break;
@@ -147,7 +147,7 @@  int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
 
 		err = -ETIMEDOUT;
 
-		mmc_delay(10);
+		mmc_delay(SD_APP_OP_COND_INTERVAL);
 	}
 
 	if (!i)
diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h
index 7667fc223b74..80c5c836ccd1 100644
--- a/drivers/mmc/core/sd_ops.h
+++ b/drivers/mmc/core/sd_ops.h
@@ -10,6 +10,14 @@ 
 
 #include <linux/types.h>
 
+/*
+ * Extensive testing has shown that a few specific SD cards require
+ * an increase in the number of command retries to successfully
+ * initialize.
+ */
+#define SD_APP_OP_COND_RETRIES  200
+#define SD_APP_OP_COND_INTERVAL 10	/* millisecond */
+
 struct mmc_card;
 struct mmc_host;