Merge branches 'pm-cpuidle' and 'pm-cpufreq'

* pm-cpuidle:
cpuidle: Check for dev before deregistering it.
intel_idle: Fixed C6 state on Avoton/Rangeley processors

* pm-cpufreq:
cpufreq: fix garbage kobjects on errors during suspend/resume
cpufreq: suspend governors on system suspend/hibernate

+57 -6
+3
drivers/base/power/main.c
··· 29 29 #include <linux/async.h> 30 30 #include <linux/suspend.h> 31 31 #include <trace/events/power.h> 32 + #include <linux/cpufreq.h> 32 33 #include <linux/cpuidle.h> 33 34 #include <linux/timer.h> 34 35 ··· 541 540 dpm_show_time(starttime, state, "noirq"); 542 541 resume_device_irqs(); 543 542 cpuidle_resume(); 543 + cpufreq_resume(); 544 544 } 545 545 546 546 /** ··· 957 955 ktime_t starttime = ktime_get(); 958 956 int error = 0; 959 957 958 + cpufreq_suspend(); 960 959 cpuidle_pause(); 961 960 suspend_device_irqs(); 962 961 mutex_lock(&dpm_list_mtx);
+43 -3
drivers/cpufreq/cpufreq.c
··· 26 26 #include <linux/module.h> 27 27 #include <linux/mutex.h> 28 28 #include <linux/slab.h> 29 + #include <linux/suspend.h> 29 30 #include <linux/syscore_ops.h> 30 31 #include <linux/tick.h> 31 32 #include <trace/events/power.h> ··· 47 46 /* This one keeps track of the previously set governor of a removed CPU */ 48 47 static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); 49 48 #endif 49 + 50 + /* Flag to suspend/resume CPUFreq governors */ 51 + static bool cpufreq_suspended; 50 52 51 53 static inline bool has_target(void) 52 54 { ··· 1466 1462 .remove_dev = cpufreq_remove_dev, 1467 1463 }; 1468 1464 1465 + void cpufreq_suspend(void) 1466 + { 1467 + struct cpufreq_policy *policy; 1468 + 1469 + if (!has_target()) 1470 + return; 1471 + 1472 + pr_debug("%s: Suspending Governors\n", __func__); 1473 + 1474 + list_for_each_entry(policy, &cpufreq_policy_list, policy_list) 1475 + if (__cpufreq_governor(policy, CPUFREQ_GOV_STOP)) 1476 + pr_err("%s: Failed to stop governor for policy: %p\n", 1477 + __func__, policy); 1478 + 1479 + cpufreq_suspended = true; 1480 + } 1481 + 1482 + void cpufreq_resume(void) 1483 + { 1484 + struct cpufreq_policy *policy; 1485 + 1486 + if (!has_target()) 1487 + return; 1488 + 1489 + pr_debug("%s: Resuming Governors\n", __func__); 1490 + 1491 + cpufreq_suspended = false; 1492 + 1493 + list_for_each_entry(policy, &cpufreq_policy_list, policy_list) 1494 + if (__cpufreq_governor(policy, CPUFREQ_GOV_START) 1495 + || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS)) 1496 + pr_err("%s: Failed to start governor for policy: %p\n", 1497 + __func__, policy); 1498 + } 1499 + 1469 1500 /** 1470 1501 * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. 1471 1502 * ··· 1802 1763 #else 1803 1764 struct cpufreq_governor *gov = NULL; 1804 1765 #endif 1766 + 1767 + /* Don't start any governor operations if we are entering suspend */ 1768 + if (cpufreq_suspended) 1769 + return 0; 1805 1770 1806 1771 if (policy->governor->max_transition_latency && 1807 1772 policy->cpuinfo.transition_latency > ··· 2118 2075 2119 2076 dev = get_cpu_device(cpu); 2120 2077 if (dev) { 2121 - 2122 - if (action & CPU_TASKS_FROZEN) 2123 - frozen = true; 2124 2078 2125 2079 switch (action & ~CPU_TASKS_FROZEN) { 2126 2080 case CPU_ONLINE:
+1 -1
drivers/cpuidle/cpuidle.c
··· 400 400 */ 401 401 void cpuidle_unregister_device(struct cpuidle_device *dev) 402 402 { 403 - if (dev->registered == 0) 403 + if (!dev || dev->registered == 0) 404 404 return; 405 405 406 406 cpuidle_pause_and_lock();
+2 -2
drivers/idle/intel_idle.c
··· 329 329 { 330 330 .enter = NULL } 331 331 }; 332 - static struct cpuidle_state avn_cstates[CPUIDLE_STATE_MAX] = { 332 + static struct cpuidle_state avn_cstates[] __initdata = { 333 333 { 334 334 .name = "C1-AVN", 335 335 .desc = "MWAIT 0x00", ··· 340 340 { 341 341 .name = "C6-AVN", 342 342 .desc = "MWAIT 0x51", 343 - .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 343 + .flags = MWAIT2flg(0x51) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 344 344 .exit_latency = 15, 345 345 .target_residency = 45, 346 346 .enter = &intel_idle },
+8
include/linux/cpufreq.h
··· 280 280 policy->cpuinfo.max_freq); 281 281 } 282 282 283 + #ifdef CONFIG_CPU_FREQ 284 + void cpufreq_suspend(void); 285 + void cpufreq_resume(void); 286 + #else 287 + static inline void cpufreq_suspend(void) {} 288 + static inline void cpufreq_resume(void) {} 289 + #endif 290 + 283 291 /********************************************************************* 284 292 * CPUFREQ NOTIFIER INTERFACE * 285 293 *********************************************************************/