From: Patrice CHOTARD <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc: stm32_sdmmc2: Increase SDMMC_BUSYD0END_TIMEOUT_US
Date: Mon, 26 Aug 2019 13:47:33 +0000 [thread overview]
Message-ID: <b5433bd2-0372-b03c-7df0-957930587830@st.com> (raw)
In-Reply-To: <20190722094110.7789-1-patrice.chotard@st.com>
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@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
prev parent reply other threads:[~2019-08-26 13:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-22 9:41 [U-Boot] [PATCH] mmc: stm32_sdmmc2: Increase SDMMC_BUSYD0END_TIMEOUT_US Patrice Chotard
2019-08-26 13:47 ` Patrice CHOTARD [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b5433bd2-0372-b03c-7df0-957930587830@st.com \
--to=patrice.chotard@st.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox