Skip to content

Commit 20582e3

Browse files
committed
Merge tag 'pm+acpi-3.12-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management fixes from "These fix two bugs in the intel_pstate driver, a hibernate bug leading to nasty resume failures sometimes and acpi-cpufreq initialization bug that causes problems to happen during module unload when intel_pstate is in use. Specifics: - Fix for rounding errors in intel_pstate causing CPU utilization to be underestimated from Brennan Shacklett. - intel_pstate fix to always use the correct max pstate value when computing the min pstate from Dirk Brandewie. - Hibernation fix for deadlocking resume in cases when the probing of the device containing the image is deferred from Russ Dill. - acpi-cpufreq fix to prevent the module from staying in memory when the driver cannot be registered and then attempting to unregister things that have never been registered on exit" * tag 'pm+acpi-3.12-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: acpi-cpufreq: Fail initialization if driver cannot be registered PM / hibernate: Move software_resume to late_initcall_sync intel_pstate: Correct calculation of min pstate value intel_pstate: Improve accuracy by not truncating until final result
2 parents d255c59 + 75c0758 commit 20582e3

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

drivers/cpufreq/acpi-cpufreq.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,12 +986,12 @@ static int __init acpi_cpufreq_init(void)
986986
{
987987
int ret;
988988

989+
if (acpi_disabled)
990+
return -ENODEV;
991+
989992
/* don't keep reloading if cpufreq_driver exists */
990993
if (cpufreq_get_current_driver())
991-
return 0;
992-
993-
if (acpi_disabled)
994-
return 0;
994+
return -EEXIST;
995995

996996
pr_debug("acpi_cpufreq_init\n");
997997

drivers/cpufreq/intel_pstate.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static inline int32_t div_fp(int32_t x, int32_t y)
4848
}
4949

5050
struct sample {
51-
int core_pct_busy;
51+
int32_t core_pct_busy;
5252
u64 aperf;
5353
u64 mperf;
5454
int freq;
@@ -68,7 +68,7 @@ struct _pid {
6868
int32_t i_gain;
6969
int32_t d_gain;
7070
int deadband;
71-
int last_err;
71+
int32_t last_err;
7272
};
7373

7474
struct cpudata {
@@ -153,16 +153,15 @@ static inline void pid_d_gain_set(struct _pid *pid, int percent)
153153
pid->d_gain = div_fp(int_tofp(percent), int_tofp(100));
154154
}
155155

156-
static signed int pid_calc(struct _pid *pid, int busy)
156+
static signed int pid_calc(struct _pid *pid, int32_t busy)
157157
{
158-
signed int err, result;
158+
signed int result;
159159
int32_t pterm, dterm, fp_error;
160160
int32_t integral_limit;
161161

162-
err = pid->setpoint - busy;
163-
fp_error = int_tofp(err);
162+
fp_error = int_tofp(pid->setpoint) - busy;
164163

165-
if (abs(err) <= pid->deadband)
164+
if (abs(fp_error) <= int_tofp(pid->deadband))
166165
return 0;
167166

168167
pterm = mul_fp(pid->p_gain, fp_error);
@@ -176,8 +175,8 @@ static signed int pid_calc(struct _pid *pid, int busy)
176175
if (pid->integral < -integral_limit)
177176
pid->integral = -integral_limit;
178177

179-
dterm = mul_fp(pid->d_gain, (err - pid->last_err));
180-
pid->last_err = err;
178+
dterm = mul_fp(pid->d_gain, fp_error - pid->last_err);
179+
pid->last_err = fp_error;
181180

182181
result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm;
183182

@@ -367,12 +366,13 @@ static int intel_pstate_turbo_pstate(void)
367366
static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
368367
{
369368
int max_perf = cpu->pstate.turbo_pstate;
369+
int max_perf_adj;
370370
int min_perf;
371371
if (limits.no_turbo)
372372
max_perf = cpu->pstate.max_pstate;
373373

374-
max_perf = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf));
375-
*max = clamp_t(int, max_perf,
374+
max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf));
375+
*max = clamp_t(int, max_perf_adj,
376376
cpu->pstate.min_pstate, cpu->pstate.turbo_pstate);
377377

378378
min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits.min_perf));
@@ -436,8 +436,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu,
436436
struct sample *sample)
437437
{
438438
u64 core_pct;
439-
core_pct = div64_u64(sample->aperf * 100, sample->mperf);
440-
sample->freq = cpu->pstate.max_pstate * core_pct * 1000;
439+
core_pct = div64_u64(int_tofp(sample->aperf * 100),
440+
sample->mperf);
441+
sample->freq = fp_toint(cpu->pstate.max_pstate * core_pct * 1000);
441442

442443
sample->core_pct_busy = core_pct;
443444
}
@@ -469,22 +470,19 @@ static inline void intel_pstate_set_sample_time(struct cpudata *cpu)
469470
mod_timer_pinned(&cpu->timer, jiffies + delay);
470471
}
471472

472-
static inline int intel_pstate_get_scaled_busy(struct cpudata *cpu)
473+
static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
473474
{
474-
int32_t busy_scaled;
475475
int32_t core_busy, max_pstate, current_pstate;
476476

477-
core_busy = int_tofp(cpu->samples[cpu->sample_ptr].core_pct_busy);
477+
core_busy = cpu->samples[cpu->sample_ptr].core_pct_busy;
478478
max_pstate = int_tofp(cpu->pstate.max_pstate);
479479
current_pstate = int_tofp(cpu->pstate.current_pstate);
480-
busy_scaled = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
481-
482-
return fp_toint(busy_scaled);
480+
return mul_fp(core_busy, div_fp(max_pstate, current_pstate));
483481
}
484482

485483
static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
486484
{
487-
int busy_scaled;
485+
int32_t busy_scaled;
488486
struct _pid *pid;
489487
signed int ctl = 0;
490488
int steps;

kernel/power/hibernate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ static int software_resume(void)
846846
goto Finish;
847847
}
848848

849-
late_initcall(software_resume);
849+
late_initcall_sync(software_resume);
850850

851851

852852
static const char * const hibernation_modes[] = {

0 commit comments

Comments
 (0)