[2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks

Message ID 20230612-topic-rcg2_ro-v1-2-e7d824aeb628@linaro.org
State New
Headers
Series Add read-only RCG2 ops |

Commit Message

Konrad Dybcio June 12, 2023, 9:22 a.m. UTC
  The config/periph/system NoC clocks are wholly controlled by the
RPM firmware and Linux should never ever alter their configuration.

Switch them over to read-only ops to avoid that.

Fixes: b1e010c0730a ("clk: qcom: Add MSM8996 Global Clock Control (GCC) driver")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/clk/qcom/gcc-msm8996.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Stephan Gerhold June 12, 2023, 10:17 a.m. UTC | #1
On Mon, Jun 12, 2023 at 11:22:48AM +0200, Konrad Dybcio wrote:
> The config/periph/system NoC clocks are wholly controlled by the
> RPM firmware and Linux should never ever alter their configuration.
> 
> Switch them over to read-only ops to avoid that.
> 
> Fixes: b1e010c0730a ("clk: qcom: Add MSM8996 Global Clock Control (GCC) driver")
> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>  drivers/clk/qcom/gcc-msm8996.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
> index 5e44d1bcca9e..588e3b67657a 100644
> --- a/drivers/clk/qcom/gcc-msm8996.c
> +++ b/drivers/clk/qcom/gcc-msm8996.c
> @@ -264,7 +264,7 @@ static struct clk_rcg2 system_noc_clk_src = {
>  		.name = "system_noc_clk_src",
>  		.parent_data = gcc_xo_gpll0_gpll0_early_div,
>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0_gpll0_early_div),
> -		.ops = &clk_rcg2_ops,
> +		.ops = &clk_rcg2_ro_ops,
>  	},
>  };
>  
> @@ -284,7 +284,7 @@ static struct clk_rcg2 config_noc_clk_src = {
>  		.name = "config_noc_clk_src",
>  		.parent_data = gcc_xo_gpll0,
>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
> -		.ops = &clk_rcg2_ops,
> +		.ops = &clk_rcg2_ro_ops,
>  	},
>  };
>  
> @@ -306,7 +306,7 @@ static struct clk_rcg2 periph_noc_clk_src = {
>  		.name = "periph_noc_clk_src",
>  		.parent_data = gcc_xo_gpll0,
>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
> -		.ops = &clk_rcg2_ops,
> +		.ops = &clk_rcg2_ro_ops,
>  	},
>  };
>  

If the rcg is read-only then it shouldn't need a .freq_tbl (the
.recalc_rate() works without it). These clocks have one for some reason.

Maybe we should also set .flags = CLK_GET_RATE_NOCACHE to ensure that
clk_get_rate() doesn't return some stale value? Although I'm not sure if
it's enough to set it here or if it would need to be set on all child
clocks as well.

Thanks,
Stephan
  
Konrad Dybcio June 12, 2023, 11:46 a.m. UTC | #2
On 12.06.2023 12:17, Stephan Gerhold wrote:
> On Mon, Jun 12, 2023 at 11:22:48AM +0200, Konrad Dybcio wrote:
>> The config/periph/system NoC clocks are wholly controlled by the
>> RPM firmware and Linux should never ever alter their configuration.
>>
>> Switch them over to read-only ops to avoid that.
>>
>> Fixes: b1e010c0730a ("clk: qcom: Add MSM8996 Global Clock Control (GCC) driver")
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>  drivers/clk/qcom/gcc-msm8996.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
>> index 5e44d1bcca9e..588e3b67657a 100644
>> --- a/drivers/clk/qcom/gcc-msm8996.c
>> +++ b/drivers/clk/qcom/gcc-msm8996.c
>> @@ -264,7 +264,7 @@ static struct clk_rcg2 system_noc_clk_src = {
>>  		.name = "system_noc_clk_src",
>>  		.parent_data = gcc_xo_gpll0_gpll0_early_div,
>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0_gpll0_early_div),
>> -		.ops = &clk_rcg2_ops,
>> +		.ops = &clk_rcg2_ro_ops,
>>  	},
>>  };
>>  
>> @@ -284,7 +284,7 @@ static struct clk_rcg2 config_noc_clk_src = {
>>  		.name = "config_noc_clk_src",
>>  		.parent_data = gcc_xo_gpll0,
>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
>> -		.ops = &clk_rcg2_ops,
>> +		.ops = &clk_rcg2_ro_ops,
>>  	},
>>  };
>>  
>> @@ -306,7 +306,7 @@ static struct clk_rcg2 periph_noc_clk_src = {
>>  		.name = "periph_noc_clk_src",
>>  		.parent_data = gcc_xo_gpll0,
>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
>> -		.ops = &clk_rcg2_ops,
>> +		.ops = &clk_rcg2_ro_ops,
>>  	},
>>  };
>>  
> 
> If the rcg is read-only then it shouldn't need a .freq_tbl (the
> .recalc_rate() works without it). These clocks have one for some reason.
.get_parent needs it

