linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
@ 2024-04-27 12:01 Konrad Dybcio
  2024-04-27 19:34 ` Bjorn Andersson
  2024-04-30  0:21 ` Stephen Boyd
  0 siblings, 2 replies; 9+ messages in thread
From: Konrad Dybcio @ 2024-04-27 12:01 UTC (permalink / raw)
  To: Bjorn Andersson, Michael Turquette, Stephen Boyd, Vinod Koul
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel,
	Dmitry Baryshkov, Konrad Dybcio

Similar to how it works on other SoCs, the top frequency of the SDHCI2
core clock is generated by a separate PLL (peculiar design choice) that
is not guaranteed to be enabled (why does the clock framework not handle
this by default?).

Add the CLK_OPS_PARENT_ENABLE flag to make sure we're not muxing the
RCG input to a dormant source.

Fixes: db0c944ee92b ("clk: qcom: Add clock driver for SM8450")
Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/clk/qcom/gcc-sm8450.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/qcom/gcc-sm8450.c b/drivers/clk/qcom/gcc-sm8450.c
index e86c58bc5e48..9a1d48ff22bc 100644
--- a/drivers/clk/qcom/gcc-sm8450.c
+++ b/drivers/clk/qcom/gcc-sm8450.c
@@ -935,7 +935,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = {
 		.name = "gcc_sdcc2_apps_clk_src",
 		.parent_data = gcc_parent_data_7,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_7),
-		.flags = CLK_SET_RATE_PARENT,
+		.flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
 		.ops = &clk_rcg2_floor_ops,
 	},
 };

---
base-commit: c0b832517f627ead3388c6f0c74e8ac10ad5774b
change-id: 20240427-topic-8450sdc2-3fcfebe1e8ad

Best regards,
-- 
Konrad Dybcio <konrad.dybcio@linaro.org>


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

* Re: [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
  2024-04-27 12:01 [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src Konrad Dybcio
@ 2024-04-27 19:34 ` Bjorn Andersson
  2024-04-30  0:21 ` Stephen Boyd
  1 sibling, 0 replies; 9+ messages in thread
From: Bjorn Andersson @ 2024-04-27 19:34 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Vinod Koul, Konrad Dybcio
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel, Dmitry Baryshkov


On Sat, 27 Apr 2024 14:01:07 +0200, Konrad Dybcio wrote:
> Similar to how it works on other SoCs, the top frequency of the SDHCI2
> core clock is generated by a separate PLL (peculiar design choice) that
> is not guaranteed to be enabled (why does the clock framework not handle
> this by default?).
> 
> Add the CLK_OPS_PARENT_ENABLE flag to make sure we're not muxing the
> RCG input to a dormant source.
> 
> [...]

Applied, thanks!

[1/1] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
      commit: 2ee7aabf9e25628c7bd17ed650cac84419d12eb1

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>

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

* Re: [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
  2024-04-27 12:01 [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src Konrad Dybcio
  2024-04-27 19:34 ` Bjorn Andersson
@ 2024-04-30  0:21 ` Stephen Boyd
  2024-04-30 10:46   ` Konrad Dybcio
  1 sibling, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2024-04-30  0:21 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Michael Turquette, Vinod Koul
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel,
	Dmitry Baryshkov, Konrad Dybcio

Quoting Konrad Dybcio (2024-04-27 05:01:07)
> Similar to how it works on other SoCs, the top frequency of the SDHCI2
> core clock is generated by a separate PLL (peculiar design choice) that
> is not guaranteed to be enabled (why does the clock framework not handle
> this by default?).
> 
> Add the CLK_OPS_PARENT_ENABLE flag to make sure we're not muxing the
> RCG input to a dormant source.

The RCG2 hardware hasn't required the parent to be enabled for clk
operations besides for the glitch-free source switch. What scenario is
happening here that's requiring this flag? Is the RCG forcibly enabled
perhaps because the bootloader has left the root enable bit set
(CMD_ROOT_EN)? Or are we changing the parent while the clk framework
thinks the clk is off when it is actually on?

TL;DR: This is papering over a bigger bug.

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

* Re: [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
  2024-04-30  0:21 ` Stephen Boyd
@ 2024-04-30 10:46   ` Konrad Dybcio
  2024-04-30 21:26     ` Stephen Boyd
  0 siblings, 1 reply; 9+ messages in thread
From: Konrad Dybcio @ 2024-04-30 10:46 UTC (permalink / raw)
  To: Stephen Boyd, Bjorn Andersson, Michael Turquette, Vinod Koul
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel, Dmitry Baryshkov

On 30.04.2024 2:21 AM, Stephen Boyd wrote:
> Quoting Konrad Dybcio (2024-04-27 05:01:07)
>> Similar to how it works on other SoCs, the top frequency of the SDHCI2
>> core clock is generated by a separate PLL (peculiar design choice) that
>> is not guaranteed to be enabled (why does the clock framework not handle
>> this by default?).
>>
>> Add the CLK_OPS_PARENT_ENABLE flag to make sure we're not muxing the
>> RCG input to a dormant source.
> 
> The RCG2 hardware hasn't required the parent to be enabled for clk
> operations besides for the glitch-free source switch. What scenario is
> happening here that's requiring this flag? Is the RCG forcibly enabled
> perhaps because the bootloader has left the root enable bit set
> (CMD_ROOT_EN)? Or are we changing the parent while the clk framework
> thinks the clk is off when it is actually on?
> 
> TL;DR: This is papering over a bigger bug.

Definitely.


Take a look at:

static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = {
	F(400000, P_BI_TCXO, 12, 1, 4),
	F(25000000, P_GCC_GPLL0_OUT_EVEN, 12, 0, 0),
	F(50000000, P_GCC_GPLL0_OUT_EVEN, 6, 0, 0),
	F(100000000, P_GCC_GPLL0_OUT_EVEN, 3, 0, 0),
	F(202000000, P_GCC_GPLL9_OUT_MAIN, 4, 0, 0),
	{ }
};

XO and GPLL0 are more or less always on, but GPLL9 is described to only
be used for this specific clock for this specific frequency (perhaps it
feeds something else on the soc but that's besides the point).

Then, the parent input is changed during set_rate, but GPLL9 seems to
never be enabled:


@@ -3272,6 +3274,8 @@ static int gcc_sm8450_probe(struct platform_device *pdev)
        if (IS_ERR(regmap))
                return PTR_ERR(regmap);
 
+       pr_err("GPLL9 is %s at boot\n", trion_pll_is_enabled(&gcc_gpll9, regmap) ? "enabled" : "disabled");
+
        ret = qcom_cc_register_rcg_dfs(regmap, gcc_dfs_clocks,
                                       ARRAY_SIZE(gcc_dfs_clocks));
        if (ret)


(+ cruft to make this callable) results in a:

[    1.637318] GPLL9 is disabled at boot


Konrad

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

* Re: [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
  2024-04-30 10:46   ` Konrad Dybcio
@ 2024-04-30 21:26     ` Stephen Boyd
  2024-05-07 13:51       ` Konrad Dybcio
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2024-04-30 21:26 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Michael Turquette, Vinod Koul
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel, Dmitry Baryshkov

Quoting Konrad Dybcio (2024-04-30 03:46:52)
> On 30.04.2024 2:21 AM, Stephen Boyd wrote:
> > Quoting Konrad Dybcio (2024-04-27 05:01:07)
> >> Similar to how it works on other SoCs, the top frequency of the SDHCI2
> >> core clock is generated by a separate PLL (peculiar design choice) that
> >> is not guaranteed to be enabled (why does the clock framework not handle
> >> this by default?).
> >>
> >> Add the CLK_OPS_PARENT_ENABLE flag to make sure we're not muxing the
> >> RCG input to a dormant source.
> > 
> > The RCG2 hardware hasn't required the parent to be enabled for clk
> > operations besides for the glitch-free source switch. What scenario is
> > happening here that's requiring this flag? Is the RCG forcibly enabled
> > perhaps because the bootloader has left the root enable bit set
> > (CMD_ROOT_EN)? Or are we changing the parent while the clk framework
> > thinks the clk is off when it is actually on?
> > 
> > TL;DR: This is papering over a bigger bug.
> 
> Definitely.
> 
> 
> Take a look at:
> 
> static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = {
>         F(400000, P_BI_TCXO, 12, 1, 4),
>         F(25000000, P_GCC_GPLL0_OUT_EVEN, 12, 0, 0),
>         F(50000000, P_GCC_GPLL0_OUT_EVEN, 6, 0, 0),
>         F(100000000, P_GCC_GPLL0_OUT_EVEN, 3, 0, 0),
>         F(202000000, P_GCC_GPLL9_OUT_MAIN, 4, 0, 0),
>         { }
> };
> 
> XO and GPLL0 are more or less always on, but GPLL9 is described to only
> be used for this specific clock for this specific frequency (perhaps it
> feeds something else on the soc but that's besides the point).
> 
> Then, the parent input is changed during set_rate, but GPLL9 seems to
> never be enabled:

Is the sdcc2 RCG enabled during the set_rate?

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

* Re: [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
  2024-04-30 21:26     ` Stephen Boyd
@ 2024-05-07 13:51       ` Konrad Dybcio
  2024-05-07 20:28         ` Stephen Boyd
  0 siblings, 1 reply; 9+ messages in thread
From: Konrad Dybcio @ 2024-05-07 13:51 UTC (permalink / raw)
  To: Stephen Boyd, Bjorn Andersson, Michael Turquette, Vinod Koul
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel, Dmitry Baryshkov



On 4/30/24 23:26, Stephen Boyd wrote:
> Quoting Konrad Dybcio (2024-04-30 03:46:52)
>> On 30.04.2024 2:21 AM, Stephen Boyd wrote:
>>> Quoting Konrad Dybcio (2024-04-27 05:01:07)
>>>> Similar to how it works on other SoCs, the top frequency of the SDHCI2
>>>> core clock is generated by a separate PLL (peculiar design choice) that
>>>> is not guaranteed to be enabled (why does the clock framework not handle
>>>> this by default?).
>>>>
>>>> Add the CLK_OPS_PARENT_ENABLE flag to make sure we're not muxing the
>>>> RCG input to a dormant source.
>>>
>>> The RCG2 hardware hasn't required the parent to be enabled for clk
>>> operations besides for the glitch-free source switch. What scenario is
>>> happening here that's requiring this flag? Is the RCG forcibly enabled
>>> perhaps because the bootloader has left the root enable bit set
>>> (CMD_ROOT_EN)? Or are we changing the parent while the clk framework
>>> thinks the clk is off when it is actually on?
>>>
>>> TL;DR: This is papering over a bigger bug.
>>
>> Definitely.
>>
>>
>> Take a look at:
>>
>> static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = {
>>          F(400000, P_BI_TCXO, 12, 1, 4),
>>          F(25000000, P_GCC_GPLL0_OUT_EVEN, 12, 0, 0),
>>          F(50000000, P_GCC_GPLL0_OUT_EVEN, 6, 0, 0),
>>          F(100000000, P_GCC_GPLL0_OUT_EVEN, 3, 0, 0),
>>          F(202000000, P_GCC_GPLL9_OUT_MAIN, 4, 0, 0),
>>          { }
>> };
>>
>> XO and GPLL0 are more or less always on, but GPLL9 is described to only
>> be used for this specific clock for this specific frequency (perhaps it
>> feeds something else on the soc but that's besides the point).
>>
>> Then, the parent input is changed during set_rate, but GPLL9 seems to
>> never be enabled:
> 
> Is the sdcc2 RCG enabled during the set_rate?

without PARENT_OPS_ENABLE:

[    3.326891] sdhci_msm 8804000.mmc: Got CD GPIO
[    3.336839] scsi host0: ufshcd
[    3.337105] gcc_sdcc2_apps_clk_src is DISABLED @ set_rate
[    3.346339] ------------[ cut here ]------------
[    3.351093] gcc_sdcc2_apps_clk_src: rcg didn't update its configuration.
[    3.351114] WARNING: CPU: 1 PID: 11 at drivers/clk/qcom/clk-rcg2.c:133 update_config+0xc8/0xd8

[...]

[    3.610523] gcc_sdcc2_apps_clk_src is ENABLED @ set_rate


with PARENT_OPS_ENABLE:

[    3.331419] sdhci_msm 8804000.mmc: Got CD GPIO
[    3.336569] gcc_sdcc2_apps_clk_src is DISABLED @ set_rate
[    3.344795] scsi host0: ufshcd
[    3.355122] qcrypto 1dfa000.crypto: Adding to iommu group 5
[    3.363567] remoteproc remoteproc0: 2400000.remoteproc is available
[    3.364729] gcc_sdcc2_apps_clk_src is ENABLED @ set_rate

after testing it both ways, I realized it wasn't supposed to make a
difference in this regard, but I suppose I can paste both results anyway..

Konrad

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

* Re: [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
  2024-05-07 13:51       ` Konrad Dybcio
@ 2024-05-07 20:28         ` Stephen Boyd
  2024-05-07 21:17           ` Konrad Dybcio
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2024-05-07 20:28 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Michael Turquette, Vinod Koul
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel, Dmitry Baryshkov

Quoting Konrad Dybcio (2024-05-07 06:51:04)
> 
> without PARENT_OPS_ENABLE:
> 
> [    3.326891] sdhci_msm 8804000.mmc: Got CD GPIO
> [    3.336839] scsi host0: ufshcd
> [    3.337105] gcc_sdcc2_apps_clk_src is DISABLED @ set_rate
> [    3.346339] ------------[ cut here ]------------
> [    3.351093] gcc_sdcc2_apps_clk_src: rcg didn't update its configuration.
> [    3.351114] WARNING: CPU: 1 PID: 11 at drivers/clk/qcom/clk-rcg2.c:133 update_config+0xc8/0xd8
> 
> [...]
> 
> [    3.610523] gcc_sdcc2_apps_clk_src is ENABLED @ set_rate
> 
> 
> with PARENT_OPS_ENABLE:
> 
> [    3.331419] sdhci_msm 8804000.mmc: Got CD GPIO
> [    3.336569] gcc_sdcc2_apps_clk_src is DISABLED @ set_rate
> [    3.344795] scsi host0: ufshcd
> [    3.355122] qcrypto 1dfa000.crypto: Adding to iommu group 5
> [    3.363567] remoteproc remoteproc0: 2400000.remoteproc is available
> [    3.364729] gcc_sdcc2_apps_clk_src is ENABLED @ set_rate
> 
> after testing it both ways, I realized it wasn't supposed to make a
> difference in this regard, but I suppose I can paste both results anyway..
> 

Can you share your patch that prints the message? What bit are you
checking in the hardware to determine if the RCG is enabled? Do you also
print the enable count in software?

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

* Re: [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
  2024-05-07 20:28         ` Stephen Boyd
@ 2024-05-07 21:17           ` Konrad Dybcio
  2024-05-07 21:52             ` Stephen Boyd
  0 siblings, 1 reply; 9+ messages in thread
From: Konrad Dybcio @ 2024-05-07 21:17 UTC (permalink / raw)
  To: Stephen Boyd, Bjorn Andersson, Michael Turquette, Vinod Koul
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel, Dmitry Baryshkov



On 5/7/24 22:28, Stephen Boyd wrote:
> Quoting Konrad Dybcio (2024-05-07 06:51:04)
>>
>> without PARENT_OPS_ENABLE:
>>
>> [    3.326891] sdhci_msm 8804000.mmc: Got CD GPIO
>> [    3.336839] scsi host0: ufshcd
>> [    3.337105] gcc_sdcc2_apps_clk_src is DISABLED @ set_rate
>> [    3.346339] ------------[ cut here ]------------
>> [    3.351093] gcc_sdcc2_apps_clk_src: rcg didn't update its configuration.
>> [    3.351114] WARNING: CPU: 1 PID: 11 at drivers/clk/qcom/clk-rcg2.c:133 update_config+0xc8/0xd8
>>
>> [...]
>>
>> [    3.610523] gcc_sdcc2_apps_clk_src is ENABLED @ set_rate
>>
>>
>> with PARENT_OPS_ENABLE:
>>
>> [    3.331419] sdhci_msm 8804000.mmc: Got CD GPIO
>> [    3.336569] gcc_sdcc2_apps_clk_src is DISABLED @ set_rate
>> [    3.344795] scsi host0: ufshcd
>> [    3.355122] qcrypto 1dfa000.crypto: Adding to iommu group 5
>> [    3.363567] remoteproc remoteproc0: 2400000.remoteproc is available
>> [    3.364729] gcc_sdcc2_apps_clk_src is ENABLED @ set_rate
>>
>> after testing it both ways, I realized it wasn't supposed to make a
>> difference in this regard, but I suppose I can paste both results anyway..
>>
> 
> Can you share your patch that prints the message? What bit are you
> checking in the hardware to determine if the RCG is enabled? Do you also
> print the enable count in software?

I already reset-ed the tree state, but I added something like

if (rcg->cmd_rcgr == the one in the declaration)
	pr_err("gcc_sdcc2_apps_clk_src is %s\n", clk_is_enabled(hw) ? "ENABLED" : "DISABLED");

to drivers/clk/qcom/clk-rcg2.c : __clk_rcg2_set_rate()

Konrad

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

* Re: [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src
  2024-05-07 21:17           ` Konrad Dybcio
@ 2024-05-07 21:52             ` Stephen Boyd
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2024-05-07 21:52 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Michael Turquette, Vinod Koul
  Cc: Marijn Suijten, linux-arm-msm, linux-clk, linux-kernel, Dmitry Baryshkov

Quoting Konrad Dybcio (2024-05-07 14:17:01)
> 
> 
> On 5/7/24 22:28, Stephen Boyd wrote:
> >>
> > 
> > Can you share your patch that prints the message? What bit are you
> > checking in the hardware to determine if the RCG is enabled? Do you also
> > print the enable count in software?
> 
> I already reset-ed the tree state, but I added something like
> 
> if (rcg->cmd_rcgr == the one in the declaration)
>         pr_err("gcc_sdcc2_apps_clk_src is %s\n", clk_is_enabled(hw) ? "ENABLED" : "DISABLED");
> 
> to drivers/clk/qcom/clk-rcg2.c : __clk_rcg2_set_rate()
> 
> 

Ok. You're reading the software state because there isn't an is_enabled
clk_op for RCGs. Can you also read the CMD register (0x0 offset from
base) and check for CMD_ROOT_EN (bit 1) being set? That's what I mean
when I'm talking about the RCG being enabled in hardware. Similarly,
read CMD_ROOT_OFF (bit 31) to see if some child branch of the RCG is
enabled at this time.

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

end of thread, other threads:[~2024-05-07 21:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-27 12:01 [PATCH] clk: qcom: gcc-sm8450: set OPS_PARENT_ENABLE on gcc_sdcc2_apps_clk_src Konrad Dybcio
2024-04-27 19:34 ` Bjorn Andersson
2024-04-30  0:21 ` Stephen Boyd
2024-04-30 10:46   ` Konrad Dybcio
2024-04-30 21:26     ` Stephen Boyd
2024-05-07 13:51       ` Konrad Dybcio
2024-05-07 20:28         ` Stephen Boyd
2024-05-07 21:17           ` Konrad Dybcio
2024-05-07 21:52             ` Stephen Boyd

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