Pull power management fixes from Rafael Wysocki: "Stable-candidate fixes for the intel_pstate driver and the cpuidle core. Specifics: - Fix two intel_pstate initialization issues, one of which was introduced during the 4.4 cycle (Srinivas Pandruvada) - Fix kernel build with CONFIG_UBSAN set and CONFIG_CPU_IDLE unset (Catalin Marinas)" * tag 'pm-4.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpufreq: intel_pstate: Fix ->set_policy() interface for no_turbo cpufreq: intel_pstate: Fix code ordering in intel_pstate_set_policy() cpuidle: Do not access cpuidle_devices when !CONFIG_CPU_IDLE
Unified · Split
| @@ -1460,6 +1460,9 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) · 1459 unmodified lines | ||
| 1460 | 1460 | |
| 1461 | 1461 | intel_pstate_clear_update_util_hook(policy->cpu); |
| 1462 | 1462 | |
| 1463 | + pr_debug("set_policy cpuinfo.max %u policy->max %u\n", | |
| 1464 | + policy->cpuinfo.max_freq, policy->max); | |
| 1465 | + | |
| 1463 | 1466 | cpu = all_cpu_data[0]; |
| 1464 | 1467 | if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate && |
| 1465 | 1468 | policy->max < policy->cpuinfo.max_freq && |
| @@ -1495,13 +1498,13 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) · 29 unmodified lines | ||
| 1495 | 1498 | limits->max_sysfs_pct); |
| 1496 | 1499 | limits->max_perf_pct = max(limits->min_policy_pct, |
| 1497 | 1500 | limits->max_perf_pct); |
| 1498 | − limits->max_perf = round_up(limits->max_perf, FRAC_BITS); | |
| 1499 | 1501 | |
| 1500 | 1502 | /* Make sure min_perf_pct <= max_perf_pct */ |
| 1501 | 1503 | limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct); |
| 1502 | 1504 | |
| 1503 | 1505 | limits->min_perf = div_fp(limits->min_perf_pct, 100); |
| 1504 | 1506 | limits->max_perf = div_fp(limits->max_perf_pct, 100); |
| 1507 | + limits->max_perf = round_up(limits->max_perf, FRAC_BITS); | |
| 1505 | 1508 | |
| 1506 | 1509 | out: |
| 1507 | 1510 | intel_pstate_set_update_util_hook(policy->cpu); |
| @@ -1558,8 +1561,11 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) · 50 unmodified lines | ||
| 1558 | 1561 | |
| 1559 | 1562 | /* cpuinfo and default policy values */ |
| 1560 | 1563 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; |
| 1561 | − policy->cpuinfo.max_freq = | |
| 1562 | − cpu->pstate.turbo_pstate * cpu->pstate.scaling; | |
| 1564 | + update_turbo_state(); | |
| 1565 | + policy->cpuinfo.max_freq = limits->turbo_disabled ? | |
| 1566 | + cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; | |
| 1567 | + policy->cpuinfo.max_freq *= cpu->pstate.scaling; | |
| 1568 | + | |
| 1563 | 1569 | intel_pstate_init_acpi_perf_limits(policy); |
| 1564 | 1570 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 1565 | 1571 | cpumask_set_cpu(policy->cpu, policy->cpus); |
| @@ -152,6 +152,8 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev); · 151 unmodified lines | ||
| 152 | 152 | extern int cpuidle_play_dead(void); |
| 153 | 153 | |
| 154 | 154 | extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev); |
| 155 | +static inline struct cpuidle_device *cpuidle_get_device(void) | |
| 156 | +{return __this_cpu_read(cpuidle_devices); } | |
| 155 | 157 | #else |
| 156 | 158 | static inline void disable_cpuidle(void) { } |
| 157 | 159 | static inline bool cpuidle_not_available(struct cpuidle_driver *drv, |
| @@ -187,6 +189,7 @@ static inline void cpuidle_disable_device(struct cpuidle_device *dev) { } · 29 unmodified lines | ||
| 187 | 189 | static inline int cpuidle_play_dead(void) {return -ENODEV; } |
| 188 | 190 | static inline struct cpuidle_driver *cpuidle_get_cpu_driver( |
| 189 | 191 | struct cpuidle_device *dev) {return NULL; } |
| 192 | +static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; } | |
| 190 | 193 | #endif |
| 191 | 194 | |
| 192 | 195 | #if defined(CONFIG_CPU_IDLE) && defined(CONFIG_SUSPEND) |
| @@ -127,7 +127,7 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev, · 126 unmodified lines | ||
| 127 | 127 | */ |
| 128 | 128 | static void cpuidle_idle_call(void) |
| 129 | 129 | { |
| 130 | − struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); | |
| 130 | + struct cpuidle_device *dev = cpuidle_get_device(); | |
| 131 | 131 | struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); |
| 132 | 132 | int next_state, entered_state; |
| 133 | 133 | |