linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] clk: meson: three small clk-pll fixes
@ 2020-12-26 12:15 Martin Blumenstingl
  2020-12-26 12:15 ` [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL Martin Blumenstingl
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2020-12-26 12:15 UTC (permalink / raw)
  To: linux-amlogic, jbrunet
  Cc: sboyd, mturquette, linux-kernel, Martin Blumenstingl, linux-clk,
	linux-arm-kernel

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(-)

-- 
2.29.2


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL
  2020-12-26 12:15 [PATCH 0/3] clk: meson: three small clk-pll fixes Martin Blumenstingl
@ 2020-12-26 12:15 ` Martin Blumenstingl
  2021-01-04 11:43   ` Jerome Brunet
  2020-12-26 12:15 ` [PATCH 2/3] clk: meson: clk-pll: make "ret" a signed integer Martin Blumenstingl
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Martin Blumenstingl @ 2020-12-26 12:15 UTC (permalink / raw)
  To: linux-amlogic, jbrunet
  Cc: sboyd, mturquette, linux-kernel, Martin Blumenstingl, linux-clk,
	linux-arm-kernel

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")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/clk/meson/clk-pll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
index b17a13e9337c..9404609b5ebf 100644
--- a/drivers/clk/meson/clk-pll.c
+++ b/drivers/clk/meson/clk-pll.c
@@ -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)
-- 
2.29.2


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] clk: meson: clk-pll: make "ret" a signed integer
  2020-12-26 12:15 [PATCH 0/3] clk: meson: three small clk-pll fixes Martin Blumenstingl
  2020-12-26 12:15 ` [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL Martin Blumenstingl
@ 2020-12-26 12:15 ` Martin Blumenstingl
  2020-12-26 12:15 ` [PATCH 3/3] clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate() Martin Blumenstingl
  2021-01-04 11:43 ` [PATCH 0/3] clk: meson: three small clk-pll fixes Jerome Brunet
  3 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2020-12-26 12:15 UTC (permalink / raw)
  To: linux-amlogic, jbrunet
  Cc: sboyd, mturquette, linux-kernel, Martin Blumenstingl, linux-clk,
	linux-arm-kernel

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")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/clk/meson/clk-pll.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
index 9404609b5ebf..5b932976483f 100644
--- a/drivers/clk/meson/clk-pll.c
+++ b/drivers/clk/meson/clk-pll.c
@@ -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;
-- 
2.29.2


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate()
  2020-12-26 12:15 [PATCH 0/3] clk: meson: three small clk-pll fixes Martin Blumenstingl
  2020-12-26 12:15 ` [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL Martin Blumenstingl
  2020-12-26 12:15 ` [PATCH 2/3] clk: meson: clk-pll: make "ret" a signed integer Martin Blumenstingl
@ 2020-12-26 12:15 ` Martin Blumenstingl
  2021-01-04 11:43 ` [PATCH 0/3] clk: meson: three small clk-pll fixes Jerome Brunet
  3 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2020-12-26 12:15 UTC (permalink / raw)
  To: linux-amlogic, jbrunet
  Cc: sboyd, mturquette, linux-kernel, Martin Blumenstingl, linux-clk,
	linux-arm-kernel

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")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/clk/meson/clk-pll.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
index 5b932976483f..49f27fe53213 100644
--- a/drivers/clk/meson/clk-pll.c
+++ b/drivers/clk/meson/clk-pll.c
@@ -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;
 }
 
 /*
-- 
2.29.2


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL
  2020-12-26 12:15 ` [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL Martin Blumenstingl
@ 2021-01-04 11:43   ` Jerome Brunet
  0 siblings, 0 replies; 6+ messages in thread
From: Jerome Brunet @ 2021-01-04 11:43 UTC (permalink / raw)
  To: Martin Blumenstingl, linux-amlogic
  Cc: sboyd, mturquette, linux-clk, linux-arm-kernel, linux-kernel


On Sat 26 Dec 2020 at 13:15, Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> 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


>
> Fixes: 7a29a869434e8b ("clk: meson: Add support for Meson clock controller")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
>  drivers/clk/meson/clk-pll.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
> index b17a13e9337c..9404609b5ebf 100644
> --- a/drivers/clk/meson/clk-pll.c
> +++ b/drivers/clk/meson/clk-pll.c
> @@ -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
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] clk: meson: three small clk-pll fixes
  2020-12-26 12:15 [PATCH 0/3] clk: meson: three small clk-pll fixes Martin Blumenstingl
                   ` (2 preceding siblings ...)
  2020-12-26 12:15 ` [PATCH 3/3] clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate() Martin Blumenstingl
@ 2021-01-04 11:43 ` Jerome Brunet
  3 siblings, 0 replies; 6+ messages in thread
From: Jerome Brunet @ 2021-01-04 11:43 UTC (permalink / raw)
  To: Martin Blumenstingl, linux-amlogic
  Cc: sboyd, mturquette, linux-clk, linux-arm-kernel, linux-kernel


On Sat 26 Dec 2020 at 13:15, Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> 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(-)

Applied, Thx

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-04 11:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-26 12:15 [PATCH 0/3] clk: meson: three small clk-pll fixes Martin Blumenstingl
2020-12-26 12:15 ` [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL Martin Blumenstingl
2021-01-04 11:43   ` Jerome Brunet
2020-12-26 12:15 ` [PATCH 2/3] clk: meson: clk-pll: make "ret" a signed integer Martin Blumenstingl
2020-12-26 12:15 ` [PATCH 3/3] clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate() Martin Blumenstingl
2021-01-04 11:43 ` [PATCH 0/3] clk: meson: three small clk-pll fixes Jerome Brunet

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).