[U-Boot] [PATCH] mmc: stm32_sdmmc2: Increase SDMMC_BUSYD0END_TIMEOUT_US

Patrice CHOTARD patrice.chotard at st.com
Mon Aug 26 13:47:33 UTC 2019


On 7/22/19 11:41 AM, Patrice Chotard wrote:
> Increase SDMMC_BUSYD0END_TIMEOUT_US from 1s to 2s to
> avoid timeout error during blocks erase on some sdcard
>
> Issue seen on Kingston 16GB :
>   Device: STM32 SDMMC2
>   Manufacturer ID: 27
>   OEM: 5048
>   Name: SD16G
>   Bus Speed: 50000000
>   Mode: SD High Speed (50MHz)
>   card capabilities: widths [4, 1] modes [SD Legacy, SD High Speed (50MHz)]
>   host capabilities: widths [4, 1] modes [MMC legacy, SD Legacy, MMC High Speed (26MHz), SD High Speed (50MHz), MMC High Speed (52MHz)]
>   Rd Block Len: 512
>   SD version 3.0
>   High Capacity: Yes
>   Capacity: 14.5 GiB
>   Bus Width: 4-bit
>   Erase Group Size: 512 Bytes
>
> Issue reproduced with following command:
>
> STM32MP> mmc erase 0 100000
>
> MMC erase: dev # 0, block # 0, count 1048576 ... mmc erase failed
> 16384 blocks erased: ERROR
>
> By by setting SDMMC_BUSYD0END_TIMEOUT_US at 2 seconds and by adding
> time measurement in stm32_sdmmc2_end_cmd() as shown below:
>
> 	+start = get_timer(0);
> 	/* Polling status register */
> 	ret = readl_poll_timeout(priv->base + SDMMC_STA,
> 				 status, status & mask,
>  				 SDMMC_BUSYD0END_TIMEOUT_US);
>
> 	+printf("time = %ld ms\n", get_timer(start));
>
> We get the following trace:
>
> STM32MP> mmc erase 0  100000
>
> MMC erase: dev # 0, block # 0, count 1048576 ...
> time = 17 ms
> time = 1 ms
> time = 1025 ms
> time = 54 ms
> time = 56 ms
> time = 1021 ms
> time = 57 ms
> time = 56 ms
> time = 1020 ms
> time = 53 ms
> time = 57 ms
> time = 1021 ms
> time = 53 ms
> time = 57 ms
> time = 1313 ms
> time = 54 ms
> time = 56 ms
> time = 1026 ms
> time = 54 ms
> time = 56 ms
> time = 1036 ms
> time = 54 ms
> time = 56 ms
> time = 1028 ms
> time = 53 ms
> time = 56 ms
> time = 1027 ms
> time = 54 ms
> time = 56 ms
> time = 1024 ms
> time = 54 ms
> time = 56 ms
> time = 1020 ms
> time = 54 ms
> time = 57 ms
> time = 1023 ms
> time = 54 ms
> time = 56 ms
> time = 1033 ms
> time = 53 ms
> time = 57 ms
> ....
> time = 53 ms
> time = 57 ms
> time = 1021 ms
> time = 56 ms
> time = 56 ms
> time = 1026 ms
> time = 54 ms
> time = 56 ms
> 1048576 blocks erased: OK
>
> We see that 1 second timeout is not enough, we also see one measurement
> up to 1313 ms. Set the timeout to 2 second to keep a security margin.
>
> Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
> ---
>
>  drivers/mmc/stm32_sdmmc2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
> index 867ed569eb..0ade1b160e 100644
> --- a/drivers/mmc/stm32_sdmmc2.c
> +++ b/drivers/mmc/stm32_sdmmc2.c
> @@ -190,7 +190,7 @@ struct stm32_sdmmc2_ctx {
>  #define SDMMC_IDMACTRL_IDMAEN		BIT(0)
>  
>  #define SDMMC_CMD_TIMEOUT		0xFFFFFFFF
> -#define SDMMC_BUSYD0END_TIMEOUT_US	1000000
> +#define SDMMC_BUSYD0END_TIMEOUT_US	2000000
>  
>  static void stm32_sdmmc2_start_data(struct stm32_sdmmc2_priv *priv,
>  				    struct mmc_data *data,


Applied on STM32 tree

Thanks


More information about the U-Boot mailing list