From d94634b0ab1bd61cc4088de63608287938a8fec2 Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Fri, 1 Jul 2016 15:47:14 +0800 Subject: [PATCH] ARM64: cpufreq_sched: implement event CPUFREQ_GOV_LIMIT for governor If we do not limit the freqency immediately when the cpu is overheat, thermal driver will lost the control of temperature. So implement event CPUFREQ_GOV_LIMIT for governor to limit the freqency immediately. Change-Id: Id709edd377226417ead92ead2ae3d3d19b3eeabf Signed-off-by: Chen Liang --- kernel/sched/cpufreq_sched.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/sched/cpufreq_sched.c b/kernel/sched/cpufreq_sched.c index e1d208e101ed..c608a9265d6a 100644 --- a/kernel/sched/cpufreq_sched.c +++ b/kernel/sched/cpufreq_sched.c @@ -327,6 +327,20 @@ static int cpufreq_sched_stop(struct cpufreq_policy *policy) return 0; } +static int cpufreq_sched_limits(struct cpufreq_policy *policy) +{ + if (policy->max < policy->cur) + __cpufreq_driver_target(policy, + policy->max, + CPUFREQ_RELATION_H); + else if (policy->min > policy->cur) + __cpufreq_driver_target(policy, + policy->min, + CPUFREQ_RELATION_L); + + return 0; +} + static int cpufreq_sched_setup(struct cpufreq_policy *policy, unsigned int event) { @@ -340,7 +354,7 @@ static int cpufreq_sched_setup(struct cpufreq_policy *policy, case CPUFREQ_GOV_STOP: return cpufreq_sched_stop(policy); case CPUFREQ_GOV_LIMITS: - break; + return cpufreq_sched_limits(policy); } return 0; } -- 2.34.1