* [PATCH] mmc: mmci: stm32: fix max busy timeout calculation
@ 2023-06-13 13:41 Yann Gautier
2023-06-13 14:25 ` Ulf Hansson
0 siblings, 1 reply; 2+ messages in thread
From: Yann Gautier @ 2023-06-13 13:41 UTC (permalink / raw)
To: Ulf Hansson, linux-mmc
Cc: Russell King, Philipp Zabel, Christophe Kerello, Rob Herring,
Xiang wangx, Yang Yingliang, linux-kernel, Marek Vasut,
Linus Walleij, Dennis Zhou, Yann Gautier
From: Christophe Kerello <christophe.kerello@foss.st.com>
The way that the timeout is currently calculated could lead to a u64
timeout value in mmci_start_command(). This value is then cast in a u32
register that leads to mmc erase failed issue with some SD cards.
Fixes: 8266c585f489 ("mmc: mmci: add hardware busy timeout feature")
Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com>
---
drivers/mmc/host/mmci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index f2b2e8b0574e8..696cbef3ff7de 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1735,7 +1735,8 @@ static void mmci_set_max_busy_timeout(struct mmc_host *mmc)
return;
if (host->variant->busy_timeout && mmc->actual_clock)
- max_busy_timeout = ~0UL / (mmc->actual_clock / MSEC_PER_SEC);
+ max_busy_timeout = U32_MAX / DIV_ROUND_UP(mmc->actual_clock,
+ MSEC_PER_SEC);
mmc->max_busy_timeout = max_busy_timeout;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: mmci: stm32: fix max busy timeout calculation
2023-06-13 13:41 [PATCH] mmc: mmci: stm32: fix max busy timeout calculation Yann Gautier
@ 2023-06-13 14:25 ` Ulf Hansson
0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2023-06-13 14:25 UTC (permalink / raw)
To: Yann Gautier
Cc: linux-mmc, Russell King, Philipp Zabel, Christophe Kerello,
Rob Herring, Xiang wangx, Yang Yingliang, linux-kernel,
Marek Vasut, Linus Walleij, Dennis Zhou
On Tue, 13 Jun 2023 at 15:42, Yann Gautier <yann.gautier@foss.st.com> wrote:
>
> From: Christophe Kerello <christophe.kerello@foss.st.com>
>
> The way that the timeout is currently calculated could lead to a u64
> timeout value in mmci_start_command(). This value is then cast in a u32
> register that leads to mmc erase failed issue with some SD cards.
>
> Fixes: 8266c585f489 ("mmc: mmci: add hardware busy timeout feature")
> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
> Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com>
Applied for fixes and by adding a stable tag, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/host/mmci.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index f2b2e8b0574e8..696cbef3ff7de 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -1735,7 +1735,8 @@ static void mmci_set_max_busy_timeout(struct mmc_host *mmc)
> return;
>
> if (host->variant->busy_timeout && mmc->actual_clock)
> - max_busy_timeout = ~0UL / (mmc->actual_clock / MSEC_PER_SEC);
> + max_busy_timeout = U32_MAX / DIV_ROUND_UP(mmc->actual_clock,
> + MSEC_PER_SEC);
>
> mmc->max_busy_timeout = max_busy_timeout;
> }
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-13 14:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 13:41 [PATCH] mmc: mmci: stm32: fix max busy timeout calculation Yann Gautier
2023-06-13 14:25 ` Ulf Hansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).