@@ -717,7 +717,7 @@ static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on)
717717 int ret = 0 ;
718718
719719 nominal_freq = READ_ONCE (cpudata -> nominal_freq );
720- max_freq = READ_ONCE (cpudata -> max_freq );
720+ max_freq = perf_to_freq ( cpudata , READ_ONCE (cpudata -> highest_perf ) );
721721
722722 if (on )
723723 policy -> cpuinfo .max_freq = max_freq ;
@@ -917,13 +917,10 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
917917 nominal_freq *= 1000 ;
918918
919919 WRITE_ONCE (cpudata -> nominal_freq , nominal_freq );
920- WRITE_ONCE (cpudata -> min_freq , min_freq );
921920
922921 max_freq = perf_to_freq (cpudata , cpudata -> highest_perf );
923922 lowest_nonlinear_freq = perf_to_freq (cpudata , cpudata -> lowest_nonlinear_perf );
924-
925923 WRITE_ONCE (cpudata -> lowest_nonlinear_freq , lowest_nonlinear_freq );
926- WRITE_ONCE (cpudata -> max_freq , max_freq );
927924
928925 /**
929926 * Below values need to be initialized correctly, otherwise driver will fail to load
@@ -948,9 +945,9 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
948945
949946static int amd_pstate_cpu_init (struct cpufreq_policy * policy )
950947{
951- int min_freq , max_freq , ret ;
952- struct device * dev ;
953948 struct amd_cpudata * cpudata ;
949+ struct device * dev ;
950+ int ret ;
954951
955952 /*
956953 * Resetting PERF_CTL_MSR will put the CPU in P0 frequency,
@@ -981,17 +978,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
981978 if (ret )
982979 goto free_cpudata1 ;
983980
984- min_freq = READ_ONCE (cpudata -> min_freq );
985- max_freq = READ_ONCE (cpudata -> max_freq );
986-
987981 policy -> cpuinfo .transition_latency = amd_pstate_get_transition_latency (policy -> cpu );
988982 policy -> transition_delay_us = amd_pstate_get_transition_delay_us (policy -> cpu );
989983
990- policy -> min = min_freq ;
991- policy -> max = max_freq ;
992-
993- policy -> cpuinfo .min_freq = min_freq ;
994- policy -> cpuinfo .max_freq = max_freq ;
984+ policy -> cpuinfo .min_freq = policy -> min = perf_to_freq (cpudata , cpudata -> lowest_perf );
985+ policy -> cpuinfo .max_freq = policy -> max = perf_to_freq (cpudata , cpudata -> highest_perf );
995986
996987 policy -> boost_enabled = READ_ONCE (cpudata -> boost_supported );
997988
@@ -1015,9 +1006,6 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
10151006 goto free_cpudata2 ;
10161007 }
10171008
1018- cpudata -> max_limit_freq = max_freq ;
1019- cpudata -> min_limit_freq = min_freq ;
1020-
10211009 policy -> driver_data = cpudata ;
10221010
10231011 if (!current_pstate_driver -> adjust_perf )
@@ -1075,14 +1063,10 @@ static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy)
10751063static ssize_t show_amd_pstate_max_freq (struct cpufreq_policy * policy ,
10761064 char * buf )
10771065{
1078- int max_freq ;
10791066 struct amd_cpudata * cpudata = policy -> driver_data ;
10801067
1081- max_freq = READ_ONCE (cpudata -> max_freq );
1082- if (max_freq < 0 )
1083- return max_freq ;
10841068
1085- return sysfs_emit (buf , "%u\n" , max_freq );
1069+ return sysfs_emit (buf , "%u\n" , perf_to_freq ( cpudata , READ_ONCE ( cpudata -> highest_perf )) );
10861070}
10871071
10881072static ssize_t show_amd_pstate_lowest_nonlinear_freq (struct cpufreq_policy * policy ,
@@ -1440,10 +1424,10 @@ static bool amd_pstate_acpi_pm_profile_undefined(void)
14401424
14411425static int amd_pstate_epp_cpu_init (struct cpufreq_policy * policy )
14421426{
1443- int min_freq , max_freq , ret ;
14441427 struct amd_cpudata * cpudata ;
14451428 struct device * dev ;
14461429 u64 value ;
1430+ int ret ;
14471431
14481432 /*
14491433 * Resetting PERF_CTL_MSR will put the CPU in P0 frequency,
@@ -1474,19 +1458,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
14741458 if (ret )
14751459 goto free_cpudata1 ;
14761460
1477- min_freq = READ_ONCE (cpudata -> min_freq );
1478- max_freq = READ_ONCE (cpudata -> max_freq );
1479-
1480- policy -> cpuinfo .min_freq = min_freq ;
1481- policy -> cpuinfo .max_freq = max_freq ;
1461+ policy -> cpuinfo .min_freq = policy -> min = perf_to_freq (cpudata , cpudata -> lowest_perf );
1462+ policy -> cpuinfo .max_freq = policy -> max = perf_to_freq (cpudata , cpudata -> highest_perf );
14821463 /* It will be updated by governor */
14831464 policy -> cur = policy -> cpuinfo .min_freq ;
14841465
14851466 policy -> driver_data = cpudata ;
14861467
1487- policy -> min = policy -> cpuinfo .min_freq ;
1488- policy -> max = policy -> cpuinfo .max_freq ;
1489-
14901468 policy -> boost_enabled = READ_ONCE (cpudata -> boost_supported );
14911469
14921470 /*
@@ -1544,7 +1522,8 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
15441522 struct amd_cpudata * cpudata = policy -> driver_data ;
15451523 u8 epp ;
15461524
1547- amd_pstate_update_min_max_limit (policy );
1525+ if (policy -> min != cpudata -> min_limit_freq || policy -> max != cpudata -> max_limit_freq )
1526+ amd_pstate_update_min_max_limit (policy );
15481527
15491528 if (cpudata -> policy == CPUFREQ_POLICY_PERFORMANCE )
15501529 epp = 0 ;
0 commit comments