@@ -1307,6 +1307,7 @@ static inline int32_t get_target_pstate_default(struct cpudata *cpu)
int64_t scaled_gain, unfiltered_target;
int32_t busy_frac;
int pstate;
+ int max_perf, min_perf;
u64 duration_ns;
busy_frac = div_fp(sample->mperf, sample->tsc);
@@ -1399,6 +1400,14 @@ static inline int32_t get_target_pstate_default(struct cpudata *cpu)
cpu->sample.target = div_u64((int_tofp(100) - scaled_gain) *
cpu->sample.target + scaled_gain *
unfiltered_target, int_tofp(100));
+ /*
+ * Clamp the filtered value.
+ */
+ intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
+ if (cpu->sample.target < int_tofp(min_perf))
+ cpu->sample.target = int_tofp(min_perf);
+ if (cpu->sample.target > int_tofp(max_perf))
+ cpu->sample.target = int_tofp(max_perf);
return fp_toint(cpu->sample.target + (1 << (FRAC_BITS-1)));
}