Skip to content

Commit c4c0efb

Browse files
Xuewen Yanvireshk
authored andcommitted
cpufreq: qcom-cpufreq-hw: Add cpufreq qos for LMh
Before update thermal pressure, the max cpufreq should be limited. Add QOS control for Lmh throttle cpufreq. Signed-off-by: Xuewen Yan <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent f7968c2 commit c4c0efb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of_address.h>
1414
#include <linux/of_platform.h>
1515
#include <linux/pm_opp.h>
16+
#include <linux/pm_qos.h>
1617
#include <linux/slab.h>
1718
#include <linux/spinlock.h>
1819
#include <linux/units.h>
@@ -56,6 +57,8 @@ struct qcom_cpufreq_data {
5657
struct cpufreq_policy *policy;
5758

5859
bool per_core_dcvs;
60+
61+
struct freq_qos_request throttle_freq_req;
5962
};
6063

6164
static unsigned long cpu_hw_rate, xo_rate;
@@ -321,6 +324,8 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
321324

322325
throttled_freq = freq_hz / HZ_PER_KHZ;
323326

327+
freq_qos_update_request(&data->throttle_freq_req, throttled_freq);
328+
324329
/* Update thermal pressure (the boost frequencies are accepted) */
325330
arch_update_thermal_pressure(policy->related_cpus, throttled_freq);
326331

@@ -413,6 +418,14 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index)
413418
if (data->throttle_irq < 0)
414419
return data->throttle_irq;
415420

421+
ret = freq_qos_add_request(&policy->constraints,
422+
&data->throttle_freq_req, FREQ_QOS_MAX,
423+
FREQ_QOS_MAX_DEFAULT_VALUE);
424+
if (ret < 0) {
425+
dev_err(&pdev->dev, "Failed to add freq constraint (%d)\n", ret);
426+
return ret;
427+
}
428+
416429
data->cancel_throttle = false;
417430
data->policy = policy;
418431

@@ -479,6 +492,7 @@ static void qcom_cpufreq_hw_lmh_exit(struct qcom_cpufreq_data *data)
479492
if (data->throttle_irq <= 0)
480493
return;
481494

495+
freq_qos_remove_request(&data->throttle_freq_req);
482496
free_irq(data->throttle_irq, data);
483497
}
484498

0 commit comments

Comments
 (0)