Skip to content

Commit 63a8c8b

Browse files
Mani-Sadhasivammehmetb0
authored andcommitted
cpufreq: qcom: Fix qcom_cpufreq_hw_recalc_rate() to query LUT if LMh IRQ is not available
BugLink: https://bugs.launchpad.net/bugs/2111953 [ Upstream commit 85d8b11 ] 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 <[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 218d45a commit 63a8c8b

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
@@ -142,14 +142,12 @@ static unsigned long qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data)
142142
}
143143

144144
/* Get the frequency requested by the cpufreq core for the CPU */
145-
static unsigned int qcom_cpufreq_get_freq(unsigned int cpu)
145+
static unsigned int qcom_cpufreq_get_freq(struct cpufreq_policy *policy)
146146
{
147147
struct qcom_cpufreq_data *data;
148148
const struct qcom_cpufreq_soc_data *soc_data;
149-
struct cpufreq_policy *policy;
150149
unsigned int index;
151150

152-
policy = cpufreq_cpu_get_raw(cpu);
153151
if (!policy)
154152
return 0;
155153

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

165-
static unsigned int qcom_cpufreq_hw_get(unsigned int cpu)
163+
static unsigned int __qcom_cpufreq_hw_get(struct cpufreq_policy *policy)
166164
{
167165
struct qcom_cpufreq_data *data;
168-
struct cpufreq_policy *policy;
169166

170-
policy = cpufreq_cpu_get_raw(cpu);
171167
if (!policy)
172168
return 0;
173169

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

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

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

442443
data->cancel_throttle = false;
443-
data->policy = policy;
444444

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

552552
policy->driver_data = data;
553553
policy->dvfs_possible_from_any_cpu = true;
554+
data->policy = policy;
554555

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

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

629630
static const struct clk_ops qcom_cpufreq_hw_clk_ops = {

0 commit comments

Comments
 (0)