Commit 78e27086 authored by Stratos Karafotis's avatar Stratos Karafotis Committed by Rafael J. Wysocki

cpufreq: intel_pstate: Remove core_pct rounding

The specific rounding adds conditionally only 1/256 to fractional
part of core_pct.

We can safely remove it without any noticeable impact in
calculations.

Use div64_u64 instead of div_u64 to avoid possible overflow of
sample->mperf as divisor
Signed-off-by: default avatarStratos Karafotis <stratosk@semaphore.gr>
Signed-off-by: default avatarDirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 4b707c89
...@@ -545,13 +545,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu) ...@@ -545,13 +545,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu)
{ {
struct sample *sample = &cpu->sample; struct sample *sample = &cpu->sample;
int64_t core_pct; int64_t core_pct;
int32_t rem;
core_pct = int_tofp(sample->aperf) * int_tofp(100); core_pct = int_tofp(sample->aperf) * int_tofp(100);
core_pct = div_u64_rem(core_pct, int_tofp(sample->mperf), &rem); core_pct = div64_u64(core_pct, int_tofp(sample->mperf));
if ((rem << 1) >= int_tofp(sample->mperf))
core_pct += 1;
sample->freq = fp_toint( sample->freq = fp_toint(
mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct)); mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));
......
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