@@ -315,6 +315,7 @@ static int pstate_init_perf(struct amd_cpudata *cpudata)
315
315
WRITE_ONCE (cpudata -> nominal_perf , AMD_CPPC_NOMINAL_PERF (cap1 ));
316
316
WRITE_ONCE (cpudata -> lowest_nonlinear_perf , AMD_CPPC_LOWNONLIN_PERF (cap1 ));
317
317
WRITE_ONCE (cpudata -> lowest_perf , AMD_CPPC_LOWEST_PERF (cap1 ));
318
+ WRITE_ONCE (cpudata -> prefcore_ranking , AMD_CPPC_HIGHEST_PERF (cap1 ));
318
319
WRITE_ONCE (cpudata -> min_limit_perf , AMD_CPPC_LOWEST_PERF (cap1 ));
319
320
return 0 ;
320
321
}
@@ -339,6 +340,7 @@ static int cppc_init_perf(struct amd_cpudata *cpudata)
339
340
WRITE_ONCE (cpudata -> lowest_nonlinear_perf ,
340
341
cppc_perf .lowest_nonlinear_perf );
341
342
WRITE_ONCE (cpudata -> lowest_perf , cppc_perf .lowest_perf );
343
+ WRITE_ONCE (cpudata -> prefcore_ranking , cppc_perf .highest_perf );
342
344
WRITE_ONCE (cpudata -> min_limit_perf , cppc_perf .lowest_perf );
343
345
344
346
if (cppc_state == AMD_PSTATE_ACTIVE )
@@ -785,6 +787,40 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata)
785
787
schedule_work (& sched_prefcore_work );
786
788
}
787
789
790
+ static void amd_pstate_update_limits (unsigned int cpu )
791
+ {
792
+ struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
793
+ struct amd_cpudata * cpudata = policy -> driver_data ;
794
+ u32 prev_high = 0 , cur_high = 0 ;
795
+ int ret ;
796
+ bool highest_perf_changed = false;
797
+
798
+ mutex_lock (& amd_pstate_driver_lock );
799
+ if ((!amd_pstate_prefcore ) || (!cpudata -> hw_prefcore ))
800
+ goto free_cpufreq_put ;
801
+
802
+ ret = amd_pstate_get_highest_perf (cpu , & cur_high );
803
+ if (ret )
804
+ goto free_cpufreq_put ;
805
+
806
+ prev_high = READ_ONCE (cpudata -> prefcore_ranking );
807
+ if (prev_high != cur_high ) {
808
+ highest_perf_changed = true;
809
+ WRITE_ONCE (cpudata -> prefcore_ranking , cur_high );
810
+
811
+ if (cur_high < CPPC_MAX_PERF )
812
+ sched_set_itmt_core_prio ((int )cur_high , cpu );
813
+ }
814
+
815
+ free_cpufreq_put :
816
+ cpufreq_cpu_put (policy );
817
+
818
+ if (!highest_perf_changed )
819
+ cpufreq_update_policy (cpu );
820
+
821
+ mutex_unlock (& amd_pstate_driver_lock );
822
+ }
823
+
788
824
static int amd_pstate_cpu_init (struct cpufreq_policy * policy )
789
825
{
790
826
int min_freq , max_freq , nominal_freq , lowest_nonlinear_freq , ret ;
@@ -958,6 +994,17 @@ static ssize_t show_amd_pstate_highest_perf(struct cpufreq_policy *policy,
958
994
return sysfs_emit (buf , "%u\n" , perf );
959
995
}
960
996
997
+ static ssize_t show_amd_pstate_prefcore_ranking (struct cpufreq_policy * policy ,
998
+ char * buf )
999
+ {
1000
+ u32 perf ;
1001
+ struct amd_cpudata * cpudata = policy -> driver_data ;
1002
+
1003
+ perf = READ_ONCE (cpudata -> prefcore_ranking );
1004
+
1005
+ return sysfs_emit (buf , "%u\n" , perf );
1006
+ }
1007
+
961
1008
static ssize_t show_amd_pstate_hw_prefcore (struct cpufreq_policy * policy ,
962
1009
char * buf )
963
1010
{
@@ -1176,6 +1223,7 @@ cpufreq_freq_attr_ro(amd_pstate_max_freq);
1176
1223
cpufreq_freq_attr_ro (amd_pstate_lowest_nonlinear_freq );
1177
1224
1178
1225
cpufreq_freq_attr_ro (amd_pstate_highest_perf );
1226
+ cpufreq_freq_attr_ro (amd_pstate_prefcore_ranking );
1179
1227
cpufreq_freq_attr_ro (amd_pstate_hw_prefcore );
1180
1228
cpufreq_freq_attr_rw (energy_performance_preference );
1181
1229
cpufreq_freq_attr_ro (energy_performance_available_preferences );
@@ -1186,6 +1234,7 @@ static struct freq_attr *amd_pstate_attr[] = {
1186
1234
& amd_pstate_max_freq ,
1187
1235
& amd_pstate_lowest_nonlinear_freq ,
1188
1236
& amd_pstate_highest_perf ,
1237
+ & amd_pstate_prefcore_ranking ,
1189
1238
& amd_pstate_hw_prefcore ,
1190
1239
NULL ,
1191
1240
};
@@ -1194,6 +1243,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = {
1194
1243
& amd_pstate_max_freq ,
1195
1244
& amd_pstate_lowest_nonlinear_freq ,
1196
1245
& amd_pstate_highest_perf ,
1246
+ & amd_pstate_prefcore_ranking ,
1197
1247
& amd_pstate_hw_prefcore ,
1198
1248
& energy_performance_preference ,
1199
1249
& energy_performance_available_preferences ,
@@ -1537,6 +1587,7 @@ static struct cpufreq_driver amd_pstate_driver = {
1537
1587
.suspend = amd_pstate_cpu_suspend ,
1538
1588
.resume = amd_pstate_cpu_resume ,
1539
1589
.set_boost = amd_pstate_set_boost ,
1590
+ .update_limits = amd_pstate_update_limits ,
1540
1591
.name = "amd-pstate" ,
1541
1592
.attr = amd_pstate_attr ,
1542
1593
};
@@ -1551,6 +1602,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = {
1551
1602
.online = amd_pstate_epp_cpu_online ,
1552
1603
.suspend = amd_pstate_epp_suspend ,
1553
1604
.resume = amd_pstate_epp_resume ,
1605
+ .update_limits = amd_pstate_update_limits ,
1554
1606
.name = "amd-pstate-epp" ,
1555
1607
.attr = amd_pstate_epp_attr ,
1556
1608
};
0 commit comments