Skip to content

Commit 85d8b11

Browse files
Mani-Sadhasivamvireshk
authored andcommitted
cpufreq: qcom: Fix qcom_cpufreq_hw_recalc_rate() to query LUT if LMh IRQ is not available
Currently, qcom_cpufreq_hw_recalc_rate() returns the LMh throttled frequency for the domain even if LMh IRQ is not available. But as per qcom_cpufreq_hw_get(), the driver has to query LUT entries to get the actual frequency of the domain. So do the same in qcom_cpufreq_hw_recalc_rate(). While doing so, refactor the existing qcom_cpufreq_hw_get() function so that qcom_cpufreq_hw_recalc_rate() can make use of the existing code and avoid code duplication. This also requires setting the qcom_cpufreq_data::policy even if LMh IRQ is not available. Fixes: 4370232 ("cpufreq: qcom-hw: Add CPU clock provider support") Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 1a4ddf6 commit 85d8b11

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,12 @@ static unsigned long qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data)
143143
}
144144

145145
/* Get the frequency requested by the cpufreq core for the CPU */
146-
static unsigned int qcom_cpufreq_get_freq(unsigned int cpu)
146+
static unsigned int qcom_cpufreq_get_freq(struct cpufreq_policy *policy)
147147
{
148148
struct qcom_cpufreq_data *data;
149149
const struct qcom_cpufreq_soc_data *soc_data;
150-
struct cpufreq_policy *policy;
151150
unsigned int index;
152151

153-
policy = cpufreq_cpu_get_raw(cpu);
154152
if (!policy)
155153
return 0;
156154

@@ -163,12 +161,10 @@ static unsigned int qcom_cpufreq_get_freq(unsigned int cpu)
163161
return policy->freq_table[index].frequency;
164162
}
165163

166-
static unsigned int qcom_cpufreq_hw_get(unsigned int cpu)
164+
static unsigned int __qcom_cpufreq_hw_get(struct cpufreq_policy *policy)
167165
{
168166
struct qcom_cpufreq_data *data;
169-
struct cpufreq_policy *policy;
170167

171-
policy = cpufreq_cpu_get_raw(cpu);
172168
if (!policy)
173169
return 0;
174170

@@ -177,7 +173,12 @@ static unsigned int qcom_cpufreq_hw_get(unsigned int cpu)
177173
if (data->throttle_irq >= 0)
178174
return qcom_lmh_get_throttle_freq(data) / HZ_PER_KHZ;
179175

180-
return qcom_cpufreq_get_freq(cpu);
176+
return qcom_cpufreq_get_freq(policy);
177+
}
178+
179+
static unsigned int qcom_cpufreq_hw_get(unsigned int cpu)
180+
{
181+
return __qcom_cpufreq_hw_get(cpufreq_cpu_get_raw(cpu));
181182
}
182183

183184
static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy,
@@ -363,7 +364,7 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
363364
* If h/w throttled frequency is higher than what cpufreq has requested
364365
* for, then stop polling and switch back to interrupt mechanism.
365366
*/
366-
if (throttled_freq >= qcom_cpufreq_get_freq(cpu))
367+
if (throttled_freq >= qcom_cpufreq_get_freq(cpufreq_cpu_get_raw(cpu)))
367368
enable_irq(data->throttle_irq);
368369
else
369370
mod_delayed_work(system_highpri_wq, &data->throttle_work,
@@ -441,7 +442,6 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index)
441442
return data->throttle_irq;
442443

443444
data->cancel_throttle = false;
444-
data->policy = policy;
445445

446446
mutex_init(&data->throttle_lock);
447447
INIT_DEFERRABLE_WORK(&data->throttle_work, qcom_lmh_dcvs_poll);
@@ -552,6 +552,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
552552

553553
policy->driver_data = data;
554554
policy->dvfs_possible_from_any_cpu = true;
555+
data->policy = policy;
555556

556557
ret = qcom_cpufreq_hw_read_lut(cpu_dev, policy);
557558
if (ret) {
@@ -622,7 +623,7 @@ static unsigned long qcom_cpufreq_hw_recalc_rate(struct clk_hw *hw, unsigned lon
622623
{
623624
struct qcom_cpufreq_data *data = container_of(hw, struct qcom_cpufreq_data, cpu_clk);
624625

625-
return qcom_lmh_get_throttle_freq(data);
626+
return __qcom_cpufreq_hw_get(data->policy) * HZ_PER_KHZ;
626627
}
627628

628629
static const struct clk_ops qcom_cpufreq_hw_clk_ops = {

0 commit comments

Comments
 (0)