Skip to content

Commit 193e8c9

Browse files
Mani-Sadhasivammehmetb0
authored andcommitted
cpufreq: qcom: Implement clk_ops::determine_rate() for qcom_cpufreq* clocks
BugLink: https://bugs.launchpad.net/bugs/2111953 [ Upstream commit a9ba290 ] determine_rate() callback is used by the clk_set_rate() API to get the closest rate of the target rate supported by the clock. If this callback is not implemented (nor round_rate() callback), then the API will assume that the clock cannot set the requested rate. And since there is no parent, it will return -EINVAL. This is not an issue right now as clk_set_rate() mistakenly compares the target rate with cached rate and bails out early. But once that is fixed to compare the target rate with the actual rate of the clock (returned by recalc_rate()), then clk_set_rate() for this clock will start to fail as below: cpu cpu0: _opp_config_clk_single: failed to set clock rate: -22 So implement the determine_rate() callback that just returns the actual rate at which the clock is passed to the CPUs in a domain. Fixes: 4370232 ("cpufreq: qcom-hw: Add CPU clock provider support") Reported-by: Johan Hovold <[email protected]> Suggested-by: Stephen Boyd <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Signed-off-by: Viresh Kumar <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent 63a8c8b commit 193e8c9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,21 @@ static unsigned long qcom_cpufreq_hw_recalc_rate(struct clk_hw *hw, unsigned lon
627627
return __qcom_cpufreq_hw_get(data->policy) * HZ_PER_KHZ;
628628
}
629629

630+
/*
631+
* Since we cannot determine the closest rate of the target rate, let's just
632+
* return the actual rate at which the clock is running at. This is needed to
633+
* make clk_set_rate() API work properly.
634+
*/
635+
static int qcom_cpufreq_hw_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
636+
{
637+
req->rate = qcom_cpufreq_hw_recalc_rate(hw, 0);
638+
639+
return 0;
640+
}
641+
630642
static const struct clk_ops qcom_cpufreq_hw_clk_ops = {
631643
.recalc_rate = qcom_cpufreq_hw_recalc_rate,
644+
.determine_rate = qcom_cpufreq_hw_determine_rate,
632645
};
633646

634647
static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)