5252#define AMD_PSTATE_TRANSITION_LATENCY 20000
5353#define AMD_PSTATE_TRANSITION_DELAY 1000
5454#define AMD_PSTATE_FAST_CPPC_TRANSITION_DELAY 600
55- #define CPPC_HIGHEST_PERF_PERFORMANCE 196
56- #define CPPC_HIGHEST_PERF_DEFAULT 166
5755
5856#define AMD_CPPC_EPP_PERFORMANCE 0x00
5957#define AMD_CPPC_EPP_BALANCE_PERFORMANCE 0x80
@@ -372,43 +370,17 @@ static inline int amd_pstate_enable(bool enable)
372370 return static_call (amd_pstate_enable )(enable );
373371}
374372
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-
390373static int pstate_init_perf (struct amd_cpudata * cpudata )
391374{
392375 u64 cap1 ;
393- u32 highest_perf ;
394376
395377 int ret = rdmsrl_safe_on_cpu (cpudata -> cpu , MSR_AMD_CPPC_CAP1 ,
396378 & cap1 );
397379 if (ret )
398380 return ret ;
399381
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 ));
412384 WRITE_ONCE (cpudata -> nominal_perf , AMD_CPPC_NOMINAL_PERF (cap1 ));
413385 WRITE_ONCE (cpudata -> lowest_nonlinear_perf , AMD_CPPC_LOWNONLIN_PERF (cap1 ));
414386 WRITE_ONCE (cpudata -> lowest_perf , AMD_CPPC_LOWEST_PERF (cap1 ));
@@ -420,19 +392,13 @@ static int pstate_init_perf(struct amd_cpudata *cpudata)
420392static int cppc_init_perf (struct amd_cpudata * cpudata )
421393{
422394 struct cppc_perf_caps cppc_perf ;
423- u32 highest_perf ;
424395
425396 int ret = cppc_get_perf_caps (cpudata -> cpu , & cppc_perf );
426397 if (ret )
427398 return ret ;
428399
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 );
436402 WRITE_ONCE (cpudata -> nominal_perf , cppc_perf .nominal_perf );
437403 WRITE_ONCE (cpudata -> lowest_nonlinear_perf ,
438404 cppc_perf .lowest_nonlinear_perf );
@@ -918,8 +884,8 @@ static u32 amd_pstate_get_transition_latency(unsigned int cpu)
918884static int amd_pstate_init_freq (struct amd_cpudata * cpudata )
919885{
920886 int ret ;
921- u32 min_freq ;
922- u32 highest_perf , max_freq ;
887+ u32 min_freq , max_freq ;
888+ u64 numerator ;
923889 u32 nominal_perf , nominal_freq ;
924890 u32 lowest_nonlinear_perf , lowest_nonlinear_freq ;
925891 u32 boost_ratio , lowest_nonlinear_ratio ;
@@ -941,8 +907,10 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
941907
942908 nominal_perf = READ_ONCE (cpudata -> nominal_perf );
943909
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 );
946914 max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT ) * 1000 ;
947915
948916 lowest_nonlinear_perf = READ_ONCE (cpudata -> lowest_nonlinear_perf );
0 commit comments