Revert "clk: Fix invalid execution of clk_set_rate"
Subsystems (2)
PATCH 1/1 Revert "clk: Fix invalid execution of clk_set_rate"
This reverts commit 25f1c96a0e841013647d788d4598e364e5c2ebb7.
The offending commit results in errors like
cpu cpu0: _opp_config_clk_single: failed to set clock rate: -22
spamming the logs on the Lenovo ThinkPad X13s and other Qualcomm machines when cpufreq tries to update the CPUFreq HW Engine clocks.
As mentioned in commit 4370232c727b ("cpufreq: qcom-hw: Add CPU clock provider support"):
[T]he frequency supplied by the driver is the actual frequency that comes out of the EPSS/OSM block after the DCVS operation. This frequency is not same as what the CPUFreq framework has set but it is the one that gets supplied to the CPUs after throttling by LMh.
which seems to suggest that the driver relies on the previous behaviour of clk_set_rate().
Since this affects many Qualcomm machines, let's revert for now.
---
#regzbot introduced: 25f1c96a0e84
drivers/clk/clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk.c +1 -1
@@ -2539,7 +2539,7 @@ static int clk_core_set_rate_nolock(struct clk_core *core, rate =clk_core_req_round_rate_nolock (core, req_rate);/* bail early if nothing to do */ -if (rate ==clk_core_get_rate_recalc (core)) +if (rate ==clk_core_get_rate_nolock (core))return 0 ;/* fail on a direct rate set of a protected provider */
Signature · 1 line
2.45.2
Quoting Johan Hovold (2024-12-02 02:06:21)
Quoted 12 lines
This reverts commit
25f1c96a0e841013647d788d4598e364e5c2ebb7.The offending commit results in errors like
cpu cpu0:
_opp_config_clk_single: failed to set clock rate: -22spamming the logs on the Lenovo ThinkPad X13s and other Qualcomm machines when cpufreq tries to update the CPUFreq HW Engine clocks.
As mentioned in commit
4370232c727b("cpufreq: qcom-hw: Add CPU clock provider support"):
Quoted 8 lines
[T]he frequency supplied by the driver is the actual frequency that comes out of the EPSS/OSM block after the DCVS operation. This frequency is not same as what the CPUFreq framework has set but it is the one that gets supplied to the CPUs after throttling by LMh.
which seems to suggest that the driver relies on the previous behaviour of
clk_set_rate().
I don't understand why a clk provider is needed there. Is anyone looking into the real problem?
Quoted 10 lines
Since this affects many Qualcomm machines, let's revert for now.
Fixes 25f1c96a0e84 ("clk: Fix invalid execution of clk_set_rate")Reported-by Aishwarya TCV <[email protected]>Cc Chuan Liu <[email protected]>Cc Manivannan Sadhasivam <[email protected]>Signed-off-by Johan Hovold <[email protected]>---
Applied to clk-fixes
[ +CC: Viresh and Sudeep ]
Quoted 19 lines · Stephen Boyd
Quoting Johan Hovold (2024-12-02 02:06:21)
Quoted 18 lines
This reverts commit
25f1c96a0e841013647d788d4598e364e5c2ebb7.The offending commit results in errors like
cpu cpu0:
_opp_config_clk_single: failed to set clock rate: -22spamming the logs on the Lenovo ThinkPad X13s and other Qualcomm machines when cpufreq tries to update the CPUFreq HW Engine clocks.
As mentioned in commit
4370232c727b("cpufreq: qcom-hw: Add CPU clock provider support"):[T]he frequency supplied by the driver is the actual frequency that comes out of the EPSS/OSM block after the DCVS operation. This frequency is not same as what the CPUFreq framework has set but it is the one that gets supplied to the CPUs after throttling by LMh.
Quoted 5 lines
Quoted 2 lines
which seems to suggest that the driver relies on the previous behaviour of
clk_set_rate().I don't understand why a clk provider is needed there. Is anyone looking into the real problem?
I mentioned this to Mani yesterday, but I'm not sure if he has had time to look into it yet. And I forgot to CC Viresh who was involved in implementing this. There is comment of his in the thread where this feature was added:
Most likely no one will ever do clk_set_rate() on this new clock, which is fine, though OPP core will likely do clk_get_rate() here.
which may suggest that some underlying assumption has changed. [1]
There are some more details in that thread that should explain why things were implemented the way they were:
https://lore.kernel.org/linux-arm-msm/[email protected]/
Quoted 11 lines
Quoted 9 lines
Since this affects many Qualcomm machines, let's revert for now.
Fixes 25f1c96a0e84 ("clk: Fix invalid execution of clk_set_rate")Reported-by Aishwarya TCV <[email protected]>Cc Chuan Liu <[email protected]>Cc Manivannan Sadhasivam <[email protected]>Signed-off-by Johan Hovold <[email protected]>---
Applied to clk-fixes
Thanks.
Johan
[1] https://lore.kernel.org/linux-arm-msm/20221118055730.yrzpuih3zfko5c2q@vireshk-i7/
Quoted 33 lines · Johan Hovold
[ +CC: Viresh and Sudeep ]
Quoted 19 lines · Stephen Boyd
Quoting Johan Hovold (2024-12-02 02:06:21)
Quoted 18 lines
This reverts commit
25f1c96a0e841013647d788d4598e364e5c2ebb7.The offending commit results in errors like
cpu cpu0:
_opp_config_clk_single: failed to set clock rate: -22spamming the logs on the Lenovo ThinkPad X13s and other Qualcomm machines when cpufreq tries to update the CPUFreq HW Engine clocks.
As mentioned in commit
4370232c727b("cpufreq: qcom-hw: Add CPU clock provider support"):[T]he frequency supplied by the driver is the actual frequency that comes out of the EPSS/OSM block after the DCVS operation. This frequency is not same as what the CPUFreq framework has set but it is the one that gets supplied to the CPUs after throttling by LMh.
Quoted 5 lines
Quoted 2 lines
which seems to suggest that the driver relies on the previous behaviour of
clk_set_rate().I don't understand why a clk provider is needed there. Is anyone looking into the real problem?
I mentioned this to Mani yesterday, but I'm not sure if he has had time to look into it yet. And I forgot to CC Viresh who was involved in implementing this. There is comment of his in the thread where this feature was added:
Quoted 6 lines
Most likely no one will ever do
clk_set_rate()on this new clock, which is fine, though OPP core will likely doclk_get_rate()here.which may suggest that some underlying assumption has changed. [1]
I just looked into the issue this morning. The commit that triggered the errors seem to be doing the right thing (although the commit message was a bit hard to understand), but the problem is this check which gets triggered now:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk.c?h=v6.13-rc1#n2319
Since the qcom-cpufreq* clocks doesn't have parents now (they should've been defined anyway) and there is no CLK_SET_RATE_PARENT flag set, the check returns NULL for the 'top' clock. Then clk_core_set_rate_nolock() returns -EINVAL, causing the reported error.
But I don't quite understand why clk_core_set_rate_nolock() fails if there is no parent or CLK_SET_RATE_PARENT is not set. The API is supposed to set the rate of the passed clock irrespective of the parent. Propagating the rate change to parent is not strictly needed and doesn't make sense if the parent is a fixed clock like XO.
Stephen, thoughts?
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Stephen Boyd
maintainerQuoting Manivannan Sadhasivam (2024-12-03 01:21:51)
Quoted 34 lines · Johan Hovold
Quoted 33 lines
[ +CC: Viresh and Sudeep ]
Quoted 19 lines · Stephen Boyd
Quoting Johan Hovold (2024-12-02 02:06:21)
Quoted 18 lines
This reverts commit
25f1c96a0e841013647d788d4598e364e5c2ebb7.The offending commit results in errors like
cpu cpu0:
_opp_config_clk_single: failed to set clock rate: -22spamming the logs on the Lenovo ThinkPad X13s and other Qualcomm machines when cpufreq tries to update the CPUFreq HW Engine clocks.
As mentioned in commit
4370232c727b("cpufreq: qcom-hw: Add CPU clock provider support"):[T]he frequency supplied by the driver is the actual frequency that comes out of the EPSS/OSM block after the DCVS operation. This frequency is not same as what the CPUFreq framework has set but it is the one that gets supplied to the CPUs after throttling by LMh.
Quoted 5 lines
Quoted 2 lines
which seems to suggest that the driver relies on the previous behaviour of
clk_set_rate().I don't understand why a clk provider is needed there. Is anyone looking into the real problem?
I mentioned this to Mani yesterday, but I'm not sure if he has had time to look into it yet. And I forgot to CC Viresh who was involved in implementing this. There is comment of his in the thread where this feature was added:
Quoted 6 lines
Quoted 6 lines
Most likely no one will ever do
clk_set_rate()on this new clock, which is fine, though OPP core will likely doclk_get_rate()here.which may suggest that some underlying assumption has changed. [1]
Yikes.
Quoted 11 lines
I just looked into the issue this morning. The commit that triggered the errors seem to be doing the right thing (although the commit message was a bit hard to understand), but the problem is this check which gets triggered now:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk.c?h=v6.13-rc1#n2319Since the qcom-cpufreq* clocks doesn't have parents now (they should've been defined anyway) and there is no
CLK_SET_RATE_PARENTflag set, the check returns NULL for the 'top' clock. Thenclk_core_set_rate_nolock()returns-EINVAL, causing the reported error.
Quoted 5 lines
But I don't quite understand why
clk_core_set_rate_nolock()fails if there is no parent orCLK_SET_RATE_PARENTis not set. The API is supposed to set the rate of the passed clock irrespective of the parent. Propagating the rate change to parent is not strictly needed and doesn't make sense if the parent is a fixed clock like XO.
The recalc_rate clk_op is telling the framework that the clk is at a different rate than is requested by the clk consumer _and_ than what the framework thinks the clk is currently running at. The clk_set_rate() call is going to attempt to satisfy that request, and because there isn't a determine_rate/round_rate clk_op it assumes the clk can't change rate so it looks to see if there's a parent that can be changed to satisfy the rate. There isn't a parent either, so the clk_set_rate() call fails because the rate can't be achieved on this clk.
It may work to have a determine_rate clk_op that is like the recalc_rate one that says "this rate you requested is going to turn into whatever the hardware is running at" by simply returning the rate that the clk is running at.
Quoted 70 lines · Stephen Boyd
Quoting Manivannan Sadhasivam (2024-12-03 01:21:51)
Quoted 34 lines · Johan Hovold
Quoted 33 lines
[ +CC: Viresh and Sudeep ]
Quoted 19 lines · Stephen Boyd
Quoting Johan Hovold (2024-12-02 02:06:21)
Quoted 18 lines
This reverts commit
25f1c96a0e841013647d788d4598e364e5c2ebb7.The offending commit results in errors like
cpu cpu0:
_opp_config_clk_single: failed to set clock rate: -22spamming the logs on the Lenovo ThinkPad X13s and other Qualcomm machines when cpufreq tries to update the CPUFreq HW Engine clocks.
As mentioned in commit
4370232c727b("cpufreq: qcom-hw: Add CPU clock provider support"):[T]he frequency supplied by the driver is the actual frequency that comes out of the EPSS/OSM block after the DCVS operation. This frequency is not same as what the CPUFreq framework has set but it is the one that gets supplied to the CPUs after throttling by LMh.
Quoted 5 lines
Quoted 2 lines
which seems to suggest that the driver relies on the previous behaviour of
clk_set_rate().I don't understand why a clk provider is needed there. Is anyone looking into the real problem?
I mentioned this to Mani yesterday, but I'm not sure if he has had time to look into it yet. And I forgot to CC Viresh who was involved in implementing this. There is comment of his in the thread where this feature was added:
Quoted 6 lines
Quoted 6 lines
Most likely no one will ever do
clk_set_rate()on this new clock, which is fine, though OPP core will likely doclk_get_rate()here.which may suggest that some underlying assumption has changed. [1]
Yikes.
Quoted 11 lines
I just looked into the issue this morning. The commit that triggered the errors seem to be doing the right thing (although the commit message was a bit hard to understand), but the problem is this check which gets triggered now:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk.c?h=v6.13-rc1#n2319Since the qcom-cpufreq* clocks doesn't have parents now (they should've been defined anyway) and there is no
CLK_SET_RATE_PARENTflag set, the check returns NULL for the 'top' clock. Thenclk_core_set_rate_nolock()returns-EINVAL, causing the reported error.Quoted 5 lines
But I don't quite understand why
clk_core_set_rate_nolock()fails if there is no parent orCLK_SET_RATE_PARENTis not set. The API is supposed to set the rate of the passed clock irrespective of the parent. Propagating the rate change to parent is not strictly needed and doesn't make sense if the parent is a fixed clock like XO.The
recalc_rateclk_opis telling the framework that the clk is at a different rate than is requested by the clk consumer _and_ than what the framework thinks the clk is currently running at. Theclk_set_rate()call is going to attempt to satisfy that request, and because there isn't a determine_rate/round_rateclk_opit assumes the clk can't change rate so it looks to see if there's a parent that can be changed to satisfy the rate. There isn't a parent either, so theclk_set_rate()call fails because the rate can't be achieved on this clk.
Quoted 4 lines
It may work to have a
determine_rateclk_opthat is like therecalc_rateone that says "this rate you requested is going to turn into whatever the hardware is running at" by simply returning the rate that the clk is running at.
Sounds reasonable to me. Fix submitted incorporating your suggestion, thanks!
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்