Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56fc9502 authored by Douglas Anderson's avatar Douglas Anderson Committed by Sarthak Garg
Browse files

mmc: sdhci-msm: Warn about overclocking SD/MMC

As talked about in commit 5e4b7e82 ("clk: qcom: gcc-sdm845: Use
floor ops for sdcc clks"), most clocks handled by the
Qualcomm Technologies, Inc. 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 Technologies, Inc. SDHCI
driver to help catch the problem.

This would have saved a bunch of time [1].

NOTE: this doesn't actually fix any problem, it just makes it obvious
to devs that there is a problem and that should be an indication to
fix the clock driver.

Change-Id: I0d7b15c854eb716383bee54715361d8936b6ad0f
Git-Repo: https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/


Git-Commit: a8cd989e1a57dff3994cd113650afb0223c44ec6
Suggested-by: default avatarStephen Boyd <swboyd@chromium.org>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarSarthak Garg <sartgarg@codeaurora.org>
parent 5b540967
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -560,6 +560,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);
@@ -570,10 +571,20 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host,
		       curr_ios.timing);
		return;
	}

	/*
	 * Qualcomm Technologies, Inc. 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_debug("%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 */