@@ -374,15 +374,19 @@ static inline int amd_pstate_cppc_enable(bool enable)
374374
375375static int msr_init_perf (struct amd_cpudata * cpudata )
376376{
377- u64 cap1 ;
377+ u64 cap1 , numerator ;
378378
379379 int ret = rdmsrl_safe_on_cpu (cpudata -> cpu , MSR_AMD_CPPC_CAP1 ,
380380 & cap1 );
381381 if (ret )
382382 return ret ;
383383
384- WRITE_ONCE (cpudata -> highest_perf , AMD_CPPC_HIGHEST_PERF (cap1 ));
385- WRITE_ONCE (cpudata -> max_limit_perf , AMD_CPPC_HIGHEST_PERF (cap1 ));
384+ ret = amd_get_boost_ratio_numerator (cpudata -> cpu , & numerator );
385+ if (ret )
386+ return ret ;
387+
388+ WRITE_ONCE (cpudata -> highest_perf , numerator );
389+ WRITE_ONCE (cpudata -> max_limit_perf , numerator );
386390 WRITE_ONCE (cpudata -> nominal_perf , AMD_CPPC_NOMINAL_PERF (cap1 ));
387391 WRITE_ONCE (cpudata -> lowest_nonlinear_perf , AMD_CPPC_LOWNONLIN_PERF (cap1 ));
388392 WRITE_ONCE (cpudata -> lowest_perf , AMD_CPPC_LOWEST_PERF (cap1 ));
@@ -394,13 +398,18 @@ static int msr_init_perf(struct amd_cpudata *cpudata)
394398static int shmem_init_perf (struct amd_cpudata * cpudata )
395399{
396400 struct cppc_perf_caps cppc_perf ;
401+ u64 numerator ;
397402
398403 int ret = cppc_get_perf_caps (cpudata -> cpu , & cppc_perf );
399404 if (ret )
400405 return ret ;
401406
402- WRITE_ONCE (cpudata -> highest_perf , cppc_perf .highest_perf );
403- WRITE_ONCE (cpudata -> max_limit_perf , cppc_perf .highest_perf );
407+ ret = amd_get_boost_ratio_numerator (cpudata -> cpu , & numerator );
408+ if (ret )
409+ return ret ;
410+
411+ WRITE_ONCE (cpudata -> highest_perf , numerator );
412+ WRITE_ONCE (cpudata -> max_limit_perf , numerator );
404413 WRITE_ONCE (cpudata -> nominal_perf , cppc_perf .nominal_perf );
405414 WRITE_ONCE (cpudata -> lowest_nonlinear_perf ,
406415 cppc_perf .lowest_nonlinear_perf );
@@ -561,16 +570,13 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy_data)
561570
562571static int amd_pstate_update_min_max_limit (struct cpufreq_policy * policy )
563572{
564- u32 max_limit_perf , min_limit_perf , lowest_perf , max_perf ;
573+ u32 max_limit_perf , min_limit_perf , lowest_perf , max_perf , max_freq ;
565574 struct amd_cpudata * cpudata = policy -> driver_data ;
566575
567- if (cpudata -> boost_supported && !policy -> boost_enabled )
568- max_perf = READ_ONCE (cpudata -> nominal_perf );
569- else
570- max_perf = READ_ONCE (cpudata -> highest_perf );
571-
572- max_limit_perf = div_u64 (policy -> max * max_perf , policy -> cpuinfo .max_freq );
573- min_limit_perf = div_u64 (policy -> min * max_perf , policy -> cpuinfo .max_freq );
576+ max_perf = READ_ONCE (cpudata -> highest_perf );
577+ max_freq = READ_ONCE (cpudata -> max_freq );
578+ max_limit_perf = div_u64 (policy -> max * max_perf , max_freq );
579+ min_limit_perf = div_u64 (policy -> min * max_perf , max_freq );
574580
575581 lowest_perf = READ_ONCE (cpudata -> lowest_perf );
576582 if (min_limit_perf < lowest_perf )
@@ -889,7 +895,6 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
889895{
890896 int ret ;
891897 u32 min_freq , max_freq ;
892- u64 numerator ;
893898 u32 nominal_perf , nominal_freq ;
894899 u32 lowest_nonlinear_perf , lowest_nonlinear_freq ;
895900 u32 boost_ratio , lowest_nonlinear_ratio ;
@@ -911,10 +916,7 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
911916
912917 nominal_perf = READ_ONCE (cpudata -> nominal_perf );
913918
914- ret = amd_get_boost_ratio_numerator (cpudata -> cpu , & numerator );
915- if (ret )
916- return ret ;
917- boost_ratio = div_u64 (numerator << SCHED_CAPACITY_SHIFT , nominal_perf );
919+ boost_ratio = div_u64 (cpudata -> highest_perf << SCHED_CAPACITY_SHIFT , nominal_perf );
918920 max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT ) * 1000 ;
919921
920922 lowest_nonlinear_perf = READ_ONCE (cpudata -> lowest_nonlinear_perf );
@@ -1869,18 +1871,18 @@ static int __init amd_pstate_init(void)
18691871 static_call_update (amd_pstate_update_perf , shmem_update_perf );
18701872 }
18711873
1872- ret = amd_pstate_register_driver (cppc_state );
1873- if (ret ) {
1874- pr_err ("failed to register with return %d\n" , ret );
1875- return ret ;
1876- }
1877-
18781874 if (amd_pstate_prefcore ) {
18791875 ret = amd_detect_prefcore (& amd_pstate_prefcore );
18801876 if (ret )
18811877 return ret ;
18821878 }
18831879
1880+ ret = amd_pstate_register_driver (cppc_state );
1881+ if (ret ) {
1882+ pr_err ("failed to register with return %d\n" , ret );
1883+ return ret ;
1884+ }
1885+
18841886 dev_root = bus_get_dev_root (& cpu_subsys );
18851887 if (dev_root ) {
18861888 ret = sysfs_create_group (& dev_root -> kobj , & amd_pstate_global_attr_group );
0 commit comments