Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: qcom-hw: Fix cpufreq_driver->get() for non-LMH systems

On a sc7180-based Chromebook, when I go to
/sys/devices/system/cpu/cpu0/cpufreq I can see:

cpuinfo_cur_freq:2995200
cpuinfo_max_freq:1804800
scaling_available_frequencies:300000 576000 ... 1708800 1804800
scaling_cur_freq:1804800
scaling_max_freq:1804800

As you can see the `cpuinfo_cur_freq` is bogus. It turns out that this
bogus info started showing up as of commit c72cf0cb1d77 ("cpufreq:
qcom-hw: Fix the frequency returned by cpufreq_driver->get()"). That
commit seems to assume that everyone is on the LMH bandwagon, but
sc7180 isn't.

Let's go back to the old code in the case where LMH isn't used.

Fixes: c72cf0cb1d77 ("cpufreq: qcom-hw: Fix the frequency returned by cpufreq_driver->get()")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
[ Viresh: Fixed the 'fixes' tag ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

authored by

Douglas Anderson and committed by
Viresh Kumar
51be2fff 1b929c02

+17 -15
+17 -15
drivers/cpufreq/qcom-cpufreq-hw.c
··· 143 143 return lval * xo_rate; 144 144 } 145 145 146 - /* Get the current frequency of the CPU (after throttling) */ 147 - static unsigned int qcom_cpufreq_hw_get(unsigned int cpu) 148 - { 149 - struct qcom_cpufreq_data *data; 150 - struct cpufreq_policy *policy; 151 - 152 - policy = cpufreq_cpu_get_raw(cpu); 153 - if (!policy) 154 - return 0; 155 - 156 - data = policy->driver_data; 157 - 158 - return qcom_lmh_get_throttle_freq(data) / HZ_PER_KHZ; 159 - } 160 - 161 146 /* Get the frequency requested by the cpufreq core for the CPU */ 162 147 static unsigned int qcom_cpufreq_get_freq(unsigned int cpu) 163 148 { ··· 162 177 index = min(index, LUT_MAX_ENTRIES - 1); 163 178 164 179 return policy->freq_table[index].frequency; 180 + } 181 + 182 + static unsigned int qcom_cpufreq_hw_get(unsigned int cpu) 183 + { 184 + struct qcom_cpufreq_data *data; 185 + struct cpufreq_policy *policy; 186 + 187 + policy = cpufreq_cpu_get_raw(cpu); 188 + if (!policy) 189 + return 0; 190 + 191 + data = policy->driver_data; 192 + 193 + if (data->throttle_irq >= 0) 194 + return qcom_lmh_get_throttle_freq(data) / HZ_PER_KHZ; 195 + 196 + return qcom_cpufreq_get_freq(cpu); 165 197 } 166 198 167 199 static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy,