Commit 51be2fff authored by Douglas Anderson's avatar Douglas Anderson Committed by Viresh Kumar

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 c72cf0cb ("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: c72cf0cb ("cpufreq: qcom-hw: Fix the frequency returned by cpufreq_driver->get()")
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: default avatarManivannan Sadhasivam <mani@kernel.org>
[ Viresh: Fixed the 'fixes' tag ]
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 1b929c02
...@@ -143,40 +143,42 @@ static unsigned long qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data) ...@@ -143,40 +143,42 @@ static unsigned long qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data)
return lval * xo_rate; return lval * xo_rate;
} }
/* Get the current frequency of the CPU (after throttling) */ /* Get the frequency requested by the cpufreq core for the CPU */
static unsigned int qcom_cpufreq_hw_get(unsigned int cpu) static unsigned int qcom_cpufreq_get_freq(unsigned int cpu)
{ {
struct qcom_cpufreq_data *data; struct qcom_cpufreq_data *data;
const struct qcom_cpufreq_soc_data *soc_data;
struct cpufreq_policy *policy; struct cpufreq_policy *policy;
unsigned int index;
policy = cpufreq_cpu_get_raw(cpu); policy = cpufreq_cpu_get_raw(cpu);
if (!policy) if (!policy)
return 0; return 0;
data = policy->driver_data; data = policy->driver_data;
soc_data = qcom_cpufreq.soc_data;
return qcom_lmh_get_throttle_freq(data) / HZ_PER_KHZ; index = readl_relaxed(data->base + soc_data->reg_perf_state);
index = min(index, LUT_MAX_ENTRIES - 1);
return policy->freq_table[index].frequency;
} }
/* Get the frequency requested by the cpufreq core for the CPU */ static unsigned int qcom_cpufreq_hw_get(unsigned int cpu)
static unsigned int qcom_cpufreq_get_freq(unsigned int cpu)
{ {
struct qcom_cpufreq_data *data; struct qcom_cpufreq_data *data;
const struct qcom_cpufreq_soc_data *soc_data;
struct cpufreq_policy *policy; struct cpufreq_policy *policy;
unsigned int index;
policy = cpufreq_cpu_get_raw(cpu); policy = cpufreq_cpu_get_raw(cpu);
if (!policy) if (!policy)
return 0; return 0;
data = policy->driver_data; data = policy->driver_data;
soc_data = qcom_cpufreq.soc_data;
index = readl_relaxed(data->base + soc_data->reg_perf_state); if (data->throttle_irq >= 0)
index = min(index, LUT_MAX_ENTRIES - 1); return qcom_lmh_get_throttle_freq(data) / HZ_PER_KHZ;
return policy->freq_table[index].frequency; return qcom_cpufreq_get_freq(cpu);
} }
static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy, static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment