@@ -511,6 +511,8 @@ static inline bool amd_pstate_sample(struct amd_cpudata *cpudata)
511511static void amd_pstate_update (struct amd_cpudata * cpudata , u32 min_perf ,
512512 u32 des_perf , u32 max_perf , bool fast_switch , int gov_flags )
513513{
514+ unsigned long max_freq ;
515+ struct cpufreq_policy * policy = cpufreq_cpu_get (cpudata -> cpu );
514516 u64 prev = READ_ONCE (cpudata -> cppc_req_cached );
515517 u64 value = prev ;
516518
@@ -520,6 +522,9 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
520522 cpudata -> max_limit_perf );
521523 des_perf = clamp_t (unsigned long , des_perf , min_perf , max_perf );
522524
525+ max_freq = READ_ONCE (cpudata -> max_limit_freq );
526+ policy -> cur = div_u64 (des_perf * max_freq , max_perf );
527+
523528 if ((cppc_state == AMD_PSTATE_GUIDED ) && (gov_flags & CPUFREQ_GOV_DYNAMIC_SWITCHING )) {
524529 min_perf = des_perf ;
525530 des_perf = 0 ;
@@ -641,18 +646,16 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
641646 unsigned long capacity )
642647{
643648 unsigned long max_perf , min_perf , des_perf ,
644- cap_perf , lowest_nonlinear_perf , max_freq ;
649+ cap_perf , lowest_nonlinear_perf ;
645650 struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
646651 struct amd_cpudata * cpudata = policy -> driver_data ;
647- unsigned int target_freq ;
648652
649653 if (policy -> min != cpudata -> min_limit_freq || policy -> max != cpudata -> max_limit_freq )
650654 amd_pstate_update_min_max_limit (policy );
651655
652656
653657 cap_perf = READ_ONCE (cpudata -> highest_perf );
654658 lowest_nonlinear_perf = READ_ONCE (cpudata -> lowest_nonlinear_perf );
655- max_freq = READ_ONCE (cpudata -> max_freq );
656659
657660 des_perf = cap_perf ;
658661 if (target_perf < capacity )
@@ -670,8 +673,6 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
670673 max_perf = min_perf ;
671674
672675 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 ;
675676
676677 amd_pstate_update (cpudata , min_perf , des_perf , max_perf , true,
677678 policy -> governor -> flags );
@@ -1557,6 +1558,12 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy)
15571558
15581559 amd_pstate_epp_update_limit (policy );
15591560
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+
15601567 return 0 ;
15611568}
15621569
0 commit comments