Skip to contentSkip to conversation

mmc: sdhci-brcmstb: use clk_get_rate(base_clk) in PM resume

PATCH In review Kamal Dasu 3 participants 3 messages Jul 14, 2022 – Jul 18, 2022

Subsystems (4)
lore
Share & tools
lore

Kamal Dasu

author
#0 lore raw

PATCH 1/1 mmc: sdhci-brcmstb: use clk_get_rate(base_clk) in PM resume

Use clk_get_rate for base_clk on resume before setting new rate. This change ensures that the clock api returns current rate and sets the clock to the desired rate and honors CLK_GET_NO_CACHE attribute used by clock api.

Fixes 97904a59855c (mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0)
---
 drivers/mmc/host/sdhci-brcmstb.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-brcmstb.c +8 -1
index 28e9cf995c41..aff36a933ebe 100644
@@ -406,7 +406,14 @@ static int sdhci_brcmstb_resume(struct device *dev)
 	ret = sdhci_pltfm_resume(dev);
 	if (!ret && priv->base_freq_hz) {
 		ret = clk_prepare_enable(priv->base_clk);
-		if (!ret)
+		/*
+		 * Note: using clk_get_rate() below as clk_get_rate()
+		 * honors CLK_GET_RATE_NOCACHE attribute, but clk_set_rate()
+		 * may do implicit get_rate() calls that do not honor
+		 * CLK_GET_RATE_NOCACHE.
+		 */
+		if (!ret &&
+		    (clk_get_rate(priv->base_clk) != priv->base_freq_hz))
 			ret = clk_set_rate(priv->base_clk, priv->base_freq_hz);
 	}
 
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Kamal Dasu

Use clk_get_rate for base_clk on resume before setting new rate. This change ensures that the clock api returns current rate and sets the clock to the desired rate and honors CLK_GET_NO_CACHE attribute used by clock api.

Fixes 97904a59855c (mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0)
Signature · 1 line
Florian
#2 lore raw
In reply to Kamal Dasu
Quoted 8 lines · Kamal Dasu

Use clk_get_rate for base_clk on resume before setting new rate. This change ensures that the clock api returns current rate and sets the clock to the desired rate and honors CLK_GET_NO_CACHE attribute used by clock api.

Fixes 97904a59855c (mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0)

Applied for next, thanks!

Kind regards
Uffe

Quoted 27 lines
---
 drivers/mmc/host/sdhci-brcmstb.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-brcmstb.c +8 -2
index 28e9cf995c41..aff36a933ebe 100644
@@ -406,7 +406,14 @@ static int sdhci_brcmstb_resume(struct device *dev)
        ret = sdhci_pltfm_resume(dev);
        if (!ret && priv->base_freq_hz) {
                ret = clk_prepare_enable(priv->base_clk);
-               if (!ret)
+               /*
+                * Note: using clk_get_rate() below as clk_get_rate()
+                * honors CLK_GET_RATE_NOCACHE attribute, but clk_set_rate()
+                * may do implicit get_rate() calls that do not honor
+                * CLK_GET_RATE_NOCACHE.
+                */
+               if (!ret &&
+                   (clk_get_rate(priv->base_clk) != priv->base_freq_hz))
                        ret = clk_set_rate(priv->base_clk, priv->base_freq_hz);
        }
 
--

2.17.1