Skip to contentSkip to conversation

clk: meson: three small clk-pll fixes

PATCH Applied Martin Blumenstingl 2 participants 6 messages Dec 26, 2020 – Jan 4, 2021

Subsystems (3)
lore
Share & tools
lore

Martin Blumenstingl

author reviewer
#0 lore raw

cover clk: meson: three small clk-pll fixes

Hi Jerome,

while working on some changes for the 32-bit SoCs I hit a corner-case in the HDMI PLL: there's some rate doubling going. The PLL only locks in a specific rate range but the M/N table is not aware of that. This means for now (I am planning to fix that) that we can end up in a ituation where the PLL doesn't lock and meson_clk_pll_set_rate() is supposed to still behave in this case. So here's three small patches for that.

For me it's fine to queue these patches for -next. I am not aware of any breakage upstream, only some of my pending patches prefer to have these fixes.

Slightly unrelated: if you know anything about that clock doubling then please let me know!

Best regards,
Martin

Martin Blumenstingl (3):
clk: meson: clk-pll: fix initializing the old rate (fallback) for a
PLL
clk: meson: clk-pll: make "ret" a signed integer
clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate()

 drivers/clk/meson/clk-pll.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 7 lines
2.29.2


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
author reviewer
#1 lore raw

PATCH 1/3 clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL

The "rate" parameter in meson_clk_pll_set_rate() contains the new rate. Retrieve the old rate with clk_hw_get_rate() so we don't inifinitely try to switch from the new rate to the same ratte again.

Fixes 7a29a869434e8b ("clk: meson: Add support for Meson clock controller")
---
 drivers/clk/meson/clk-pll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/meson/clk-pll.c +1 -1
index b17a13e9337c..9404609b5ebf 100644
@@ -371,7 +371,7 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 	if (parent_rate == 0 || rate == 0)
 		return -EINVAL;
 
-	old_rate = rate;
+	old_rate = clk_hw_get_rate(hw);
 
 	ret = meson_clk_get_pll_settings(rate, parent_rate, &m, &n, pll);
 	if (ret)
Signature · 7 lines
2.29.2


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
maintainer
#2 lore raw

Re: [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL

Quoted 3 lines · Martin Blumenstingl

The "rate" parameter in meson_clk_pll_set_rate() contains the new rate. Retrieve the old rate with clk_hw_get_rate() so we don't inifinitely try to switch from the new rate to the same ratte again.

Small typo above fixed while applying

Quoted 12 lines
Fixes 7a29a869434e8b ("clk: meson: Add support for Meson clock controller")
---
 drivers/clk/meson/clk-pll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/meson/clk-pll.c +0 -0
index b17a13e9337c..9404609b5ebf 100644

drivers/clk/meson/clk-pll.c static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, · line 377

Quoted 8 lines
drivers/clk/meson/clk-pll.c +1 -1
@@ -371,7 +371,7 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 	if (parent_rate == 0 || rate == 0)
 		return -EINVAL;
 
-	old_rate = rate;
+	old_rate = clk_hw_get_rate(hw);
 
 	ret = meson_clk_get_pll_settings(rate, parent_rate, &m, &n, pll);
 	if (ret)

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

author reviewer
#3 lore raw

PATCH 2/3 clk: meson: clk-pll: make "ret" a signed integer

In reply to Martin Blumenstingl

The error codes returned by meson_clk_get_pll_settings() are all negative. Make "ret" a signed integer in meson_clk_pll_set_rate() to make it match with the clk_ops.set_rate API as well as the data type returned by meson_clk_get_pll_settings().

Fixes 8eed1db1adec6a ("clk: meson: pll: update driver for the g12a")
---
 drivers/clk/meson/clk-pll.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/meson/clk-pll.c +2 -1
index 9404609b5ebf..5b932976483f 100644
@@ -365,8 +365,9 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 {
 	struct clk_regmap *clk = to_clk_regmap(hw);
 	struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
-	unsigned int enabled, m, n, frac = 0, ret;
+	unsigned int enabled, m, n, frac = 0;
 	unsigned long old_rate;
+	int ret;
 
 	if (parent_rate == 0 || rate == 0)
 		return -EINVAL;
Signature · 7 lines
2.29.2


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
author reviewer
#4 lore raw

PATCH 3/3 clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate()

In reply to Martin Blumenstingl

Popagate the error code from meson_clk_pll_set_rate() when the PLL does not lock with the new settings.

Fixes 722825dcd54b2e ("clk: meson: migrate plls clocks to clk_regmap")
---
 drivers/clk/meson/clk-pll.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/meson/clk-pll.c +3 -2
index 5b932976483f..49f27fe53213 100644
@@ -394,7 +394,8 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 	if (!enabled)
 		return 0;
 
-	if (meson_clk_pll_enable(hw)) {
+	ret = meson_clk_pll_enable(hw);
+	if (ret) {
 		pr_warn("%s: pll did not lock, trying to restore old rate %lu\n",
 			__func__, old_rate);
 		/*
@@ -406,7 +407,7 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 		meson_clk_pll_set_rate(hw, old_rate, parent_rate);
 	}
 
-	return 0;
+	return ret;
 }
 
 /*
Signature · 7 lines
2.29.2


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
maintainer Applied
#5 lore raw
In reply to Martin Blumenstingl
Quoted 22 lines · Martin Blumenstingl

Hi Jerome,

while working on some changes for the 32-bit SoCs I hit a corner-case in the HDMI PLL: there's some rate doubling going. The PLL only locks in a specific rate range but the M/N table is not aware of that. This means for now (I am planning to fix that) that we can end up in a ituation where the PLL doesn't lock and meson_clk_pll_set_rate() is supposed to still behave in this case. So here's three small patches for that.

For me it's fine to queue these patches for -next. I am not aware of any breakage upstream, only some of my pending patches prefer to have these fixes.

Slightly unrelated: if you know anything about that clock doubling then please let me know!

Best regards,
Martin

Quoted 8 lines

Martin Blumenstingl (3):
clk: meson: clk-pll: fix initializing the old rate (fallback) for a
PLL
clk: meson: clk-pll: make "ret" a signed integer
clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate()

 drivers/clk/meson/clk-pll.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Applied, Thx

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic