@@ -511,6 +511,8 @@ static inline bool amd_pstate_sample(struct amd_cpudata *cpudata)
511
511
static void amd_pstate_update (struct amd_cpudata * cpudata , u32 min_perf ,
512
512
u32 des_perf , u32 max_perf , bool fast_switch , int gov_flags )
513
513
{
514
+ unsigned long max_freq ;
515
+ struct cpufreq_policy * policy = cpufreq_cpu_get (cpudata -> cpu );
514
516
u64 prev = READ_ONCE (cpudata -> cppc_req_cached );
515
517
u64 value = prev ;
516
518
@@ -520,6 +522,9 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
520
522
cpudata -> max_limit_perf );
521
523
des_perf = clamp_t (unsigned long , des_perf , min_perf , max_perf );
522
524
525
+ max_freq = READ_ONCE (cpudata -> max_limit_freq );
526
+ policy -> cur = div_u64 (des_perf * max_freq , max_perf );
527
+
523
528
if ((cppc_state == AMD_PSTATE_GUIDED ) && (gov_flags & CPUFREQ_GOV_DYNAMIC_SWITCHING )) {
524
529
min_perf = des_perf ;
525
530
des_perf = 0 ;
@@ -641,18 +646,16 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
641
646
unsigned long capacity )
642
647
{
643
648
unsigned long max_perf , min_perf , des_perf ,
644
- cap_perf , lowest_nonlinear_perf , max_freq ;
649
+ cap_perf , lowest_nonlinear_perf ;
645
650
struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
646
651
struct amd_cpudata * cpudata = policy -> driver_data ;
647
- unsigned int target_freq ;
648
652
649
653
if (policy -> min != cpudata -> min_limit_freq || policy -> max != cpudata -> max_limit_freq )
650
654
amd_pstate_update_min_max_limit (policy );
651
655
652
656
653
657
cap_perf = READ_ONCE (cpudata -> highest_perf );
654
658
lowest_nonlinear_perf = READ_ONCE (cpudata -> lowest_nonlinear_perf );
655
- max_freq = READ_ONCE (cpudata -> max_freq );
656
659
657
660
des_perf = cap_perf ;
658
661
if (target_perf < capacity )
@@ -670,8 +673,6 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
670
673
max_perf = min_perf ;
671
674
672
675
des_perf = clamp_t (unsigned long , des_perf , min_perf , max_perf );
673
- target_freq = div_u64 (des_perf * max_freq , max_perf );
674
- policy -> cur = target_freq ;
675
676
676
677
amd_pstate_update (cpudata , min_perf , des_perf , max_perf , true,
677
678
policy -> governor -> flags );
@@ -1557,6 +1558,12 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy)
1557
1558
1558
1559
amd_pstate_epp_update_limit (policy );
1559
1560
1561
+ /*
1562
+ * policy->cur is never updated with the amd_pstate_epp driver, but it
1563
+ * is used as a stale frequency value. So, keep it within limits.
1564
+ */
1565
+ policy -> cur = policy -> min ;
1566
+
1560
1567
return 0 ;
1561
1568
}
1562
1569
0 commit comments