@@ -173,7 +173,6 @@ struct vid_data {
173
173
* based on the MSR_IA32_MISC_ENABLE value and whether or
174
174
* not the maximum reported turbo P-state is different from
175
175
* the maximum reported non-turbo one.
176
- * @turbo_disabled_mf: The @turbo_disabled value reflected by cpuinfo.max_freq.
177
176
* @min_perf_pct: Minimum capacity limit in percent of the maximum turbo
178
177
* P-state capacity.
179
178
* @max_perf_pct: Maximum capacity limit in percent of the maximum turbo
@@ -182,7 +181,6 @@ struct vid_data {
182
181
struct global_params {
183
182
bool no_turbo ;
184
183
bool turbo_disabled ;
185
- bool turbo_disabled_mf ;
186
184
int max_perf_pct ;
187
185
int min_perf_pct ;
188
186
};
@@ -594,12 +592,13 @@ static void intel_pstate_hybrid_hwp_adjust(struct cpudata *cpu)
594
592
cpu -> pstate .min_pstate = intel_pstate_freq_to_hwp (cpu , freq );
595
593
}
596
594
597
- static inline void update_turbo_state (void )
595
+ static bool turbo_is_disabled (void )
598
596
{
599
597
u64 misc_en ;
600
598
601
599
rdmsrl (MSR_IA32_MISC_ENABLE , misc_en );
602
- global .turbo_disabled = misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ;
600
+
601
+ return !!(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE );
603
602
}
604
603
605
604
static int min_perf_pct_min (void )
@@ -1154,40 +1153,16 @@ static void intel_pstate_update_policies(void)
1154
1153
static void __intel_pstate_update_max_freq (struct cpudata * cpudata ,
1155
1154
struct cpufreq_policy * policy )
1156
1155
{
1157
- policy -> cpuinfo .max_freq = global .turbo_disabled_mf ?
1156
+ policy -> cpuinfo .max_freq = global .turbo_disabled ?
1158
1157
cpudata -> pstate .max_freq : cpudata -> pstate .turbo_freq ;
1159
1158
refresh_frequency_limits (policy );
1160
1159
}
1161
1160
1162
- static void intel_pstate_update_max_freq (unsigned int cpu )
1163
- {
1164
- struct cpufreq_policy * policy = cpufreq_cpu_acquire (cpu );
1165
-
1166
- if (!policy )
1167
- return ;
1168
-
1169
- __intel_pstate_update_max_freq (all_cpu_data [cpu ], policy );
1170
-
1171
- cpufreq_cpu_release (policy );
1172
- }
1173
-
1174
1161
static void intel_pstate_update_limits (unsigned int cpu )
1175
1162
{
1176
1163
mutex_lock (& intel_pstate_driver_lock );
1177
1164
1178
- update_turbo_state ();
1179
- /*
1180
- * If turbo has been turned on or off globally, policy limits for
1181
- * all CPUs need to be updated to reflect that.
1182
- */
1183
- if (global .turbo_disabled_mf != global .turbo_disabled ) {
1184
- global .turbo_disabled_mf = global .turbo_disabled ;
1185
- arch_set_max_freq_ratio (global .turbo_disabled );
1186
- for_each_possible_cpu (cpu )
1187
- intel_pstate_update_max_freq (cpu );
1188
- } else {
1189
- cpufreq_update_policy (cpu );
1190
- }
1165
+ cpufreq_update_policy (cpu );
1191
1166
1192
1167
mutex_unlock (& intel_pstate_driver_lock );
1193
1168
}
@@ -1287,7 +1262,6 @@ static ssize_t show_no_turbo(struct kobject *kobj,
1287
1262
return - EAGAIN ;
1288
1263
}
1289
1264
1290
- update_turbo_state ();
1291
1265
if (global .turbo_disabled )
1292
1266
ret = sprintf (buf , "%u\n" , global .turbo_disabled );
1293
1267
else
@@ -1317,7 +1291,6 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
1317
1291
1318
1292
mutex_lock (& intel_pstate_limits_lock );
1319
1293
1320
- update_turbo_state ();
1321
1294
if (global .turbo_disabled ) {
1322
1295
pr_notice_once ("Turbo disabled by BIOS or unavailable on processor\n" );
1323
1296
mutex_unlock (& intel_pstate_limits_lock );
@@ -2281,8 +2254,6 @@ static void intel_pstate_adjust_pstate(struct cpudata *cpu)
2281
2254
struct sample * sample ;
2282
2255
int target_pstate ;
2283
2256
2284
- update_turbo_state ();
2285
-
2286
2257
target_pstate = get_target_pstate (cpu );
2287
2258
target_pstate = intel_pstate_prepare_request (cpu , target_pstate );
2288
2259
trace_cpu_frequency (target_pstate * cpu -> pstate .scaling , cpu -> cpu );
@@ -2593,7 +2564,6 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
2593
2564
* be invoked on them.
2594
2565
*/
2595
2566
intel_pstate_clear_update_util_hook (policy -> cpu );
2596
- update_turbo_state ();
2597
2567
intel_pstate_set_pstate (cpu , pstate );
2598
2568
} else {
2599
2569
intel_pstate_set_update_util_hook (policy -> cpu );
@@ -2637,7 +2607,6 @@ static void intel_pstate_verify_cpu_policy(struct cpudata *cpu,
2637
2607
{
2638
2608
int max_freq ;
2639
2609
2640
- update_turbo_state ();
2641
2610
if (hwp_active ) {
2642
2611
intel_pstate_get_hwp_cap (cpu );
2643
2612
max_freq = global .no_turbo || global .turbo_disabled ?
@@ -2734,8 +2703,6 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy)
2734
2703
2735
2704
/* cpuinfo and default policy values */
2736
2705
policy -> cpuinfo .min_freq = cpu -> pstate .min_freq ;
2737
- update_turbo_state ();
2738
- global .turbo_disabled_mf = global .turbo_disabled ;
2739
2706
policy -> cpuinfo .max_freq = global .turbo_disabled ?
2740
2707
cpu -> pstate .max_freq : cpu -> pstate .turbo_freq ;
2741
2708
@@ -2901,8 +2868,6 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy,
2901
2868
struct cpufreq_freqs freqs ;
2902
2869
int target_pstate ;
2903
2870
2904
- update_turbo_state ();
2905
-
2906
2871
freqs .old = policy -> cur ;
2907
2872
freqs .new = target_freq ;
2908
2873
@@ -2924,8 +2889,6 @@ static unsigned int intel_cpufreq_fast_switch(struct cpufreq_policy *policy,
2924
2889
struct cpudata * cpu = all_cpu_data [policy -> cpu ];
2925
2890
int target_pstate ;
2926
2891
2927
- update_turbo_state ();
2928
-
2929
2892
target_pstate = intel_pstate_freq_to_hwp (cpu , target_freq );
2930
2893
2931
2894
target_pstate = intel_cpufreq_update_pstate (policy , target_pstate , true);
@@ -2943,7 +2906,6 @@ static void intel_cpufreq_adjust_perf(unsigned int cpunum,
2943
2906
int old_pstate = cpu -> pstate .current_pstate ;
2944
2907
int cap_pstate , min_pstate , max_pstate , target_pstate ;
2945
2908
2946
- update_turbo_state ();
2947
2909
cap_pstate = global .turbo_disabled ? HWP_GUARANTEED_PERF (hwp_cap ) :
2948
2910
HWP_HIGHEST_PERF (hwp_cap );
2949
2911
@@ -3131,6 +3093,9 @@ static int intel_pstate_register_driver(struct cpufreq_driver *driver)
3131
3093
3132
3094
memset (& global , 0 , sizeof (global ));
3133
3095
global .max_perf_pct = 100 ;
3096
+ global .turbo_disabled = turbo_is_disabled ();
3097
+
3098
+ arch_set_max_freq_ratio (global .turbo_disabled );
3134
3099
3135
3100
intel_pstate_driver = driver ;
3136
3101
ret = cpufreq_register_driver (intel_pstate_driver );
0 commit comments