Add read-only RCG2 ops
Subsystems (3)
cover Add read-only RCG2 ops
Some of the clocks are managed by remote cores and we're not supposed to alter their parameters. Monitoring them may still be useful, e.g. for getting the correct rates of their children. This series attempts to solve this problem without compromising on either of them.
---
Konrad Dybcio (2):
clk: qcom: rcg2: Introduce read-only RCG2 ops
clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
drivers/clk/qcom/clk-rcg.h | 1 + drivers/clk/qcom/clk-rcg2.c | 8 ++++++++ drivers/clk/qcom/gcc-msm8996.c | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-)
---
base-commit: 53ab6975c12d1ad86c599a8927e8c698b144d669
change-id: 20230612-topic-rcg2_ro-1450a076eda9
Best regards,
Signature · 1 line
Konrad Dybcio <[email protected]>
PATCH 1/2 clk: qcom: rcg2: Introduce read-only RCG2 ops
Some clocks are physically part of a clock controller block (e.g. GCC), but are under no circumstances supposed to be touched from HLOS/APSS, as another subsystem manages them, and trying to alter its configuration may (and likely will) wreck total havoc over whatever the clock is attached to.
Add read-only ops for RCG clocks. This allows us to peak at the rates (and other configuration parameters) of such clocks without the risk of messing up half of the SoC due to an erroneous CCF call.
--- drivers/clk/qcom/clk-rcg.h | 1 + drivers/clk/qcom/clk-rcg2.c | 8 ++++++++ 2 files changed, 9 insertions(+)
drivers/clk/qcom/clk-rcg.h +1 -0
@@ -170,6 +170,7 @@ struct clk_rcg2_gfx3d {extern const struct clk_ops clk_rcg2_ops;extern const struct clk_ops clk_rcg2_floor_ops;extern const struct clk_ops clk_rcg2_mux_closest_ops; +extern const struct clk_ops clk_rcg2_ro_ops;extern const struct clk_ops clk_edp_pixel_ops;extern const struct clk_ops clk_byte_ops;extern const struct clk_ops clk_byte2_ops;
drivers/clk/qcom/clk-rcg2.c +8 -0
@@ -518,6 +518,14 @@ const struct clk_ops clk_rcg2_mux_closest_ops = { };EXPORT_SYMBOL_GPL (clk_rcg2_mux_closest_ops); +const struct clk_ops clk_rcg2_ro_ops = { + .is_enabled = clk_rcg2_is_enabled, + .get_parent = clk_rcg2_get_parent, + .recalc_rate = clk_rcg2_recalc_rate, + .get_duty_cycle = clk_rcg2_get_duty_cycle, +}; +EXPORT_SYMBOL_GPL (clk_rcg2_ro_ops); +struct frac_entry {int num;int den;
Signature · 1 line
2.41.0
PATCH 2/2 clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
In reply to Konrad DybcioThe 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.
--- drivers/clk/qcom/gcc-msm8996.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/qcom/gcc-msm8996.c +3 -3
@@ -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, }, };
Signature · 1 line
2.41.0
Re: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
Quoted 34 lines · Konrad Dybcio
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 <[email protected]>--- drivers/clk/qcom/gcc-msm8996.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/clk/qcom/gcc-msm8996.c +2
-2@@ -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, }, };
drivers/clk/qcom/gcc-msm8996.c static struct clk_rcg2 periph_noc_clk_src = { · line 312
Quoted 8 lines
drivers/clk/qcom/gcc-msm8996.c +1
-1@@ -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
Re: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
Quoted 34 lines · Stephan Gerhold
Quoted 33 lines · Konrad Dybcio
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 <[email protected]>--- drivers/clk/qcom/gcc-msm8996.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/clk/qcom/gcc-msm8996.c +2
-2@@ -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, }, };
Quoted 12 lines
drivers/clk/qcom/gcc-msm8996.c static struct clk_rcg2 periph_noc_clk_src = { · line 312
Quoted 9 lines
drivers/clk/qcom/gcc-msm8996.c +1
-1@@ -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
Quoted 5 lines
Maybe we should also set .flags =
CLK_GET_RATE_NOCACHEto ensure thatclk_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
Quoted 3 lines
Thanks,
Stephan
Re: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
Quoted 47 lines · Konrad Dybcio
Quoted 34 lines · Stephan Gerhold
Quoted 33 lines · Konrad Dybcio
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 <[email protected]>--- drivers/clk/qcom/gcc-msm8996.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/clk/qcom/gcc-msm8996.c +2
-2@@ -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, }, };Quoted 12 lines
drivers/clk/qcom/gcc-msm8996.c static struct clk_rcg2 periph_noc_clk_src = { · line 312
Quoted 9 lines
drivers/clk/qcom/gcc-msm8996.c +1
-1@@ -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.
Quoted 2 lines
.get_parent needs it
Hm? .get_parent uses the ->parent_map but not the ->freq_tbl as far as I can see. :)
Stephan
Re: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
Quoted 48 lines · Stephan Gerhold
Quoted 47 lines · Konrad Dybcio
Quoted 46 lines · Stephan Gerhold
Quoted 34 lines · Konrad Dybcio
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 <[email protected]>--- drivers/clk/qcom/gcc-msm8996.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/clk/qcom/gcc-msm8996.c +2
-2@@ -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, }, };drivers/clk/qcom/gcc-msm8996.c static struct clk_rcg2 periph_noc_clk_src = { · line 312
Quoted 8 lines
drivers/clk/qcom/gcc-msm8996.c +1
-1@@ -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.
Quoted 5 lines
Quoted 2 lines
.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
Quoted 2 lines
Stephan
Bjorn Andersson
maintainerRe: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
In reply to Konrad DybcioQuoted 3 lines · Konrad Dybcio
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
Quoted 43 lines
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 <[email protected]>--- drivers/clk/qcom/gcc-msm8996.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/clk/qcom/gcc-msm8996.c +3
-3@@ -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, }, };Signature · 2 lines
-- 2.41.0
Re: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
Quoted 6 lines · Bjorn Andersson
Quoted 3 lines · Konrad Dybcio
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
Quoted 47 lines
Regards,
BjornQuoted 43 lines
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 <[email protected]>--- drivers/clk/qcom/gcc-msm8996.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/clk/qcom/gcc-msm8996.c +3
-3@@ -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, }, };Signature · 2 lines
-- 2.41.0
Re: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Bjorn Andersson
Quoted 3 lines · Konrad Dybcio
The config/periph/system NoC clocks are wholly controlled by the RPM firmware and Linux should never ever alter their configuration.
Quoted 6 lines
Quoted 1 line
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_ratefor some reason.
Any opinions?
Konrad
Re: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
Quoted 9 lines · Konrad Dybcio
Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Bjorn Andersson
Quoted 3 lines · Konrad Dybcio
The config/periph/system NoC clocks are wholly controlled by the RPM firmware and Linux should never ever alter their configuration.
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
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_ratefor some reason.Any opinions?
So, do we drop them?
Konrad
Re: [PATCH 2/2] clk: qcom: gcc-msm8996: Use read-only RCG ops for RPM bus clocks
Quoted 11 lines · Konrad Dybcio
Quoted 9 lines · Konrad Dybcio
Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Bjorn Andersson
Quoted 3 lines · Konrad Dybcio
The config/periph/system NoC clocks are wholly controlled by the RPM firmware and Linux should never ever alter their configuration.
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
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_ratefor some reason.Any opinions?
So, do we drop them?
My opinion would be to drop the NoC clocks unless there is any extra value (like child clocks).
Signature · 2 lines
With best wishes Dmitry