]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cpufreq: scpi: compare kHz instead of Hz
authorzuoqian <zuoqian113@gmail.com>
Sat, 25 Jan 2025 08:49:49 +0000 (08:49 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:30:55 +0000 (14:30 +0200)
[ Upstream commit 4742da9774a416908ef8e3916164192c15c0e2d1 ]

The CPU rate from clk_get_rate() may not be divisible by 1000
(e.g., 133333333). But the rate calculated from frequency(kHz) is
always divisible by 1000 (e.g., 133333000).
Comparing the rate causes a warning during CPU scaling:
"cpufreq: __target_index: Failed to change cpu frequency: -5".
When we choose to compare kHz here, the issue does not occur.

Fixes: 343a8d17fa8d ("cpufreq: scpi: remove arm_big_little dependency")
Signed-off-by: zuoqian <zuoqian113@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpufreq/scpi-cpufreq.c

index e5140ad63db8369ab53c8aa3c096e7e98b818f57..c79cdf1be7803b8a605fddec630d316d11caaab2 100644 (file)
@@ -47,8 +47,9 @@ static unsigned int scpi_cpufreq_get_rate(unsigned int cpu)
 static int
 scpi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
 {
-       u64 rate = policy->freq_table[index].frequency * 1000;
+       unsigned long freq_khz = policy->freq_table[index].frequency;
        struct scpi_data *priv = policy->driver_data;
+       unsigned long rate = freq_khz * 1000;
        int ret;
 
        ret = clk_set_rate(priv->clk, rate);
@@ -56,7 +57,7 @@ scpi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
        if (ret)
                return ret;
 
-       if (clk_get_rate(priv->clk) != rate)
+       if (clk_get_rate(priv->clk) / 1000 != freq_khz)
                return -EIO;
 
        return 0;