> 
> Maybe we should also set .flags = CLK_GET_RATE_NOCACHE to ensure that
> clk_get_rate() doesn't return some stale value? Although I'm not sure if
> it's enough to set it here or if it would need to be set on all child
> clocks as well.
Hm, I'm not sure if it makes sense for the children..

Konrad

> 
> Thanks,
> Stephan
  
Stephan Gerhold June 12, 2023, 12:23 p.m. UTC | #3
On Mon, Jun 12, 2023 at 01:46:26PM +0200, Konrad Dybcio wrote:
> On 12.06.2023 12:17, Stephan Gerhold wrote:
> > On Mon, Jun 12, 2023 at 11:22:48AM +0200, Konrad Dybcio wrote:
> >> The config/periph/system NoC clocks are wholly controlled by the
> >> RPM firmware and Linux should never ever alter their configuration.
> >>
> >> Switch them over to read-only ops to avoid that.
> >>
> >> Fixes: b1e010c0730a ("clk: qcom: Add MSM8996 Global Clock Control (GCC) driver")
> >> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> >> ---
> >>  drivers/clk/qcom/gcc-msm8996.c | 6 +++---
> >>  1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
> >> index 5e44d1bcca9e..588e3b67657a 100644
> >> --- a/drivers/clk/qcom/gcc-msm8996.c
> >> +++ b/drivers/clk/qcom/gcc-msm8996.c
> >> @@ -264,7 +264,7 @@ static struct clk_rcg2 system_noc_clk_src = {
> >>  		.name = "system_noc_clk_src",
> >>  		.parent_data = gcc_xo_gpll0_gpll0_early_div,
> >>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0_gpll0_early_div),
> >> -		.ops = &clk_rcg2_ops,
> >> +		.ops = &clk_rcg2_ro_ops,
> >>  	},
> >>  };
> >>  
> >> @@ -284,7 +284,7 @@ static struct clk_rcg2 config_noc_clk_src = {
> >>  		.name = "config_noc_clk_src",
> >>  		.parent_data = gcc_xo_gpll0,
> >>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
> >> -		.ops = &clk_rcg2_ops,
> >> +		.ops = &clk_rcg2_ro_ops,
> >>  	},
> >>  };
> >>  
> >> @@ -306,7 +306,7 @@ static struct clk_rcg2 periph_noc_clk_src = {
> >>  		.name = "periph_noc_clk_src",
> >>  		.parent_data = gcc_xo_gpll0,
> >>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
> >> -		.ops = &clk_rcg2_ops,
> >> +		.ops = &clk_rcg2_ro_ops,
> >>  	},
> >>  };
> >>  
> > 
> > If the rcg is read-only then it shouldn't need a .freq_tbl (the
> > .recalc_rate() works without it). These clocks have one for some reason.
> .get_parent needs it
> 

Hm? .get_parent uses the ->parent_map but not the ->freq_tbl as far as I
can see. :)

Stephan
  
