ARM64: cpufreq_sched: implement event CPUFREQ_GOV_LIMIT for governor
authorChen Liang <cl@rock-chips.com>
Fri, 1 Jul 2016 07:47:14 +0000 (15:47 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Thu, 7 Jul 2016 03:30:24 +0000 (11:30 +0800)
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 <cl@rock-chips.com>
kernel/sched/cpufreq_sched.c

index e1d208e..c608a92 100644 (file)
@@ -327,6 +327,20 @@ static int cpufreq_sched_stop(struct cpufreq_policy *policy)
        return 0;
 }
 
        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)
 {
 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:
        case CPUFREQ_GOV_STOP:
                return cpufreq_sched_stop(policy);
        case CPUFREQ_GOV_LIMITS:
-               break;
+               return cpufreq_sched_limits(policy);
        }
        return 0;
 }
        }
        return 0;
 }