@@ -717,7 +717,7 @@ static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on)
717
717
int ret = 0 ;
718
718
719
719
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 ) );
721
721
722
722
if (on )
723
723
policy -> cpuinfo .max_freq = max_freq ;
@@ -917,13 +917,10 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
917
917
nominal_freq *= 1000 ;
918
918
919
919
WRITE_ONCE (cpudata -> nominal_freq , nominal_freq );
920
- WRITE_ONCE (cpudata -> min_freq , min_freq );
921
920
922
921
max_freq = perf_to_freq (cpudata , cpudata -> highest_perf );
923
922
lowest_nonlinear_freq = perf_to_freq (cpudata , cpudata -> lowest_nonlinear_perf );
924
-
925
923
WRITE_ONCE (cpudata -> lowest_nonlinear_freq , lowest_nonlinear_freq );
926
- WRITE_ONCE (cpudata -> max_freq , max_freq );
927
924
928
925
/**
929
926
* 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)
948
945
949
946
static int amd_pstate_cpu_init (struct cpufreq_policy * policy )
950
947
{
951
- int min_freq , max_freq , ret ;
952
- struct device * dev ;
953
948
struct amd_cpudata * cpudata ;
949
+ struct device * dev ;
950
+ int ret ;
954
951
955
952
/*
956
953
* 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)
981
978
if (ret )
982
979
goto free_cpudata1 ;
983
980
984
- min_freq = READ_ONCE (cpudata -> min_freq );
985
- max_freq = READ_ONCE (cpudata -> max_freq );
986
-
987
981
policy -> cpuinfo .transition_latency = amd_pstate_get_transition_latency (policy -> cpu );
988
982
policy -> transition_delay_us = amd_pstate_get_transition_delay_us (policy -> cpu );
989
983
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 );
995
986
996
987
policy -> boost_enabled = READ_ONCE (cpudata -> boost_supported );
997
988
@@ -1015,9 +1006,6 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
1015
1006
goto free_cpudata2 ;
1016
1007
}
1017
1008
1018
- cpudata -> max_limit_freq = max_freq ;
1019
- cpudata -> min_limit_freq = min_freq ;
1020
-
1021
1009
policy -> driver_data = cpudata ;
1022
1010
1023
1011
if (!current_pstate_driver -> adjust_perf )
@@ -1075,14 +1063,10 @@ static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy)
1075
1063
static ssize_t show_amd_pstate_max_freq (struct cpufreq_policy * policy ,
1076
1064
char * buf )
1077
1065
{
1078
- int max_freq ;
1079
1066
struct amd_cpudata * cpudata = policy -> driver_data ;
1080
1067
1081
- max_freq = READ_ONCE (cpudata -> max_freq );
1082
- if (max_freq < 0 )
1083
- return max_freq ;
1084
1068
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 )) );
1086
1070
}
1087
1071
1088
1072
static 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)
1440
1424
1441
1425
static int amd_pstate_epp_cpu_init (struct cpufreq_policy * policy )
1442
1426
{
1443
- int min_freq , max_freq , ret ;
1444
1427
struct amd_cpudata * cpudata ;
1445
1428
struct device * dev ;
1446
1429
u64 value ;
1430
+ int ret ;
1447
1431
1448
1432
/*
1449
1433
* 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)
1474
1458
if (ret )
1475
1459
goto free_cpudata1 ;
1476
1460
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 );
1482
1463
/* It will be updated by governor */
1483
1464
policy -> cur = policy -> cpuinfo .min_freq ;
1484
1465
1485
1466
policy -> driver_data = cpudata ;
1486
1467
1487
- policy -> min = policy -> cpuinfo .min_freq ;
1488
- policy -> max = policy -> cpuinfo .max_freq ;
1489
-
1490
1468
policy -> boost_enabled = READ_ONCE (cpudata -> boost_supported );
1491
1469
1492
1470
/*
@@ -1544,7 +1522,8 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
1544
1522
struct amd_cpudata * cpudata = policy -> driver_data ;
1545
1523
u8 epp ;
1546
1524
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 );
1548
1527
1549
1528
if (cpudata -> policy == CPUFREQ_POLICY_PERFORMANCE )
1550
1529
epp = 0 ;
0 commit comments