Re: [PATCH] cpufreq: amd_freq_sensitivity: Fix sensitivity clamping in amd_powersave_bias_target
From: David Laight
Date: Tue Dec 02 2025 - 14:09:20 EST
On Tue, 2 Dec 2025 13:44:28 +0100
Thorsten Blum <thorsten.blum@xxxxxxxxx> wrote:
> The local variable 'sensitivity' was never clamped to 0 or
> POWERSAVE_BIAS_MAX because the return value of clamp() was not used. Fix
> this by assigning the clamped value back to 'sensitivity'.
This actually makes no difference
(assuming od_tuners->powersave_bias <= POWERSAVE_BIAS_MAX).
The only use of 'sensitivity' is the test at the end of the diff.
So I think you could just delete the line.
David
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 9c5320c8ea8b ("cpufreq: AMD "frequency sensitivity feedback" powersave bias for ondemand governor")
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
> ---
> drivers/cpufreq/amd_freq_sensitivity.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd_freq_sensitivity.c b/drivers/cpufreq/amd_freq_sensitivity.c
> index 13fed4b9e02b..713ccf24c97d 100644
> --- a/drivers/cpufreq/amd_freq_sensitivity.c
> +++ b/drivers/cpufreq/amd_freq_sensitivity.c
> @@ -76,7 +76,7 @@ static unsigned int amd_powersave_bias_target(struct cpufreq_policy *policy,
> sensitivity = POWERSAVE_BIAS_MAX -
> (POWERSAVE_BIAS_MAX * (d_reference - d_actual) / d_reference);
>
> - clamp(sensitivity, 0, POWERSAVE_BIAS_MAX);
> + sensitivity = clamp(sensitivity, 0, POWERSAVE_BIAS_MAX);
>
> /* this workload is not CPU bound, so choose a lower freq */
> if (sensitivity < od_tuners->powersave_bias) {