Konrad Dybcio June 12, 2023, 12:25 p.m. UTC | #4
On 12.06.2023 14:23, Stephan Gerhold wrote:
> On Mon, Jun 12, 2023 at 01:46:26PM +0200, Konrad Dybcio wrote:
>> On 12.06.2023 12:17, Stephan Gerhold wrote:
>>> On Mon, Jun 12, 2023 at 11:22:48AM +0200, Konrad Dybcio wrote:
>>>> The config/periph/system NoC clocks are wholly controlled by the
>>>> RPM firmware and Linux should never ever alter their configuration.
>>>>
>>>> Switch them over to read-only ops to avoid that.
>>>>
>>>> Fixes: b1e010c0730a ("clk: qcom: Add MSM8996 Global Clock Control (GCC) driver")
>>>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>>>> ---
>>>>  drivers/clk/qcom/gcc-msm8996.c | 6 +++---
>>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
>>>> index 5e44d1bcca9e..588e3b67657a 100644
>>>> --- a/drivers/clk/qcom/gcc-msm8996.c
>>>> +++ b/drivers/clk/qcom/gcc-msm8996.c
>>>> @@ -264,7 +264,7 @@ static struct clk_rcg2 system_noc_clk_src = {
>>>>  		.name = "system_noc_clk_src",
>>>>  		.parent_data = gcc_xo_gpll0_gpll0_early_div,
>>>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0_gpll0_early_div),
>>>> -		.ops = &clk_rcg2_ops,
>>>> +		.ops = &clk_rcg2_ro_ops,
>>>>  	},
>>>>  };
>>>>  
>>>> @@ -284,7 +284,7 @@ static struct clk_rcg2 config_noc_clk_src = {
>>>>  		.name = "config_noc_clk_src",
>>>>  		.parent_data = gcc_xo_gpll0,
>>>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
>>>> -		.ops = &clk_rcg2_ops,
>>>> +		.ops = &clk_rcg2_ro_ops,
>>>>  	},
>>>>  };
>>>>  
>>>> @@ -306,7 +306,7 @@ static struct clk_rcg2 periph_noc_clk_src = {
>>>>  		.name = "periph_noc_clk_src",
>>>>  		.parent_data = gcc_xo_gpll0,
>>>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
>>>> -		.ops = &clk_rcg2_ops,
>>>> +		.ops = &clk_rcg2_ro_ops,
>>>>  	},
>>>>  };
>>>>  
>>>
>>> If the rcg is read-only then it shouldn't need a .freq_tbl (the
>>> .recalc_rate() works without it). These clocks have one for some reason.
>> .get_parent needs it
>>
> 
> Hm? .get_parent uses the ->parent_map but not the ->freq_tbl as far as I
> can see. :)
Brainfart. I think the ftbls can be removed.

Konrad
> 
> Stephan
  
Konrad Dybcio June 13, 2023, 5:54 p.m. UTC | #5
On 13.06.2023 19:56, Bjorn Andersson wrote:
> On Mon, Jun 12, 2023 at 11:22:48AM +0200, Konrad Dybcio wrote:
>> The config/periph/system NoC clocks are wholly controlled by the
>> RPM firmware and Linux should never ever alter their configuration.
>>
> 
> Does Linux need to know about them?
Not really, but it allows us to get rates of their children.

We can get rid of them if one can argue debugcc is enough. Unless
we need clk_get_rate for some reason.

Konrad
> 
> Regards,
> Bjorn
> 
>> Switch them over to read-only ops to avoid that.
>>
>> Fixes: b1e010c0730a ("clk: qcom: Add MSM8996 Global Clock Control (GCC) driver")
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>  drivers/clk/qcom/gcc-msm8996.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
>> index 5e44d1bcca9e..588e3b67657a 100644
>> --- a/drivers/clk/qcom/gcc-msm8996.c
>> +++ b/drivers/clk/qcom/gcc-msm8996.c
>> @@ -264,7 +264,7 @@ static struct clk_rcg2 system_noc_clk_src = {
>>  		.name = "system_noc_clk_src",
>>  		.parent_data = gcc_xo_gpll0_gpll0_early_div,
>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0_gpll0_early_div),
>> -		.ops = &clk_rcg2_ops,
>> +		.ops = &clk_rcg2_ro_ops,
>>  	},
>>  };
>>  
>> @@ -284,7 +284,7 @@ static struct clk_rcg2 config_noc_clk_src = {
>>  		.name = "config_noc_clk_src",
>>  		.parent_data = gcc_xo_gpll0,
>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
>> -		.ops = &clk_rcg2_ops,
>> +		.ops = &clk_rcg2_ro_ops,
>>  	},
>>  };
>>  
>> @@ -306,7 +306,7 @@ static struct clk_rcg2 periph_noc_clk_src = {
>>  		.name = "periph_noc_clk_src",
>>  		.parent_data = gcc_xo_gpll0,
>>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
>> -		.ops = &clk_rcg2_ops,
>> +		.ops = &clk_rcg2_ro_ops,
>>  	},
>>  };
>>  
>>
>> -- 
>> 2.41.0
>>
  
