Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCH] mmc: core: increase the number of retries of the ACMD41
@ 2024-04-16 14:59 Felix Qin
  2024-04-16 16:59 ` Dragan Simic
  0 siblings, 1 reply; 3+ messages in thread
From: Felix Qin @ 2024-04-16 14:59 UTC (permalink / raw)
  To: ulf.hansson, linux-mmc; +Cc: Felix Qin

Extensive testing has shown that a few specific SD cards require
an increase in the number of command retries to successfully
initialize.

Signed-off-by: Felix Qin <xiaokeqinhealth@126.com>
---
 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;
 
-- 
2.34.1


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

* Re: [PATCH] mmc: core: increase the number of retries of the ACMD41
  2024-04-16 14:59 [PATCH] mmc: core: increase the number of retries of the ACMD41 Felix Qin
@ 2024-04-16 16:59 ` Dragan Simic
  2024-04-17  6:32   ` [PATCH] mmc: core: increase the number of retries of the cdir Avri Altman
  0 siblings, 1 reply; 3+ messages in thread
From: Dragan Simic @ 2024-04-16 16:59 UTC (permalink / raw)
  To: Felix Qin; +Cc: ulf.hansson, linux-mmc

Hello Felix,

On 2024-04-16 16:59, 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.

Any chances, please, to include the models of the affected  SD cards
in the patch description, together with the model of the used host
hardware?  That might be helpful to the people wanting to replicate
(or debug further) such card initialization issues.

> Signed-off-by: Felix Qin <xiaokeqinhealth@126.com>
> ---
>  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;

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

* RE: [PATCH] mmc: core: increase the number of retries of the cdir
  2024-04-16 16:59 ` Dragan Simic
@ 2024-04-17  6:32   ` Avri Altman
  0 siblings, 0 replies; 3+ messages in thread
From: Avri Altman @ 2024-04-17  6:32 UTC (permalink / raw)
  To: Felix Qin; +Cc: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org

> On 2024-04-16 16:59, 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.
Acked-by: Avri Altman <avri.altman@wdc.com>

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

end of thread, other threads:[~2024-04-17  6:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-16 14:59 [PATCH] mmc: core: increase the number of retries of the ACMD41 Felix Qin
2024-04-16 16:59 ` Dragan Simic
2024-04-17  6:32   ` [PATCH] mmc: core: increase the number of retries of the cdir Avri Altman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox