@@ -374,15 +374,19 @@ static inline int amd_pstate_cppc_enable(bool enable)
374
374
375
375
static int msr_init_perf (struct amd_cpudata * cpudata )
376
376
{
377
- u64 cap1 ;
377
+ u64 cap1 , numerator ;
378
378
379
379
int ret = rdmsrl_safe_on_cpu (cpudata -> cpu , MSR_AMD_CPPC_CAP1 ,
380
380
& cap1 );
381
381
if (ret )
382
382
return ret ;
383
383
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 );
386
390
WRITE_ONCE (cpudata -> nominal_perf , AMD_CPPC_NOMINAL_PERF (cap1 ));
387
391
WRITE_ONCE (cpudata -> lowest_nonlinear_perf , AMD_CPPC_LOWNONLIN_PERF (cap1 ));
388
392
WRITE_ONCE (cpudata -> lowest_perf , AMD_CPPC_LOWEST_PERF (cap1 ));
@@ -394,13 +398,18 @@ static int msr_init_perf(struct amd_cpudata *cpudata)
394
398
static int shmem_init_perf (struct amd_cpudata * cpudata )
395
399
{
396
400
struct cppc_perf_caps cppc_perf ;
401
+ u64 numerator ;
397
402
398
403
int ret = cppc_get_perf_caps (cpudata -> cpu , & cppc_perf );
399
404
if (ret )
400
405
return ret ;
401
406
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 );
404
413
WRITE_ONCE (cpudata -> nominal_perf , cppc_perf .nominal_perf );
405
414
WRITE_ONCE (cpudata -> lowest_nonlinear_perf ,
406
415
cppc_perf .lowest_nonlinear_perf );
@@ -561,16 +570,13 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy_data)
561
570
562
571
static int amd_pstate_update_min_max_limit (struct cpufreq_policy * policy )
563
572
{
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 ;
565
574
struct amd_cpudata * cpudata = policy -> driver_data ;
566
575
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 );
574
580
575
581
lowest_perf = READ_ONCE (cpudata -> lowest_perf );
576
582
if (min_limit_perf < lowest_perf )
@@ -889,7 +895,6 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
889
895
{
890
896
int ret ;
891
897
u32 min_freq , max_freq ;
892
- u64 numerator ;
893
898
u32 nominal_perf , nominal_freq ;
894
899
u32 lowest_nonlinear_perf , lowest_nonlinear_freq ;
895
900
u32 boost_ratio , lowest_nonlinear_ratio ;
@@ -911,10 +916,7 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
911
916
912
917
nominal_perf = READ_ONCE (cpudata -> nominal_perf );
913
918
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 );
918
920
max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT ) * 1000 ;
919
921
920
922
lowest_nonlinear_perf = READ_ONCE (cpudata -> lowest_nonlinear_perf );
@@ -1869,18 +1871,18 @@ static int __init amd_pstate_init(void)
1869
1871
static_call_update (amd_pstate_update_perf , shmem_update_perf );
1870
1872
}
1871
1873
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
-
1878
1874
if (amd_pstate_prefcore ) {
1879
1875
ret = amd_detect_prefcore (& amd_pstate_prefcore );
1880
1876
if (ret )
1881
1877
return ret ;
1882
1878
}
1883
1879
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
+
1884
1886
dev_root = bus_get_dev_root (& cpu_subsys );
1885
1887
if (dev_root ) {
1886
1888
ret = sysfs_create_group (& dev_root -> kobj , & amd_pstate_global_attr_group );
0 commit comments