@@ -173,7 +173,6 @@ struct vid_data {
173173 * based on the MSR_IA32_MISC_ENABLE value and whether or
174174 * not the maximum reported turbo P-state is different from
175175 * the maximum reported non-turbo one.
176- * @turbo_disabled_mf: The @turbo_disabled value reflected by cpuinfo.max_freq.
177176 * @min_perf_pct: Minimum capacity limit in percent of the maximum turbo
178177 * P-state capacity.
179178 * @max_perf_pct: Maximum capacity limit in percent of the maximum turbo
@@ -182,7 +181,6 @@ struct vid_data {
182181struct global_params {
183182 bool no_turbo ;
184183 bool turbo_disabled ;
185- bool turbo_disabled_mf ;
186184 int max_perf_pct ;
187185 int min_perf_pct ;
188186};
@@ -594,12 +592,13 @@ static void intel_pstate_hybrid_hwp_adjust(struct cpudata *cpu)
594592 cpu -> pstate .min_pstate = intel_pstate_freq_to_hwp (cpu , freq );
595593}
596594
597- static inline void update_turbo_state (void )
595+ static bool turbo_is_disabled (void )
598596{
599597 u64 misc_en ;
600598
601599 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 );
603602}
604603
605604static int min_perf_pct_min (void )
@@ -1154,40 +1153,16 @@ static void intel_pstate_update_policies(void)
11541153static void __intel_pstate_update_max_freq (struct cpudata * cpudata ,
11551154 struct cpufreq_policy * policy )
11561155{
1157- policy -> cpuinfo .max_freq = global .turbo_disabled_mf ?
1156+ policy -> cpuinfo .max_freq = global .turbo_disabled ?
11581157 cpudata -> pstate .max_freq : cpudata -> pstate .turbo_freq ;
11591158 refresh_frequency_limits (policy );
11601159}
11611160
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-
11741161static void intel_pstate_update_limits (unsigned int cpu )
11751162{
11761163 mutex_lock (& intel_pstate_driver_lock );
11771164
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 );
11911166
11921167 mutex_unlock (& intel_pstate_driver_lock );
11931168}
@@ -1287,7 +1262,6 @@ static ssize_t show_no_turbo(struct kobject *kobj,
12871262 return - EAGAIN ;
12881263 }
12891264
1290- update_turbo_state ();
12911265 if (global .turbo_disabled )
12921266 ret = sprintf (buf , "%u\n" , global .turbo_disabled );
12931267 else
@@ -1317,7 +1291,6 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
13171291
13181292 mutex_lock (& intel_pstate_limits_lock );
13191293
1320- update_turbo_state ();
13211294 if (global .turbo_disabled ) {
13221295 pr_notice_once ("Turbo disabled by BIOS or unavailable on processor\n" );
13231296 mutex_unlock (& intel_pstate_limits_lock );
@@ -2281,8 +2254,6 @@ static void intel_pstate_adjust_pstate(struct cpudata *cpu)
22812254 struct sample * sample ;
22822255 int target_pstate ;
22832256
2284- update_turbo_state ();
2285-
22862257 target_pstate = get_target_pstate (cpu );
22872258 target_pstate = intel_pstate_prepare_request (cpu , target_pstate );
22882259 trace_cpu_frequency (target_pstate * cpu -> pstate .scaling , cpu -> cpu );
@@ -2593,7 +2564,6 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
25932564 * be invoked on them.
25942565 */
25952566 intel_pstate_clear_update_util_hook (policy -> cpu );
2596- update_turbo_state ();
25972567 intel_pstate_set_pstate (cpu , pstate );
25982568 } else {
25992569 intel_pstate_set_update_util_hook (policy -> cpu );
@@ -2637,7 +2607,6 @@ static void intel_pstate_verify_cpu_policy(struct cpudata *cpu,
26372607{
26382608 int max_freq ;
26392609
2640- update_turbo_state ();
26412610 if (hwp_active ) {
26422611 intel_pstate_get_hwp_cap (cpu );
26432612 max_freq = global .no_turbo || global .turbo_disabled ?
@@ -2734,8 +2703,6 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy)
27342703
27352704 /* cpuinfo and default policy values */
27362705 policy -> cpuinfo .min_freq = cpu -> pstate .min_freq ;
2737- update_turbo_state ();
2738- global .turbo_disabled_mf = global .turbo_disabled ;
27392706 policy -> cpuinfo .max_freq = global .turbo_disabled ?
27402707 cpu -> pstate .max_freq : cpu -> pstate .turbo_freq ;
27412708
@@ -2901,8 +2868,6 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy,
29012868 struct cpufreq_freqs freqs ;
29022869 int target_pstate ;
29032870
2904- update_turbo_state ();
2905-
29062871 freqs .old = policy -> cur ;
29072872 freqs .new = target_freq ;
29082873
@@ -2924,8 +2889,6 @@ static unsigned int intel_cpufreq_fast_switch(struct cpufreq_policy *policy,
29242889 struct cpudata * cpu = all_cpu_data [policy -> cpu ];
29252890 int target_pstate ;
29262891
2927- update_turbo_state ();
2928-
29292892 target_pstate = intel_pstate_freq_to_hwp (cpu , target_freq );
29302893
29312894 target_pstate = intel_cpufreq_update_pstate (policy , target_pstate , true);
@@ -2943,7 +2906,6 @@ static void intel_cpufreq_adjust_perf(unsigned int cpunum,
29432906 int old_pstate = cpu -> pstate .current_pstate ;
29442907 int cap_pstate , min_pstate , max_pstate , target_pstate ;
29452908
2946- update_turbo_state ();
29472909 cap_pstate = global .turbo_disabled ? HWP_GUARANTEED_PERF (hwp_cap ) :
29482910 HWP_HIGHEST_PERF (hwp_cap );
29492911
@@ -3131,6 +3093,9 @@ static int intel_pstate_register_driver(struct cpufreq_driver *driver)
31313093
31323094 memset (& global , 0 , sizeof (global ));
31333095 global .max_perf_pct = 100 ;
3096+ global .turbo_disabled = turbo_is_disabled ();
3097+
3098+ arch_set_max_freq_ratio (global .turbo_disabled );
31343099
31353100 intel_pstate_driver = driver ;
31363101 ret = cpufreq_register_driver (intel_pstate_driver );
0 commit comments