diff mbox series

cpufreq/amd-pstate: Move max_perf limiting in amd_pstate_update

Message ID 20250415082308.3341-1-dhananjay.ugwekar@amd.com (mailing list archive)
State New
Delegated to: Mario Limonciello
Headers show
Series cpufreq/amd-pstate: Move max_perf limiting in amd_pstate_update | expand

Commit Message

Dhananjay Ugwekar April 15, 2025, 8:23 a.m. UTC
Move up the max_perf limiting, so that we clamp the des_perf with the
updated max_perf.

Signed-off-by: Dhananjay Ugwekar <dhananjay.ugwekar@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Mario Limonciello April 15, 2025, 8:46 p.m. UTC | #1
On 4/15/2025 3:23 AM, Dhananjay Ugwekar wrote:
> Move up the max_perf limiting, so that we clamp the des_perf with the
> updated max_perf.
> 
> Signed-off-by: Dhananjay Ugwekar <dhananjay.ugwekar@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   drivers/cpufreq/amd-pstate.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index c54c031939c8..c29840ba3b30 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -554,6 +554,10 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u8 min_perf,
>   	if (!policy)
>   		return;
>   
> +	/* limit the max perf when core performance boost feature is disabled */
> +	if (!cpudata->boost_supported)
> +		max_perf = min_t(u8, perf.nominal_perf, max_perf);
> +
>   	des_perf = clamp_t(u8, des_perf, min_perf, max_perf);
>   
>   	policy->cur = perf_to_freq(perf, cpudata->nominal_freq, des_perf);
> @@ -563,10 +567,6 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u8 min_perf,
>   		des_perf = 0;
>   	}
>   
> -	/* limit the max perf when core performance boost feature is disabled */
> -	if (!cpudata->boost_supported)
> -		max_perf = min_t(u8, perf.nominal_perf, max_perf);
> -
>   	if (trace_amd_pstate_perf_enabled() && amd_pstate_sample(cpudata)) {
>   		trace_amd_pstate_perf(min_perf, des_perf, max_perf, cpudata->freq,
>   			cpudata->cur.mperf, cpudata->cur.aperf, cpudata->cur.tsc,
diff mbox series

Patch

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index c54c031939c8..c29840ba3b30 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -554,6 +554,10 @@  static void amd_pstate_update(struct amd_cpudata *cpudata, u8 min_perf,
 	if (!policy)
 		return;
 
+	/* limit the max perf when core performance boost feature is disabled */
+	if (!cpudata->boost_supported)
+		max_perf = min_t(u8, perf.nominal_perf, max_perf);
+
 	des_perf = clamp_t(u8, des_perf, min_perf, max_perf);
 
 	policy->cur = perf_to_freq(perf, cpudata->nominal_freq, des_perf);
@@ -563,10 +567,6 @@  static void amd_pstate_update(struct amd_cpudata *cpudata, u8 min_perf,
 		des_perf = 0;
 	}
 
-	/* limit the max perf when core performance boost feature is disabled */
-	if (!cpudata->boost_supported)
-		max_perf = min_t(u8, perf.nominal_perf, max_perf);
-
 	if (trace_amd_pstate_perf_enabled() && amd_pstate_sample(cpudata)) {
 		trace_amd_pstate_perf(min_perf, des_perf, max_perf, cpudata->freq,
 			cpudata->cur.mperf, cpudata->cur.aperf, cpudata->cur.tsc,