* [PATCH] mmc: mmc_spi: fix timeout calculation
@ 2020-08-14 18:50 Tobias Schramm
2020-08-21 8:45 ` Ulf Hansson
2020-08-24 9:50 ` Ulf Hansson
0 siblings, 2 replies; 4+ messages in thread
From: Tobias Schramm @ 2020-08-14 18:50 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-mmc, linux-kernel, Tobias Schramm
Previously the cycle timeout was converted to a microsecond value but
then incorrectly treated as a nanosecond timeout. This patch changes
the code to convert both the nanosecond timeout and the cycle timeout
to a microsecond value and use that directly.
Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
---
drivers/mmc/host/mmc_spi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 39bb1e30c2d7..f85e0ad896a9 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -882,9 +882,9 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
else
clock_rate = spi->max_speed_hz;
- timeout = data->timeout_ns +
+ timeout = data->timeout_ns / 1000 +
data->timeout_clks * 1000000 / clock_rate;
- timeout = usecs_to_jiffies((unsigned int)(timeout / 1000)) + 1;
+ timeout = usecs_to_jiffies((unsigned int)timeout) + 1;
/* Handle scatterlist segments one at a time, with synch for
* each 512-byte block
--
2.28.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: mmc_spi: fix timeout calculation
2020-08-14 18:50 [PATCH] mmc: mmc_spi: fix timeout calculation Tobias Schramm
@ 2020-08-21 8:45 ` Ulf Hansson
2020-08-23 23:08 ` Tobias Schramm
2020-08-24 9:50 ` Ulf Hansson
1 sibling, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2020-08-21 8:45 UTC (permalink / raw)
To: Tobias Schramm; +Cc: linux-mmc, Linux Kernel Mailing List
On Fri, 14 Aug 2020 at 20:50, Tobias Schramm <t.schramm@manjaro.org> wrote:
>
> Previously the cycle timeout was converted to a microsecond value but
> then incorrectly treated as a nanosecond timeout. This patch changes
> the code to convert both the nanosecond timeout and the cycle timeout
> to a microsecond value and use that directly.
>
> Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
This looks good to me, but before applying just wanted to check that
you tested this on some HW, to make sure it doesn't break anything?
Kind regards
Uffe
> ---
> drivers/mmc/host/mmc_spi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
> index 39bb1e30c2d7..f85e0ad896a9 100644
> --- a/drivers/mmc/host/mmc_spi.c
> +++ b/drivers/mmc/host/mmc_spi.c
> @@ -882,9 +882,9 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
> else
> clock_rate = spi->max_speed_hz;
>
> - timeout = data->timeout_ns +
> + timeout = data->timeout_ns / 1000 +
> data->timeout_clks * 1000000 / clock_rate;
> - timeout = usecs_to_jiffies((unsigned int)(timeout / 1000)) + 1;
> + timeout = usecs_to_jiffies((unsigned int)timeout) + 1;
>
> /* Handle scatterlist segments one at a time, with synch for
> * each 512-byte block
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: mmc_spi: fix timeout calculation
2020-08-21 8:45 ` Ulf Hansson
@ 2020-08-23 23:08 ` Tobias Schramm
0 siblings, 0 replies; 4+ messages in thread
From: Tobias Schramm @ 2020-08-23 23:08 UTC (permalink / raw)
To: Ulf Hansson, Tobias Schramm; +Cc: linux-mmc, Linux Kernel Mailing List
Hi Uffe,
> This looks good to me, but before applying just wanted to check that
> you tested this on some HW, to make sure it doesn't break anything?
yes, I should have mentioned that. I tested the change on a custom
STM32H743 board with a microSD card connected to one of its SPIs. It
does still work just fine with this patch applied.
Tobias
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: mmc_spi: fix timeout calculation
2020-08-14 18:50 [PATCH] mmc: mmc_spi: fix timeout calculation Tobias Schramm
2020-08-21 8:45 ` Ulf Hansson
@ 2020-08-24 9:50 ` Ulf Hansson
1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2020-08-24 9:50 UTC (permalink / raw)
To: Tobias Schramm; +Cc: linux-mmc, Linux Kernel Mailing List
On Fri, 14 Aug 2020 at 20:50, Tobias Schramm <t.schramm@manjaro.org> wrote:
>
> Previously the cycle timeout was converted to a microsecond value but
> then incorrectly treated as a nanosecond timeout. This patch changes
> the code to convert both the nanosecond timeout and the cycle timeout
> to a microsecond value and use that directly.
>
> Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/host/mmc_spi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
> index 39bb1e30c2d7..f85e0ad896a9 100644
> --- a/drivers/mmc/host/mmc_spi.c
> +++ b/drivers/mmc/host/mmc_spi.c
> @@ -882,9 +882,9 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
> else
> clock_rate = spi->max_speed_hz;
>
> - timeout = data->timeout_ns +
> + timeout = data->timeout_ns / 1000 +
> data->timeout_clks * 1000000 / clock_rate;
> - timeout = usecs_to_jiffies((unsigned int)(timeout / 1000)) + 1;
> + timeout = usecs_to_jiffies((unsigned int)timeout) + 1;
>
> /* Handle scatterlist segments one at a time, with synch for
> * each 512-byte block
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-24 9:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-14 18:50 [PATCH] mmc: mmc_spi: fix timeout calculation Tobias Schramm
2020-08-21 8:45 ` Ulf Hansson
2020-08-23 23:08 ` Tobias Schramm
2020-08-24 9:50 ` Ulf Hansson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.