linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] clk: meson: fix PLL rate rounding
@ 2019-03-24 16:43 Martin Blumenstingl
  2019-03-24 16:43 ` [PATCH 1/1] clk: meson: pll: fix rounding and setting a rate that matches precisely Martin Blumenstingl
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Blumenstingl @ 2019-03-24 16:43 UTC (permalink / raw)
  To: narmstrong, jbrunet, linux-amlogic, linux-clk
  Cc: mturquette, sboyd, linux-arm-kernel, linux-kernel, Martin Blumenstingl

Hi Jerome,

can you please look at this small fix? I discovered that my Odroid-C1
wasn't booting anymore. My other Meson8m2 board was using fine.

While investigating this I found that it hangs while setting the
sys_pll_dco rate. This is important because unlike Odroid-C1 my
Meson8m2 board has a fixed regulator (and thus always runs at a
fixed CPU speed).
It always hanged while trying to set a CPU frequency of 312MHz. This
can be achieved with:
  24MHz (xtal) * 52 (m) / 1 (n) / 4 (sys_pll)
However, my added debug logging showed that it was trying to set an
M value of 51, resulting in an output frequency of 306MHz. My debug
logs showed that meson_clk_get_pll_settings() considers 1248MHz
(which is the rate requested for sys_pll_dco for a CPU frequency of
 312MHz) "worse" than 1224MHz.

I'm not sure exactly why the bug caused the board to hang, but my
patch fixes it.

Please apply this to v5.1-rc as I believe the Odroid-C1 on kernelci
also suffers from this issue.


Martin Blumenstingl (1):
  clk: meson: pll: fix rounding and setting a rate that matches
    precisely

 drivers/clk/meson/clk-pll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.21.0


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

* [PATCH 1/1] clk: meson: pll: fix rounding and setting a rate that matches precisely
  2019-03-24 16:43 [PATCH 0/1] clk: meson: fix PLL rate rounding Martin Blumenstingl
@ 2019-03-24 16:43 ` Martin Blumenstingl
  2019-03-25  9:48   ` Jerome Brunet
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Blumenstingl @ 2019-03-24 16:43 UTC (permalink / raw)
  To: narmstrong, jbrunet, linux-amlogic, linux-clk
  Cc: mturquette, sboyd, linux-arm-kernel, linux-kernel, Martin Blumenstingl

Make meson_clk_pll_is_better() consider a rate that precisely matches
the requested rate to be better than any previous rate (which was
smaller than the current).

Prior to commit 8eed1db1adec6a ("clk: meson: pll: update driver for the
g12a") meson_clk_get_pll_settings() returned early (before calling
meson_clk_pll_is_better()) if the rate from the current iteration
matches the requested rate precisely. After this commit
meson_clk_pll_is_better() is called unconditionally. This requires
meson_clk_pll_is_better() to work with the case where "now == rate".

This fixes a hang during boot on Meson8b / Odroid-C1 for me.

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 | 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 41e16dd7272a..7a14ac9b2fec 100644
--- a/drivers/clk/meson/clk-pll.c
+++ b/drivers/clk/meson/clk-pll.c
@@ -120,7 +120,7 @@ static bool meson_clk_pll_is_better(unsigned long rate,
 			return true;
 	} else {
 		/* Round down */
-		if (now < rate && best < now)
+		if (now <= rate && best < now)
 			return true;
 	}
 
-- 
2.21.0


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

* Re: [PATCH 1/1] clk: meson: pll: fix rounding and setting a rate that matches precisely
  2019-03-24 16:43 ` [PATCH 1/1] clk: meson: pll: fix rounding and setting a rate that matches precisely Martin Blumenstingl
@ 2019-03-25  9:48   ` Jerome Brunet
  2019-03-25 12:18     ` Neil Armstrong
  0 siblings, 1 reply; 4+ messages in thread
From: Jerome Brunet @ 2019-03-25  9:48 UTC (permalink / raw)
  To: Martin Blumenstingl, narmstrong, linux-amlogic, linux-clk
  Cc: mturquette, sboyd, linux-arm-kernel, linux-kernel

On Sun, 2019-03-24 at 17:43 +0100, Martin Blumenstingl wrote:
> Make meson_clk_pll_is_better() consider a rate that precisely matches
> the requested rate to be better than any previous rate (which was
> smaller than the current).
> 
> Prior to commit 8eed1db1adec6a ("clk: meson: pll: update driver for the
> g12a") meson_clk_get_pll_settings() returned early (before calling
> meson_clk_pll_is_better()) if the rate from the current iteration
> matches the requested rate precisely. After this commit
> meson_clk_pll_is_better() is called unconditionally. This requires
> meson_clk_pll_is_better() to work with the case where "now == rate".
> 
> This fixes a hang during boot on Meson8b / Odroid-C1 for me.
> 
> Fixes: 8eed1db1adec6a ("clk: meson: pll: update driver for the g12a")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Good catch !

Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>




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

* Re: [PATCH 1/1] clk: meson: pll: fix rounding and setting a rate that matches precisely
  2019-03-25  9:48   ` Jerome Brunet
@ 2019-03-25 12:18     ` Neil Armstrong
  0 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2019-03-25 12:18 UTC (permalink / raw)
  To: Jerome Brunet, Martin Blumenstingl, linux-amlogic, linux-clk
  Cc: mturquette, sboyd, linux-arm-kernel, linux-kernel

On 25/03/2019 10:48, Jerome Brunet wrote:
> On Sun, 2019-03-24 at 17:43 +0100, Martin Blumenstingl wrote:
>> Make meson_clk_pll_is_better() consider a rate that precisely matches
>> the requested rate to be better than any previous rate (which was
>> smaller than the current).
>>
>> Prior to commit 8eed1db1adec6a ("clk: meson: pll: update driver for the
>> g12a") meson_clk_get_pll_settings() returned early (before calling
>> meson_clk_pll_is_better()) if the rate from the current iteration
>> matches the requested rate precisely. After this commit
>> meson_clk_pll_is_better() is called unconditionally. This requires
>> meson_clk_pll_is_better() to work with the case where "now == rate".
>>
>> This fixes a hang during boot on Meson8b / Odroid-C1 for me.
>>
>> Fixes: 8eed1db1adec6a ("clk: meson: pll: update driver for the g12a")
>> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> 
> Good catch !
> 
> Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
> 
> 
> 

Applied to fixes/drivers !

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

end of thread, other threads:[~2019-03-25 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-24 16:43 [PATCH 0/1] clk: meson: fix PLL rate rounding Martin Blumenstingl
2019-03-24 16:43 ` [PATCH 1/1] clk: meson: pll: fix rounding and setting a rate that matches precisely Martin Blumenstingl
2019-03-25  9:48   ` Jerome Brunet
2019-03-25 12:18     ` Neil Armstrong

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