@@ -316,9 +316,10 @@ static int shmem_set_epp(struct amd_cpudata *cpudata, u32 epp)
316
316
return ret ;
317
317
}
318
318
319
- static int amd_pstate_set_energy_pref_index (struct amd_cpudata * cpudata ,
320
- int pref_index )
319
+ static int amd_pstate_set_energy_pref_index (struct cpufreq_policy * policy ,
320
+ int pref_index )
321
321
{
322
+ struct amd_cpudata * cpudata = policy -> driver_data ;
322
323
int epp ;
323
324
324
325
if (!pref_index )
@@ -336,7 +337,7 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
336
337
epp ,
337
338
FIELD_GET (AMD_CPPC_MIN_PERF_MASK , cpudata -> cppc_req_cached ),
338
339
FIELD_GET (AMD_CPPC_MAX_PERF_MASK , cpudata -> cppc_req_cached ),
339
- cpudata -> boost_state );
340
+ policy -> boost_enabled );
340
341
}
341
342
342
343
return amd_pstate_set_epp (cpudata , epp );
@@ -746,7 +747,6 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
746
747
guard (mutex )(& amd_pstate_driver_lock );
747
748
748
749
ret = amd_pstate_cpu_boost_update (policy , state );
749
- WRITE_ONCE (cpudata -> boost_state , !ret ? state : false);
750
750
policy -> boost_enabled = !ret ? state : false;
751
751
refresh_frequency_limits (policy );
752
752
@@ -768,9 +768,6 @@ static int amd_pstate_init_boost_support(struct amd_cpudata *cpudata)
768
768
goto exit_err ;
769
769
}
770
770
771
- /* at least one CPU supports CPB, even if others fail later on to set up */
772
- current_pstate_driver -> boost_enabled = true;
773
-
774
771
ret = rdmsrl_on_cpu (cpudata -> cpu , MSR_K7_HWCR , & boost_val );
775
772
if (ret ) {
776
773
pr_err_once ("failed to read initial CPU boost state!\n" );
@@ -1176,7 +1173,6 @@ static ssize_t show_energy_performance_available_preferences(
1176
1173
static ssize_t store_energy_performance_preference (
1177
1174
struct cpufreq_policy * policy , const char * buf , size_t count )
1178
1175
{
1179
- struct amd_cpudata * cpudata = policy -> driver_data ;
1180
1176
char str_preference [21 ];
1181
1177
ssize_t ret ;
1182
1178
@@ -1190,7 +1186,7 @@ static ssize_t store_energy_performance_preference(
1190
1186
1191
1187
guard (mutex )(& amd_pstate_limits_lock );
1192
1188
1193
- ret = amd_pstate_set_energy_pref_index (cpudata , ret );
1189
+ ret = amd_pstate_set_energy_pref_index (policy , ret );
1194
1190
1195
1191
return ret ? ret : count ;
1196
1192
}
@@ -1265,6 +1261,9 @@ static int amd_pstate_register_driver(int mode)
1265
1261
return ret ;
1266
1262
}
1267
1263
1264
+ /* at least one CPU supports CPB */
1265
+ current_pstate_driver -> boost_enabled = cpu_feature_enabled (X86_FEATURE_CPB );
1266
+
1268
1267
ret = cpufreq_register_driver (current_pstate_driver );
1269
1268
if (ret ) {
1270
1269
amd_pstate_driver_cleanup ();
@@ -1604,8 +1603,9 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy)
1604
1603
return 0 ;
1605
1604
}
1606
1605
1607
- static int amd_pstate_epp_reenable (struct amd_cpudata * cpudata )
1606
+ static int amd_pstate_epp_reenable (struct cpufreq_policy * policy )
1608
1607
{
1608
+ struct amd_cpudata * cpudata = policy -> driver_data ;
1609
1609
u64 max_perf ;
1610
1610
int ret ;
1611
1611
@@ -1619,7 +1619,7 @@ static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata)
1619
1619
trace_amd_pstate_epp_perf (cpudata -> cpu , cpudata -> highest_perf ,
1620
1620
cpudata -> epp_cached ,
1621
1621
FIELD_GET (AMD_CPPC_MIN_PERF_MASK , cpudata -> cppc_req_cached ),
1622
- max_perf , cpudata -> boost_state );
1622
+ max_perf , policy -> boost_enabled );
1623
1623
}
1624
1624
1625
1625
return amd_pstate_update_perf (cpudata , 0 , 0 , max_perf , cpudata -> epp_cached , false);
@@ -1632,7 +1632,7 @@ static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy)
1632
1632
1633
1633
pr_debug ("AMD CPU Core %d going online\n" , cpudata -> cpu );
1634
1634
1635
- ret = amd_pstate_epp_reenable (cpudata );
1635
+ ret = amd_pstate_epp_reenable (policy );
1636
1636
if (ret )
1637
1637
return ret ;
1638
1638
cpudata -> suspended = false;
@@ -1690,7 +1690,7 @@ static int amd_pstate_epp_resume(struct cpufreq_policy *policy)
1690
1690
guard (mutex )(& amd_pstate_limits_lock );
1691
1691
1692
1692
/* enable amd pstate from suspend state*/
1693
- amd_pstate_epp_reenable (cpudata );
1693
+ amd_pstate_epp_reenable (policy );
1694
1694
1695
1695
cpudata -> suspended = false;
1696
1696
}
0 commit comments