Commit 51d211e9 authored by Doug Smythies's avatar Doug Smythies Committed by Rafael J. Wysocki

intel_pstate: Correct rounding in busy calculation

There was a mistake in the actual rounding portion this previous patch:
f0fe3cd7 (intel_pstate: Correct rounding in busy calculation) such that
the rounding was asymetric and incorrect.

Severity: Not very serious, but can increase target pstate by one extra value.
For real world work flows the issue should self correct (but I have no proof).
It is the equivalent of different PID gains for positive and negative numbers.

Examples:
 -3.000000 used to round to -4, rounds to -3 with this patch.
 -3.503906 used to round to -5, rounds to -4 with this patch.

Fixes: f0fe3cd7 (intel_pstate: Correct rounding in busy calculation)
Signed-off-by: default avatarDoug Smythies <dsmythies@telus.net>
Cc: 3.14+ <stable@vger.kernel.org> # 3.14+
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 217886d3
...@@ -196,10 +196,7 @@ static signed int pid_calc(struct _pid *pid, int32_t busy) ...@@ -196,10 +196,7 @@ static signed int pid_calc(struct _pid *pid, int32_t busy)
pid->last_err = fp_error; pid->last_err = fp_error;
result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm; result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm;
if (result >= 0) result = result + (1 << (FRAC_BITS-1));
result = result + (1 << (FRAC_BITS-1));
else
result = result - (1 << (FRAC_BITS-1));
return (signed int)fp_toint(result); return (signed int)fp_toint(result);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment