]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/cpufreq/intel_pstate.c
Merge branch 'stable-4.13' of git://git.infradead.org/users/pcmoore/audit
[karo-tx-linux.git] / drivers / cpufreq / intel_pstate.c
index be0290a1a5e2b59eed7f203b465b1a84a85567ab..48a98f11a84ee79b9ccabcff6c6865a0c51a6e26 100644 (file)
@@ -651,6 +651,12 @@ static const char * const energy_perf_strings[] = {
        "power",
        NULL
 };
+static const unsigned int epp_values[] = {
+       HWP_EPP_PERFORMANCE,
+       HWP_EPP_BALANCE_PERFORMANCE,
+       HWP_EPP_BALANCE_POWERSAVE,
+       HWP_EPP_POWERSAVE
+};
 
 static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data)
 {
@@ -662,17 +668,14 @@ static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data)
                return epp;
 
        if (static_cpu_has(X86_FEATURE_HWP_EPP)) {
-               /*
-                * Range:
-                *      0x00-0x3F       :       Performance
-                *      0x40-0x7F       :       Balance performance
-                *      0x80-0xBF       :       Balance power
-                *      0xC0-0xFF       :       Power
-                * The EPP is a 8 bit value, but our ranges restrict the
-                * value which can be set. Here only using top two bits
-                * effectively.
-                */
-               index = (epp >> 6) + 1;
+               if (epp == HWP_EPP_PERFORMANCE)
+                       return 1;
+               if (epp <= HWP_EPP_BALANCE_PERFORMANCE)
+                       return 2;
+               if (epp <= HWP_EPP_BALANCE_POWERSAVE)
+                       return 3;
+               else
+                       return 4;
        } else if (static_cpu_has(X86_FEATURE_EPB)) {
                /*
                 * Range:
@@ -710,15 +713,8 @@ static int intel_pstate_set_energy_pref_index(struct cpudata *cpu_data,
 
                value &= ~GENMASK_ULL(31, 24);
 
-               /*
-                * If epp is not default, convert from index into
-                * energy_perf_strings to epp value, by shifting 6
-                * bits left to use only top two bits in epp.
-                * The resultant epp need to shifted by 24 bits to
-                * epp position in MSR_HWP_REQUEST.
-                */
                if (epp == -EINVAL)
-                       epp = (pref_index - 1) << 6;
+                       epp = epp_values[pref_index - 1];
 
                value |= (u64)epp << 24;
                ret = wrmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, value);
@@ -1620,9 +1616,6 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu)
        int32_t busy_frac, boost;
        int target, avg_pstate;
 
-       if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE)
-               return cpu->pstate.turbo_pstate;
-
        busy_frac = div_fp(sample->mperf, sample->tsc);
 
        boost = cpu->iowait_boost;
@@ -1659,9 +1652,6 @@ static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu)
        int32_t perf_scaled, max_pstate, current_pstate, sample_ratio;
        u64 duration_ns;
 
-       if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE)
-               return cpu->pstate.turbo_pstate;
-
        /*
         * perf_scaled is the ratio of the average P-state during the last
         * sampling period to the P-state requested last time (in percent).
@@ -1736,16 +1726,6 @@ static void intel_pstate_adjust_pstate(struct cpudata *cpu, int target_pstate)
                fp_toint(cpu->iowait_boost * 100));
 }
 
-static void intel_pstate_update_util_hwp(struct update_util_data *data,
-                                        u64 time, unsigned int flags)
-{
-       struct cpudata *cpu = container_of(data, struct cpudata, update_util);
-       u64 delta_ns = time - cpu->sample.time;
-
-       if ((s64)delta_ns >= INTEL_PSTATE_HWP_SAMPLING_INTERVAL)
-               intel_pstate_sample(cpu, time);
-}
-
 static void intel_pstate_update_util_pid(struct update_util_data *data,
                                         u64 time, unsigned int flags)
 {
@@ -1937,6 +1917,9 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num)
 {
        struct cpudata *cpu = all_cpu_data[cpu_num];
 
+       if (hwp_active)
+               return;
+
        if (cpu->update_util_set)
                return;
 
@@ -2051,10 +2034,10 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
                 */
                intel_pstate_clear_update_util_hook(policy->cpu);
                intel_pstate_max_within_limits(cpu);
+       } else {
+               intel_pstate_set_update_util_hook(policy->cpu);
        }
 
-       intel_pstate_set_update_util_hook(policy->cpu);
-
        if (hwp_active)
                intel_pstate_hwp_set(policy->cpu);
 
@@ -2570,7 +2553,6 @@ static int __init intel_pstate_init(void)
                } else {
                        hwp_active++;
                        intel_pstate.attr = hwp_cpufreq_attrs;
-                       pstate_funcs.update_util = intel_pstate_update_util_hwp;
                        goto hwp_cpu_matched;
                }
        } else {