Merge branch 'writable_limits' of git://decibel.fi.muni.cz/~xslaby/linux
[firefly-linux-kernel-4.4.55.git] / drivers / cpufreq / cpufreq_ondemand.c
index e1314212d8d4e2d3789c2ae4658e504963bc6a90..7b5093664e49ba4d2172cd208c5d6ae7b7b419ee 100644 (file)
@@ -459,6 +459,17 @@ static struct attribute_group dbs_attr_group_old = {
 
 /************************** sysfs end ************************/
 
+static void dbs_freq_increase(struct cpufreq_policy *p, unsigned int freq)
+{
+       if (dbs_tuners_ins.powersave_bias)
+               freq = powersave_bias_target(p, freq, CPUFREQ_RELATION_H);
+       else if (p->cur == p->max)
+               return;
+
+       __cpufreq_driver_target(p, freq, dbs_tuners_ins.powersave_bias ?
+                       CPUFREQ_RELATION_L : CPUFREQ_RELATION_H);
+}
+
 static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
 {
        unsigned int max_load_freq;
@@ -551,19 +562,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
 
        /* Check for frequency increase */
        if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
-               /* if we are already at full speed then break out early */
-               if (!dbs_tuners_ins.powersave_bias) {
-                       if (policy->cur == policy->max)
-                               return;
-
-                       __cpufreq_driver_target(policy, policy->max,
-                               CPUFREQ_RELATION_H);
-               } else {
-                       int freq = powersave_bias_target(policy, policy->max,
-                                       CPUFREQ_RELATION_H);
-                       __cpufreq_driver_target(policy, freq,
-                               CPUFREQ_RELATION_L);
-               }
+               dbs_freq_increase(policy, policy->max);
                return;
        }
 
@@ -610,7 +609,9 @@ static void do_dbs_timer(struct work_struct *work)
        /* We want all CPUs to do sampling nearly on same jiffy */
        int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
 
-       delay -= jiffies % delay;
+       if (num_online_cpus() > 1)
+               delay -= jiffies % delay;
+
        mutex_lock(&dbs_info->timer_mutex);
 
        /* Common NORMAL_SAMPLE setup */
@@ -635,7 +636,9 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
 {
        /* We want all CPUs to do sampling nearly on same jiffy */
        int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
-       delay -= jiffies % delay;
+
+       if (num_online_cpus() > 1)
+               delay -= jiffies % delay;
 
        dbs_info->sample_type = DBS_NORMAL_SAMPLE;
        INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);