cpufreq: Use CPUFREQ_RELATION_E in DVFS governors
authorVincent Donnefort <vincent.donnefort@arm.com>
Wed, 8 Sep 2021 14:05:29 +0000 (15:05 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 5 Oct 2021 14:33:05 +0000 (16:33 +0200)
Let the governors schedutil, conservative and ondemand to work, if possible
on efficient frequencies only.

Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c
drivers/cpufreq/cpufreq_conservative.c
drivers/cpufreq/cpufreq_ondemand.c
include/linux/cpufreq.h

index 8069a7bac9efcdf63b24db86282183f7cc05369d..e338d2f010feb2a8978fc3ddfa22970d28aa15e5 100644 (file)
@@ -554,7 +554,7 @@ static unsigned int __resolve_freq(struct cpufreq_policy *policy,
 unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
                                         unsigned int target_freq)
 {
-       return __resolve_freq(policy, target_freq, CPUFREQ_RELATION_L);
+       return __resolve_freq(policy, target_freq, CPUFREQ_RELATION_LE);
 }
 EXPORT_SYMBOL_GPL(cpufreq_driver_resolve_freq);
 
index aa39ff31ec9f76ec0f83b861c55c91af0e105c57..0879ec3c170cae97b6066de4137d0b684f9c27fc 100644 (file)
@@ -111,7 +111,8 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy)
                if (requested_freq > policy->max)
                        requested_freq = policy->max;
 
-               __cpufreq_driver_target(policy, requested_freq, CPUFREQ_RELATION_H);
+               __cpufreq_driver_target(policy, requested_freq,
+                                       CPUFREQ_RELATION_HE);
                dbs_info->requested_freq = requested_freq;
                goto out;
        }
@@ -134,7 +135,8 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy)
                else
                        requested_freq = policy->min;
 
-               __cpufreq_driver_target(policy, requested_freq, CPUFREQ_RELATION_L);
+               __cpufreq_driver_target(policy, requested_freq,
+                                       CPUFREQ_RELATION_LE);
                dbs_info->requested_freq = requested_freq;
        }
 
index f68cad9abd1162d419fcb7eb1f1a2192e0cfa76c..3b8f924771b439740db468f758fd43f00e809078 100644 (file)
@@ -120,12 +120,12 @@ static void dbs_freq_increase(struct cpufreq_policy *policy, unsigned int freq)
 
        if (od_tuners->powersave_bias)
                freq = od_ops.powersave_bias_target(policy, freq,
-                               CPUFREQ_RELATION_H);
+                                                   CPUFREQ_RELATION_HE);
        else if (policy->cur == policy->max)
                return;
 
        __cpufreq_driver_target(policy, freq, od_tuners->powersave_bias ?
-                       CPUFREQ_RELATION_L : CPUFREQ_RELATION_H);
+                       CPUFREQ_RELATION_LE : CPUFREQ_RELATION_HE);
 }
 
 /*
@@ -163,9 +163,9 @@ static void od_update(struct cpufreq_policy *policy)
                if (od_tuners->powersave_bias)
                        freq_next = od_ops.powersave_bias_target(policy,
                                                                 freq_next,
-                                                                CPUFREQ_RELATION_L);
+                                                                CPUFREQ_RELATION_LE);
 
-               __cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_C);
+               __cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_CE);
        }
 }
 
@@ -184,7 +184,7 @@ static unsigned int od_dbs_update(struct cpufreq_policy *policy)
         */
        if (sample_type == OD_SUB_SAMPLE && policy_dbs->sample_delay_ns > 0) {
                __cpufreq_driver_target(policy, dbs_info->freq_lo,
-                                       CPUFREQ_RELATION_H);
+                                       CPUFREQ_RELATION_HE);
                return dbs_info->freq_lo_delay_us;
        }
 
index 6d96bd452d55e2c824e0793db085ef37b3efb2e2..7ce71c7371fb9728fe40082b760d1d669dcae708 100644 (file)
@@ -283,6 +283,10 @@ static inline void cpufreq_stats_record_transition(struct cpufreq_policy *policy
 /* relation flags */
 #define CPUFREQ_RELATION_E BIT(2) /* Get if possible an efficient frequency */
 
+#define CPUFREQ_RELATION_LE (CPUFREQ_RELATION_L | CPUFREQ_RELATION_E)
+#define CPUFREQ_RELATION_HE (CPUFREQ_RELATION_H | CPUFREQ_RELATION_E)
+#define CPUFREQ_RELATION_CE (CPUFREQ_RELATION_C | CPUFREQ_RELATION_E)
+
 struct freq_attr {
        struct attribute attr;
        ssize_t (*show)(struct cpufreq_policy *, char *);
@@ -636,9 +640,11 @@ struct cpufreq_governor *cpufreq_fallback_governor(void);
 static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *policy)
 {
        if (policy->max < policy->cur)
-               __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
+               __cpufreq_driver_target(policy, policy->max,
+                                       CPUFREQ_RELATION_HE);
        else if (policy->min > policy->cur)
-               __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
+               __cpufreq_driver_target(policy, policy->min,
+                                       CPUFREQ_RELATION_LE);
 }
 
 /* Governor attribute set */