* [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC
@ 2020-12-10 21:27 Douglas Anderson
2020-12-10 21:57 ` Stephen Boyd
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Douglas Anderson @ 2020-12-10 21:27 UTC (permalink / raw)
To: Ulf Hansson, Adrian Hunter
Cc: Stephen Boyd, vbadigan, Taniya Das, Douglas Anderson, Andy Gross,
Bjorn Andersson, linux-arm-msm, linux-kernel, linux-mmc
As talked about in commit 5e4b7e82d497 ("clk: qcom: gcc-sdm845: Use
floor ops for sdcc clks"), most clocks handled by the Qualcomm clock
drivers are rounded _up_ by default instead of down. We should make
sure SD/MMC clocks are always rounded down in the clock drivers.
Let's add a warning in the Qualcomm SDHCI driver to help catch the
problem.
This would have saved a bunch of time [1].
[1] http://lore.kernel.org/r/20201210102234.1.I096779f219625148900fc984dd0084ed1ba87c7f@changeid
Suggested-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
Changes in v3:
- Proper printf format code.
Changes in v2:
- Store rate in unsigned long, not unsigned int.
- Reuse the clk_get_rate() in the later print.
drivers/mmc/host/sdhci-msm.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 3451eb325513..50beb407dbe9 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -353,6 +353,7 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
struct mmc_ios curr_ios = host->mmc->ios;
struct clk *core_clk = msm_host->bulk_clks[0].clk;
+ unsigned long achieved_rate;
int rc;
clock = msm_get_clock_rate_for_bus_mode(host, clock);
@@ -363,10 +364,20 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
curr_ios.timing);
return;
}
+
+ /*
+ * Qualcomm clock drivers by default round clock _up_ if they can't
+ * make the requested rate. This is not good for SD. Yell if we
+ * encounter it.
+ */
+ achieved_rate = clk_get_rate(core_clk);
+ if (achieved_rate > clock)
+ pr_warn("%s: Card appears overclocked; req %u Hz, actual %lu Hz\n",
+ mmc_hostname(host->mmc), clock, achieved_rate);
+
msm_host->clk_rate = clock;
pr_debug("%s: Setting clock at rate %lu at timing %d\n",
- mmc_hostname(host->mmc), clk_get_rate(core_clk),
- curr_ios.timing);
+ mmc_hostname(host->mmc), achieved_rate, curr_ios.timing);
}
/* Platform specific tuning */
--
2.29.2.576.ga3fc446d84-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC
2020-12-10 21:27 [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC Douglas Anderson
@ 2020-12-10 21:57 ` Stephen Boyd
2020-12-10 22:23 ` Bjorn Andersson
2020-12-11 5:56 ` Adrian Hunter
2 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2020-12-10 21:57 UTC (permalink / raw)
To: Adrian Hunter, Douglas Anderson, Ulf Hansson
Cc: vbadigan, Taniya Das, Douglas Anderson, Andy Gross,
Bjorn Andersson, linux-arm-msm, linux-kernel, linux-mmc
Quoting Douglas Anderson (2020-12-10 13:27:52)
> As talked about in commit 5e4b7e82d497 ("clk: qcom: gcc-sdm845: Use
> floor ops for sdcc clks"), most clocks handled by the Qualcomm clock
> drivers are rounded _up_ by default instead of down. We should make
> sure SD/MMC clocks are always rounded down in the clock drivers.
> Let's add a warning in the Qualcomm SDHCI driver to help catch the
> problem.
>
> This would have saved a bunch of time [1].
>
> [1] http://lore.kernel.org/r/20201210102234.1.I096779f219625148900fc984dd0084ed1ba87c7f@changeid
>
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC
2020-12-10 21:27 [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC Douglas Anderson
2020-12-10 21:57 ` Stephen Boyd
@ 2020-12-10 22:23 ` Bjorn Andersson
2020-12-11 5:56 ` Adrian Hunter
2 siblings, 0 replies; 5+ messages in thread
From: Bjorn Andersson @ 2020-12-10 22:23 UTC (permalink / raw)
To: Douglas Anderson
Cc: Ulf Hansson, Adrian Hunter, Stephen Boyd, vbadigan, Taniya Das,
Andy Gross, linux-arm-msm, linux-kernel, linux-mmc
On Thu 10 Dec 15:27 CST 2020, Douglas Anderson wrote:
> As talked about in commit 5e4b7e82d497 ("clk: qcom: gcc-sdm845: Use
> floor ops for sdcc clks"), most clocks handled by the Qualcomm clock
> drivers are rounded _up_ by default instead of down. We should make
> sure SD/MMC clocks are always rounded down in the clock drivers.
> Let's add a warning in the Qualcomm SDHCI driver to help catch the
> problem.
>
> This would have saved a bunch of time [1].
>
> [1] http://lore.kernel.org/r/20201210102234.1.I096779f219625148900fc984dd0084ed1ba87c7f@changeid
>
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Regards,
Bjorn
> ---
>
> Changes in v3:
> - Proper printf format code.
>
> Changes in v2:
> - Store rate in unsigned long, not unsigned int.
> - Reuse the clk_get_rate() in the later print.
>
> drivers/mmc/host/sdhci-msm.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index 3451eb325513..50beb407dbe9 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -353,6 +353,7 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
> struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
> struct mmc_ios curr_ios = host->mmc->ios;
> struct clk *core_clk = msm_host->bulk_clks[0].clk;
> + unsigned long achieved_rate;
> int rc;
>
> clock = msm_get_clock_rate_for_bus_mode(host, clock);
> @@ -363,10 +364,20 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
> curr_ios.timing);
> return;
> }
> +
> + /*
> + * Qualcomm clock drivers by default round clock _up_ if they can't
> + * make the requested rate. This is not good for SD. Yell if we
> + * encounter it.
> + */
> + achieved_rate = clk_get_rate(core_clk);
> + if (achieved_rate > clock)
> + pr_warn("%s: Card appears overclocked; req %u Hz, actual %lu Hz\n",
> + mmc_hostname(host->mmc), clock, achieved_rate);
> +
> msm_host->clk_rate = clock;
> pr_debug("%s: Setting clock at rate %lu at timing %d\n",
> - mmc_hostname(host->mmc), clk_get_rate(core_clk),
> - curr_ios.timing);
> + mmc_hostname(host->mmc), achieved_rate, curr_ios.timing);
> }
>
> /* Platform specific tuning */
> --
> 2.29.2.576.ga3fc446d84-goog
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC
2020-12-10 21:27 [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC Douglas Anderson
2020-12-10 21:57 ` Stephen Boyd
2020-12-10 22:23 ` Bjorn Andersson
@ 2020-12-11 5:56 ` Adrian Hunter
2020-12-11 17:15 ` Doug Anderson
2 siblings, 1 reply; 5+ messages in thread
From: Adrian Hunter @ 2020-12-11 5:56 UTC (permalink / raw)
To: Douglas Anderson, Ulf Hansson
Cc: Stephen Boyd, vbadigan, Taniya Das, Andy Gross, Bjorn Andersson,
linux-arm-msm, linux-kernel, linux-mmc
On 10/12/20 11:27 pm, Douglas Anderson wrote:
> As talked about in commit 5e4b7e82d497 ("clk: qcom: gcc-sdm845: Use
> floor ops for sdcc clks"), most clocks handled by the Qualcomm clock
> drivers are rounded _up_ by default instead of down. We should make
> sure SD/MMC clocks are always rounded down in the clock drivers.
> Let's add a warning in the Qualcomm SDHCI driver to help catch the
> problem.
>
> This would have saved a bunch of time [1].
>
> [1] http://lore.kernel.org/r/20201210102234.1.I096779f219625148900fc984dd0084ed1ba87c7f@changeid
>
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
> Changes in v3:
> - Proper printf format code.
>
> Changes in v2:
> - Store rate in unsigned long, not unsigned int.
> - Reuse the clk_get_rate() in the later print.
>
> drivers/mmc/host/sdhci-msm.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index 3451eb325513..50beb407dbe9 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -353,6 +353,7 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
> struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
> struct mmc_ios curr_ios = host->mmc->ios;
> struct clk *core_clk = msm_host->bulk_clks[0].clk;
> + unsigned long achieved_rate;
> int rc;
>
> clock = msm_get_clock_rate_for_bus_mode(host, clock);
> @@ -363,10 +364,20 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
> curr_ios.timing);
> return;
> }
> +
> + /*
> + * Qualcomm clock drivers by default round clock _up_ if they can't
> + * make the requested rate. This is not good for SD. Yell if we
> + * encounter it.
> + */
> + achieved_rate = clk_get_rate(core_clk);
> + if (achieved_rate > clock)
> + pr_warn("%s: Card appears overclocked; req %u Hz, actual %lu Hz\n",
> + mmc_hostname(host->mmc), clock, achieved_rate);
How does a warning help?
Also, did you consider setting host->mmc->actual_clock
> +
> msm_host->clk_rate = clock;
> pr_debug("%s: Setting clock at rate %lu at timing %d\n",
> - mmc_hostname(host->mmc), clk_get_rate(core_clk),
> - curr_ios.timing);
> + mmc_hostname(host->mmc), achieved_rate, curr_ios.timing);
> }
>
> /* Platform specific tuning */
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC
2020-12-11 5:56 ` Adrian Hunter
@ 2020-12-11 17:15 ` Doug Anderson
0 siblings, 0 replies; 5+ messages in thread
From: Doug Anderson @ 2020-12-11 17:15 UTC (permalink / raw)
To: Adrian Hunter
Cc: Ulf Hansson, Stephen Boyd, Veerabhadrarao Badiganti, Taniya Das,
Andy Gross, Bjorn Andersson, linux-arm-msm, LKML, Linux MMC List
Hi,
On Thu, Dec 10, 2020 at 9:56 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 10/12/20 11:27 pm, Douglas Anderson wrote:
> > As talked about in commit 5e4b7e82d497 ("clk: qcom: gcc-sdm845: Use
> > floor ops for sdcc clks"), most clocks handled by the Qualcomm clock
> > drivers are rounded _up_ by default instead of down. We should make
> > sure SD/MMC clocks are always rounded down in the clock drivers.
> > Let's add a warning in the Qualcomm SDHCI driver to help catch the
> > problem.
> >
> > This would have saved a bunch of time [1].
> >
> > [1] http://lore.kernel.org/r/20201210102234.1.I096779f219625148900fc984dd0084ed1ba87c7f@changeid
> >
> > Suggested-by: Stephen Boyd <swboyd@chromium.org>
> > Signed-off-by: Douglas Anderson <dianders@chromium.org>
> > ---
> >
> > Changes in v3:
> > - Proper printf format code.
> >
> > Changes in v2:
> > - Store rate in unsigned long, not unsigned int.
> > - Reuse the clk_get_rate() in the later print.
> >
> > drivers/mmc/host/sdhci-msm.c | 15 +++++++++++++--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> > index 3451eb325513..50beb407dbe9 100644
> > --- a/drivers/mmc/host/sdhci-msm.c
> > +++ b/drivers/mmc/host/sdhci-msm.c
> > @@ -353,6 +353,7 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
> > struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
> > struct mmc_ios curr_ios = host->mmc->ios;
> > struct clk *core_clk = msm_host->bulk_clks[0].clk;
> > + unsigned long achieved_rate;
> > int rc;
> >
> > clock = msm_get_clock_rate_for_bus_mode(host, clock);
> > @@ -363,10 +364,20 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
> > curr_ios.timing);
> > return;
> > }
> > +
> > + /*
> > + * Qualcomm clock drivers by default round clock _up_ if they can't
> > + * make the requested rate. This is not good for SD. Yell if we
> > + * encounter it.
> > + */
> > + achieved_rate = clk_get_rate(core_clk);
> > + if (achieved_rate > clock)
> > + pr_warn("%s: Card appears overclocked; req %u Hz, actual %lu Hz\n",
> > + mmc_hostname(host->mmc), clock, achieved_rate);
>
> How does a warning help?
The actual fixes are made in the clock drivers, but this seems to be a
common problem in Qualcomm clock drivers. ...so while this doesn't
actually fix the problem, it hopefully calls enough attention that
someone will know to fix it in the clock driver.
> Also, did you consider setting host->mmc->actual_clock
That makes sense, though I think logically it's a separate change.
I'll add it as patch #2 in the series. It's not as trivial as I would
have thought. ;-)
-Doug
>
> > +
> > msm_host->clk_rate = clock;
> > pr_debug("%s: Setting clock at rate %lu at timing %d\n",
> > - mmc_hostname(host->mmc), clk_get_rate(core_clk),
> > - curr_ios.timing);
> > + mmc_hostname(host->mmc), achieved_rate, curr_ios.timing);
> > }
> >
> > /* Platform specific tuning */
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-11 19:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 21:27 [PATCH v3] mmc: sdhci-msm: Warn about overclocking SD/MMC Douglas Anderson
2020-12-10 21:57 ` Stephen Boyd
2020-12-10 22:23 ` Bjorn Andersson
2020-12-11 5:56 ` Adrian Hunter
2020-12-11 17:15 ` Doug Anderson
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).