Bjorn Andersson June 13, 2023, 5:56 p.m. UTC | #6
On Mon, Jun 12, 2023 at 11:22:48AM +0200, Konrad Dybcio wrote:
> The config/periph/system NoC clocks are wholly controlled by the
> RPM firmware and Linux should never ever alter their configuration.
> 

Does Linux need to know about them?

Regards,
Bjorn

> Switch them over to read-only ops to avoid that.
> 
> Fixes: b1e010c0730a ("clk: qcom: Add MSM8996 Global Clock Control (GCC) driver")
> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>  drivers/clk/qcom/gcc-msm8996.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
> index 5e44d1bcca9e..588e3b67657a 100644
> --- a/drivers/clk/qcom/gcc-msm8996.c
> +++ b/drivers/clk/qcom/gcc-msm8996.c
> @@ -264,7 +264,7 @@ static struct clk_rcg2 system_noc_clk_src = {
>  		.name = "system_noc_clk_src",
>  		.parent_data = gcc_xo_gpll0_gpll0_early_div,
>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0_gpll0_early_div),
> -		.ops = &clk_rcg2_ops,
> +		.ops = &clk_rcg2_ro_ops,
>  	},
>  };
>  
> @@ -284,7 +284,7 @@ static struct clk_rcg2 config_noc_clk_src = {
>  		.name = "config_noc_clk_src",
>  		.parent_data = gcc_xo_gpll0,
>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
> -		.ops = &clk_rcg2_ops,
> +		.ops = &clk_rcg2_ro_ops,
>  	},
>  };
>  
> @@ -306,7 +306,7 @@ static struct clk_rcg2 periph_noc_clk_src = {
>  		.name = "periph_noc_clk_src",
>  		.parent_data = gcc_xo_gpll0,
>  		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
> -		.ops = &clk_rcg2_ops,
> +		.ops = &clk_rcg2_ro_ops,
>  	},
>  };
>  
> 
> -- 
> 2.41.0
>
  
Konrad Dybcio July 31, 2023, 11:01 a.m. UTC | #7
On 13.06.2023 19:54, Konrad Dybcio wrote:
> 
> 
> On 13.06.2023 19:56, Bjorn Andersson wrote:
>> On Mon, Jun 12, 2023 at 11:22:48AM +0200, Konrad Dybcio wrote:
>>> The config/periph/system NoC clocks are wholly controlled by the
>>> RPM firmware and Linux should never ever alter their configuration.
>>>
>>
>> Does Linux need to know about them?
> Not really, but it allows us to get rates of their children.
> 
> We can get rid of them if one can argue debugcc is enough. Unless
> we need clk_get_rate for some reason.
> 
Any opinions?

Konrad
  

Patch

diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
index 5e44d1bcca9e..588e3b67657a 100644
--- a/drivers/clk/qcom/gcc-msm8996.c
+++ b/drivers/clk/qcom/gcc-msm8996.c
@@ -264,7 +264,7 @@  static struct clk_rcg2 system_noc_clk_src = {
 		.name = "system_noc_clk_src",
 		.parent_data = gcc_xo_gpll0_gpll0_early_div,
 		.num_parents = ARRAY_SIZE(gcc_xo_gpll0_gpll0_early_div),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_ro_ops,
 	},
 };
 
@@ -284,7 +284,7 @@  static struct clk_rcg2 config_noc_clk_src = {
 		.name = "config_noc_clk_src",
 		.parent_data = gcc_xo_gpll0,
 		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_ro_ops,
 	},
 };
 
@@ -306,7 +306,7 @@  static struct clk_rcg2 periph_noc_clk_src = {
 		.name = "periph_noc_clk_src",
 		.parent_data = gcc_xo_gpll0,
 		.num_parents = ARRAY_SIZE(gcc_xo_gpll0),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_ro_ops,
 	},
 };