diff mbox

intel_pstate: Correct rounding in busy calculation again

Message ID 1403024179-26280-1-git-send-email-dsmythies@telus.net (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Doug Smythies June 17, 2014, 4:56 p.m. UTC
There was a mistake in the actual rounding portion of the previous patch,
such that the rounding was asymetric and incorrect.
(see also: f0fe3cd7e12d8290c82284b5c8aee723cbd0371a intel_pstate: Correct rounding in busy calculation)

Signed-off-by: Doug Smythies <dsmythies@telus.net>
---
 drivers/cpufreq/intel_pstate.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Rafael J. Wysocki June 17, 2014, 8:14 p.m. UTC | #1
On Tuesday, June 17, 2014 09:56:19 AM Doug Smythies wrote:
> There was a mistake in the actual rounding portion of the previous patch,

Do you mean commit f0fe3cd7e12d here?

> such that the rounding was asymetric and incorrect.
> (see also: f0fe3cd7e12d8290c82284b5c8aee723cbd0371a intel_pstate: Correct rounding in busy calculation)

Please also say something about why it was incorrect in the
changelog, in terms of what undesirable behaviour it would lead to.

> Signed-off-by: Doug Smythies <dsmythies@telus.net>
> ---
>  drivers/cpufreq/intel_pstate.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 4e7f492..924bb2d 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -196,10 +196,7 @@ static signed int pid_calc(struct _pid *pid, int32_t busy)
>  	pid->last_err = fp_error;
>  
>  	result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm;
> -	if (result >= 0)
> -		result = result + (1 << (FRAC_BITS-1));
> -	else
> -		result = result - (1 << (FRAC_BITS-1));
> +	result = result + (1 << (FRAC_BITS-1));
>  	return (signed int)fp_toint(result);
>  }
>  
>
diff mbox

Patch

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 4e7f492..924bb2d 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -196,10 +196,7 @@  static signed int pid_calc(struct _pid *pid, int32_t busy)
 	pid->last_err = fp_error;
 
 	result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm;
-	if (result >= 0)
-		result = result + (1 << (FRAC_BITS-1));
-	else
-		result = result - (1 << (FRAC_BITS-1));
+	result = result + (1 << (FRAC_BITS-1));
 	return (signed int)fp_toint(result);
 }