52
52
#define AMD_PSTATE_TRANSITION_LATENCY 20000
53
53
#define AMD_PSTATE_TRANSITION_DELAY 1000
54
54
#define AMD_PSTATE_FAST_CPPC_TRANSITION_DELAY 600
55
- #define CPPC_HIGHEST_PERF_PERFORMANCE 196
56
- #define CPPC_HIGHEST_PERF_DEFAULT 166
57
55
58
56
#define AMD_CPPC_EPP_PERFORMANCE 0x00
59
57
#define AMD_CPPC_EPP_BALANCE_PERFORMANCE 0x80
@@ -372,43 +370,17 @@ static inline int amd_pstate_enable(bool enable)
372
370
return static_call (amd_pstate_enable )(enable );
373
371
}
374
372
375
- static u32 amd_pstate_highest_perf_set (struct amd_cpudata * cpudata )
376
- {
377
- struct cpuinfo_x86 * c = & cpu_data (0 );
378
-
379
- /*
380
- * For AMD CPUs with Family ID 19H and Model ID range 0x70 to 0x7f,
381
- * the highest performance level is set to 196.
382
- * https://bugzilla.kernel.org/show_bug.cgi?id=218759
383
- */
384
- if (c -> x86 == 0x19 && (c -> x86_model >= 0x70 && c -> x86_model <= 0x7f ))
385
- return CPPC_HIGHEST_PERF_PERFORMANCE ;
386
-
387
- return CPPC_HIGHEST_PERF_DEFAULT ;
388
- }
389
-
390
373
static int pstate_init_perf (struct amd_cpudata * cpudata )
391
374
{
392
375
u64 cap1 ;
393
- u32 highest_perf ;
394
376
395
377
int ret = rdmsrl_safe_on_cpu (cpudata -> cpu , MSR_AMD_CPPC_CAP1 ,
396
378
& cap1 );
397
379
if (ret )
398
380
return ret ;
399
381
400
- /* For platforms that do not support the preferred core feature, the
401
- * highest_pef may be configured with 166 or 255, to avoid max frequency
402
- * calculated wrongly. we take the AMD_CPPC_HIGHEST_PERF(cap1) value as
403
- * the default max perf.
404
- */
405
- if (cpudata -> hw_prefcore )
406
- highest_perf = amd_pstate_highest_perf_set (cpudata );
407
- else
408
- highest_perf = AMD_CPPC_HIGHEST_PERF (cap1 );
409
-
410
- WRITE_ONCE (cpudata -> highest_perf , highest_perf );
411
- WRITE_ONCE (cpudata -> max_limit_perf , highest_perf );
382
+ WRITE_ONCE (cpudata -> highest_perf , AMD_CPPC_HIGHEST_PERF (cap1 ));
383
+ WRITE_ONCE (cpudata -> max_limit_perf , AMD_CPPC_HIGHEST_PERF (cap1 ));
412
384
WRITE_ONCE (cpudata -> nominal_perf , AMD_CPPC_NOMINAL_PERF (cap1 ));
413
385
WRITE_ONCE (cpudata -> lowest_nonlinear_perf , AMD_CPPC_LOWNONLIN_PERF (cap1 ));
414
386
WRITE_ONCE (cpudata -> lowest_perf , AMD_CPPC_LOWEST_PERF (cap1 ));
@@ -420,19 +392,13 @@ static int pstate_init_perf(struct amd_cpudata *cpudata)
420
392
static int cppc_init_perf (struct amd_cpudata * cpudata )
421
393
{
422
394
struct cppc_perf_caps cppc_perf ;
423
- u32 highest_perf ;
424
395
425
396
int ret = cppc_get_perf_caps (cpudata -> cpu , & cppc_perf );
426
397
if (ret )
427
398
return ret ;
428
399
429
- if (cpudata -> hw_prefcore )
430
- highest_perf = amd_pstate_highest_perf_set (cpudata );
431
- else
432
- highest_perf = cppc_perf .highest_perf ;
433
-
434
- WRITE_ONCE (cpudata -> highest_perf , highest_perf );
435
- WRITE_ONCE (cpudata -> max_limit_perf , highest_perf );
400
+ WRITE_ONCE (cpudata -> highest_perf , cppc_perf .highest_perf );
401
+ WRITE_ONCE (cpudata -> max_limit_perf , cppc_perf .highest_perf );
436
402
WRITE_ONCE (cpudata -> nominal_perf , cppc_perf .nominal_perf );
437
403
WRITE_ONCE (cpudata -> lowest_nonlinear_perf ,
438
404
cppc_perf .lowest_nonlinear_perf );
@@ -918,8 +884,8 @@ static u32 amd_pstate_get_transition_latency(unsigned int cpu)
918
884
static int amd_pstate_init_freq (struct amd_cpudata * cpudata )
919
885
{
920
886
int ret ;
921
- u32 min_freq ;
922
- u32 highest_perf , max_freq ;
887
+ u32 min_freq , max_freq ;
888
+ u64 numerator ;
923
889
u32 nominal_perf , nominal_freq ;
924
890
u32 lowest_nonlinear_perf , lowest_nonlinear_freq ;
925
891
u32 boost_ratio , lowest_nonlinear_ratio ;
@@ -941,8 +907,10 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
941
907
942
908
nominal_perf = READ_ONCE (cpudata -> nominal_perf );
943
909
944
- highest_perf = READ_ONCE (cpudata -> highest_perf );
945
- boost_ratio = div_u64 (highest_perf << SCHED_CAPACITY_SHIFT , nominal_perf );
910
+ ret = amd_get_boost_ratio_numerator (cpudata -> cpu , & numerator );
911
+ if (ret )
912
+ return ret ;
913
+ boost_ratio = div_u64 (numerator << SCHED_CAPACITY_SHIFT , nominal_perf );
946
914
max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT ) * 1000 ;
947
915
948
916
lowest_nonlinear_perf = READ_ONCE (cpudata -> lowest_nonlinear_perf );
0 commit comments