Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pm+acpi-3.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management and ACPI fixes from Rafael Wysocki:

- intel_pstate driver fixes and cleanups from Dirk Brandewie and Wei
Yongjun.

- cpufreq fixes related to ARM big.LITTLE support and the cpufreq-cpu0
driver from Viresh Kumar.

- Assorted cpufreq fixes from Srivatsa S Bhat, Borislav Petkov, Wolfram
Sang, Alexander Shiyan, and Nishanth Menon.

- Assorted ACPI fixes from Catalin Marinas, Lan Tianyu, Alex Hung,
Jan-Simon Möller, and Rafael J Wysocki.

- Fix for a kfree() under spinlock in the PM core from Shuah Khan.

- PM documentation updates from Borislav Petkov and Zhang Rui.

* tag 'pm+acpi-3.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (30 commits)
cpufreq: Preserve sysfs files across suspend/resume
ACPI / scan: Fix memory leak on acpi_scan_init_hotplug() error path
PM / hibernate: Correct documentation
PM / Documentation: remove inaccurate suspend/hibernate transition lantency statement
PM: Documentation update for freeze state
cpufreq / intel_pstate: use vzalloc() instead of vmalloc()/memset(0)
cpufreq, ondemand: Remove leftover debug line
PM: Avoid calling kfree() under spinlock in dev_pm_put_subsys_data()
cpufreq / kirkwood: don't check resource with devm_ioremap_resource
cpufreq / intel_pstate: remove #ifdef MODULE compile fence
cpufreq / intel_pstate: Remove idle mode PID
cpufreq / intel_pstate: fix ffmpeg regression
cpufreq / intel_pstate: use lowest requested max performance
cpufreq / intel_pstate: remove idle time and duration from sample and calculations
cpufreq: Fix incorrect dependecies for ARM SA11xx drivers
cpufreq: ARM big LITTLE: Fix Kconfig entries
cpufreq: cpufreq-cpu0: Free parent node for error cases
cpufreq: cpufreq-cpu0: defer probe when regulator is not ready
cpufreq: Issue CPUFREQ_GOV_POLICY_EXIT notifier before dropping policy refcount
cpufreq: governors: Fix CPUFREQ_GOV_POLICY_{INIT|EXIT} notifiers
...

+189 -194
+8 -7
Documentation/power/devices.txt
··· 268 268 System Power Management Phases 269 269 ------------------------------ 270 270 Suspending or resuming the system is done in several phases. Different phases 271 - are used for standby or memory sleep states ("suspend-to-RAM") and the 271 + are used for freeze, standby, and memory sleep states ("suspend-to-RAM") and the 272 272 hibernation state ("suspend-to-disk"). Each phase involves executing callbacks 273 273 for every device before the next phase begins. Not all busses or classes 274 274 support all these callbacks and not all drivers use all the callbacks. The ··· 309 309 310 310 Entering System Suspend 311 311 ----------------------- 312 - When the system goes into the standby or memory sleep state, the phases are: 312 + When the system goes into the freeze, standby or memory sleep state, 313 + the phases are: 313 314 314 315 prepare, suspend, suspend_late, suspend_noirq. 315 316 ··· 369 368 370 369 Leaving System Suspend 371 370 ---------------------- 372 - When resuming from standby or memory sleep, the phases are: 371 + When resuming from freeze, standby or memory sleep, the phases are: 373 372 374 373 resume_noirq, resume_early, resume, complete. 375 374 ··· 434 433 435 434 Entering Hibernation 436 435 -------------------- 437 - Hibernating the system is more complicated than putting it into the standby or 438 - memory sleep state, because it involves creating and saving a system image. 436 + Hibernating the system is more complicated than putting it into the other 437 + sleep states, because it involves creating and saving a system image. 439 438 Therefore there are more phases for hibernation, with a different set of 440 439 callbacks. These phases always run after tasks have been frozen and memory has 441 440 been freed. ··· 486 485 487 486 At this point the system image is saved, and the devices then need to be 488 487 prepared for the upcoming system shutdown. This is much like suspending them 489 - before putting the system into the standby or memory sleep state, and the phases 490 - are similar. 488 + before putting the system into the freeze, standby or memory sleep state, 489 + and the phases are similar. 491 490 492 491 9. The prepare phase is discussed above. 493 492
+2 -2
Documentation/power/interface.txt
··· 7 7 is mounted at /sys). 8 8 9 9 /sys/power/state controls system power state. Reading from this file 10 - returns what states are supported, which is hard-coded to 'standby' 11 - (Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk' 10 + returns what states are supported, which is hard-coded to 'freeze', 11 + 'standby' (Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk' 12 12 (Suspend-to-Disk). 13 13 14 14 Writing to this file one of those strings causes the system to
+4 -2
Documentation/power/notifiers.txt
··· 15 15 The subsystems or drivers having such needs can register suspend notifiers that 16 16 will be called upon the following events by the PM core: 17 17 18 - PM_HIBERNATION_PREPARE The system is going to hibernate or suspend, tasks will 19 - be frozen immediately. 18 + PM_HIBERNATION_PREPARE The system is going to hibernate, tasks will be frozen 19 + immediately. This is different from PM_SUSPEND_PREPARE 20 + below because here we do additional work between notifiers 21 + and drivers freezing. 20 22 21 23 PM_POST_HIBERNATION The system memory state has been restored from a 22 24 hibernation image or an error occurred during
+17 -13
Documentation/power/states.txt
··· 2 2 System Power Management States 3 3 4 4 5 - The kernel supports three power management states generically, though 6 - each is dependent on platform support code to implement the low-level 7 - details for each state. This file describes each state, what they are 5 + The kernel supports four power management states generically, though 6 + one is generic and the other three are dependent on platform support 7 + code to implement the low-level details for each state. 8 + This file describes each state, what they are 8 9 commonly called, what ACPI state they map to, and what string to write 9 10 to /sys/power/state to enter that state 11 + 12 + state: Freeze / Low-Power Idle 13 + ACPI state: S0 14 + String: "freeze" 15 + 16 + This state is a generic, pure software, light-weight, low-power state. 17 + It allows more energy to be saved relative to idle by freezing user 18 + space and putting all I/O devices into low-power states (possibly 19 + lower-power than available at run time), such that the processors can 20 + spend more time in their idle states. 21 + This state can be used for platforms without Standby/Suspend-to-RAM 22 + support, or it can be used in addition to Suspend-to-RAM (memory sleep) 23 + to provide reduced resume latency. 10 24 11 25 12 26 State: Standby / Power-On Suspend ··· 35 21 We try to put devices in a low-power state equivalent to D1, which 36 22 also offers low power savings, but low resume latency. Not all devices 37 23 support D1, and those that don't are left on. 38 - 39 - A transition from Standby to the On state should take about 1-2 40 - seconds. 41 24 42 25 43 26 State: Suspend-to-RAM ··· 52 41 53 42 For at least ACPI, STR requires some minimal boot-strapping code to 54 43 resume the system from STR. This may be true on other platforms. 55 - 56 - A transition from Suspend-to-RAM to the On state should take about 57 - 3-5 seconds. 58 44 59 45 60 46 State: Suspend-to-disk ··· 82 74 down offers greater savings, and allows this mechanism to work on any 83 75 system. However, entering a real low-power state allows the user to 84 76 trigger wake up events (e.g. pressing a key or opening a laptop lid). 85 - 86 - A transition from Suspend-to-Disk to the On state should take about 30 87 - seconds, though it's typically a bit more with the current 88 - implementation.
+33
drivers/acpi/ac.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/init.h> 30 30 #include <linux/types.h> 31 + #include <linux/dmi.h> 32 + #include <linux/delay.h> 31 33 #ifdef CONFIG_ACPI_PROCFS_POWER 32 34 #include <linux/proc_fs.h> 33 35 #include <linux/seq_file.h> ··· 75 73 static int acpi_ac_resume(struct device *dev); 76 74 #endif 77 75 static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume); 76 + 77 + static int ac_sleep_before_get_state_ms; 78 78 79 79 static struct acpi_driver acpi_ac_driver = { 80 80 .name = "ac", ··· 256 252 case ACPI_AC_NOTIFY_STATUS: 257 253 case ACPI_NOTIFY_BUS_CHECK: 258 254 case ACPI_NOTIFY_DEVICE_CHECK: 255 + /* 256 + * A buggy BIOS may notify AC first and then sleep for 257 + * a specific time before doing actual operations in the 258 + * EC event handler (_Qxx). This will cause the AC state 259 + * reported by the ACPI event to be incorrect, so wait for a 260 + * specific time for the EC event handler to make progress. 261 + */ 262 + if (ac_sleep_before_get_state_ms > 0) 263 + msleep(ac_sleep_before_get_state_ms); 264 + 259 265 acpi_ac_get_state(ac); 260 266 acpi_bus_generate_proc_event(device, event, (u32) ac->state); 261 267 acpi_bus_generate_netlink_event(device->pnp.device_class, ··· 277 263 278 264 return; 279 265 } 266 + 267 + static int thinkpad_e530_quirk(const struct dmi_system_id *d) 268 + { 269 + ac_sleep_before_get_state_ms = 1000; 270 + return 0; 271 + } 272 + 273 + static struct dmi_system_id ac_dmi_table[] = { 274 + { 275 + .callback = thinkpad_e530_quirk, 276 + .ident = "thinkpad e530", 277 + .matches = { 278 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 279 + DMI_MATCH(DMI_PRODUCT_NAME, "32597CG"), 280 + }, 281 + }, 282 + {}, 283 + }; 280 284 281 285 static int acpi_ac_add(struct acpi_device *device) 282 286 { ··· 344 312 kfree(ac); 345 313 } 346 314 315 + dmi_check_system(ac_dmi_table); 347 316 return result; 348 317 } 349 318
+1 -3
drivers/acpi/ec.c
··· 223 223 static int ec_poll(struct acpi_ec *ec) 224 224 { 225 225 unsigned long flags; 226 - int repeat = 2; /* number of command restarts */ 226 + int repeat = 5; /* number of command restarts */ 227 227 while (repeat--) { 228 228 unsigned long delay = jiffies + 229 229 msecs_to_jiffies(ec_delay); ··· 241 241 } 242 242 advance_transaction(ec, acpi_ec_read_status(ec)); 243 243 } while (time_before(jiffies, delay)); 244 - if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) 245 - break; 246 244 pr_debug(PREFIX "controller reset, restart transaction\n"); 247 245 spin_lock_irqsave(&ec->lock, flags); 248 246 start_transaction(ec);
+4 -4
drivers/acpi/processor_driver.c
··· 95 95 }; 96 96 MODULE_DEVICE_TABLE(acpi, processor_device_ids); 97 97 98 - static SIMPLE_DEV_PM_OPS(acpi_processor_pm, 99 - acpi_processor_suspend, acpi_processor_resume); 100 - 101 98 static struct acpi_driver acpi_processor_driver = { 102 99 .name = "processor", 103 100 .class = ACPI_PROCESSOR_CLASS, ··· 104 107 .remove = acpi_processor_remove, 105 108 .notify = acpi_processor_notify, 106 109 }, 107 - .drv.pm = &acpi_processor_pm, 108 110 }; 109 111 110 112 #define INSTALL_NOTIFY_HANDLER 1 ··· 930 934 if (result < 0) 931 935 return result; 932 936 937 + acpi_processor_syscore_init(); 938 + 933 939 acpi_processor_install_hotplug_notify(); 934 940 935 941 acpi_thermal_cpufreq_init(); ··· 953 955 acpi_thermal_cpufreq_exit(); 954 956 955 957 acpi_processor_uninstall_hotplug_notify(); 958 + 959 + acpi_processor_syscore_exit(); 956 960 957 961 acpi_bus_unregister_driver(&acpi_processor_driver); 958 962
+19 -10
drivers/acpi/processor_idle.c
··· 34 34 #include <linux/sched.h> /* need_resched() */ 35 35 #include <linux/clockchips.h> 36 36 #include <linux/cpuidle.h> 37 + #include <linux/syscore_ops.h> 37 38 38 39 /* 39 40 * Include the apic definitions for x86 to have the APIC timer related defines ··· 211 210 212 211 #endif 213 212 213 + #ifdef CONFIG_PM_SLEEP 214 214 static u32 saved_bm_rld; 215 215 216 - static void acpi_idle_bm_rld_save(void) 216 + int acpi_processor_suspend(void) 217 217 { 218 218 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld); 219 + return 0; 219 220 } 220 - static void acpi_idle_bm_rld_restore(void) 221 + 222 + void acpi_processor_resume(void) 221 223 { 222 224 u32 resumed_bm_rld; 223 225 224 226 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); 227 + if (resumed_bm_rld == saved_bm_rld) 228 + return; 225 229 226 - if (resumed_bm_rld != saved_bm_rld) 227 - acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld); 230 + acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld); 228 231 } 229 232 230 - int acpi_processor_suspend(struct device *dev) 233 + static struct syscore_ops acpi_processor_syscore_ops = { 234 + .suspend = acpi_processor_suspend, 235 + .resume = acpi_processor_resume, 236 + }; 237 + 238 + void acpi_processor_syscore_init(void) 231 239 { 232 - acpi_idle_bm_rld_save(); 233 - return 0; 240 + register_syscore_ops(&acpi_processor_syscore_ops); 234 241 } 235 242 236 - int acpi_processor_resume(struct device *dev) 243 + void acpi_processor_syscore_exit(void) 237 244 { 238 - acpi_idle_bm_rld_restore(); 239 - return 0; 245 + unregister_syscore_ops(&acpi_processor_syscore_ops); 240 246 } 247 + #endif /* CONFIG_PM_SLEEP */ 241 248 242 249 #if defined(CONFIG_X86) 243 250 static void tsc_check_state(int state)
+2 -1
drivers/acpi/scan.c
··· 1785 1785 acpi_set_pnp_ids(handle, &pnp, type); 1786 1786 1787 1787 if (!pnp.type.hardware_id) 1788 - return; 1788 + goto out; 1789 1789 1790 1790 /* 1791 1791 * This relies on the fact that acpi_install_notify_handler() will not ··· 1800 1800 } 1801 1801 } 1802 1802 1803 + out: 1803 1804 acpi_free_pnp_ids(&pnp); 1804 1805 } 1805 1806
+8
drivers/acpi/video.c
··· 456 456 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dm4 Notebook PC"), 457 457 }, 458 458 }, 459 + { 460 + .callback = video_ignore_initial_backlight, 461 + .ident = "HP 1000 Notebook PC", 462 + .matches = { 463 + DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 464 + DMI_MATCH(DMI_PRODUCT_NAME, "HP 1000 Notebook PC"), 465 + }, 466 + }, 459 467 {} 460 468 }; 461 469
+6 -6
drivers/base/power/common.c
··· 61 61 int dev_pm_put_subsys_data(struct device *dev) 62 62 { 63 63 struct pm_subsys_data *psd; 64 - int ret = 0; 64 + int ret = 1; 65 65 66 66 spin_lock_irq(&dev->power.lock); 67 67 68 68 psd = dev_to_psd(dev); 69 - if (!psd) { 70 - ret = -EINVAL; 69 + if (!psd) 71 70 goto out; 72 - } 73 71 74 72 if (--psd->refcount == 0) { 75 73 dev->power.subsys_data = NULL; 76 - kfree(psd); 77 - ret = 1; 74 + } else { 75 + psd = NULL; 76 + ret = 0; 78 77 } 79 78 80 79 out: 81 80 spin_unlock_irq(&dev->power.lock); 81 + kfree(psd); 82 82 83 83 return ret; 84 84 }
+1 -1
drivers/cpufreq/Kconfig
··· 47 47 48 48 choice 49 49 prompt "Default CPUFreq governor" 50 - default CPU_FREQ_DEFAULT_GOV_USERSPACE if CPU_FREQ_SA1100 || CPU_FREQ_SA1110 50 + default CPU_FREQ_DEFAULT_GOV_USERSPACE if ARM_SA1100_CPUFREQ || ARM_SA1110_CPUFREQ 51 51 default CPU_FREQ_DEFAULT_GOV_PERFORMANCE 52 52 help 53 53 This option sets which CPUFreq governor shall be loaded at
+8 -7
drivers/cpufreq/Kconfig.arm
··· 3 3 # 4 4 5 5 config ARM_BIG_LITTLE_CPUFREQ 6 - tristate 7 - depends on ARM_CPU_TOPOLOGY 6 + tristate "Generic ARM big LITTLE CPUfreq driver" 7 + depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK 8 + help 9 + This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. 8 10 9 11 config ARM_DT_BL_CPUFREQ 10 - tristate "Generic ARM big LITTLE CPUfreq driver probed via DT" 11 - select ARM_BIG_LITTLE_CPUFREQ 12 - depends on OF && HAVE_CLK 12 + tristate "Generic probing via DT for ARM big LITTLE CPUfreq driver" 13 + depends on ARM_BIG_LITTLE_CPUFREQ && OF 13 14 help 14 - This enables the Generic CPUfreq driver for ARM big.LITTLE platform. 15 - This gets frequency tables from DT. 15 + This enables probing via DT for Generic CPUfreq driver for ARM 16 + big.LITTLE platform. This gets frequency tables from DT. 16 17 17 18 config ARM_EXYNOS_CPUFREQ 18 19 bool "SAMSUNG EXYNOS SoCs"
+1 -6
drivers/cpufreq/arm_big_little.c
··· 40 40 static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS]; 41 41 static atomic_t cluster_usage[MAX_CLUSTERS] = {ATOMIC_INIT(0), ATOMIC_INIT(0)}; 42 42 43 - static int cpu_to_cluster(int cpu) 44 - { 45 - return topology_physical_package_id(cpu); 46 - } 47 - 48 43 static unsigned int bL_cpufreq_get(unsigned int cpu) 49 44 { 50 45 u32 cur_cluster = cpu_to_cluster(cpu); ··· 187 192 188 193 cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); 189 194 190 - dev_info(cpu_dev, "CPU %d initialized\n", policy->cpu); 195 + dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu); 191 196 return 0; 192 197 } 193 198
+5
drivers/cpufreq/arm_big_little.h
··· 34 34 int (*init_opp_table)(struct device *cpu_dev); 35 35 }; 36 36 37 + static inline int cpu_to_cluster(int cpu) 38 + { 39 + return topology_physical_package_id(cpu); 40 + } 41 + 37 42 int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops); 38 43 void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops); 39 44
+5 -4
drivers/cpufreq/arm_big_little_dt.c
··· 66 66 67 67 parent = of_find_node_by_path("/cpus"); 68 68 if (!parent) { 69 - pr_err("failed to find OF /cpus\n"); 70 - return -ENOENT; 69 + pr_info("Failed to find OF /cpus. Use CPUFREQ_ETERNAL transition latency\n"); 70 + return CPUFREQ_ETERNAL; 71 71 } 72 72 73 73 for_each_child_of_node(parent, np) { ··· 78 78 of_node_put(np); 79 79 of_node_put(parent); 80 80 81 - return 0; 81 + return transition_latency; 82 82 } 83 83 84 - return -ENODEV; 84 + pr_info("clock-latency isn't found, use CPUFREQ_ETERNAL transition latency\n"); 85 + return CPUFREQ_ETERNAL; 85 86 } 86 87 87 88 static struct cpufreq_arm_bL_ops dt_bL_ops = {
+20 -7
drivers/cpufreq/cpufreq-cpu0.c
··· 189 189 190 190 if (!np) { 191 191 pr_err("failed to find cpu0 node\n"); 192 - return -ENOENT; 192 + ret = -ENOENT; 193 + goto out_put_parent; 193 194 } 194 195 195 196 cpu_dev = &pdev->dev; 196 197 cpu_dev->of_node = np; 198 + 199 + cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); 200 + if (IS_ERR(cpu_reg)) { 201 + /* 202 + * If cpu0 regulator supply node is present, but regulator is 203 + * not yet registered, we should try defering probe. 204 + */ 205 + if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) { 206 + dev_err(cpu_dev, "cpu0 regulator not ready, retry\n"); 207 + ret = -EPROBE_DEFER; 208 + goto out_put_node; 209 + } 210 + pr_warn("failed to get cpu0 regulator: %ld\n", 211 + PTR_ERR(cpu_reg)); 212 + cpu_reg = NULL; 213 + } 197 214 198 215 cpu_clk = devm_clk_get(cpu_dev, NULL); 199 216 if (IS_ERR(cpu_clk)) { 200 217 ret = PTR_ERR(cpu_clk); 201 218 pr_err("failed to get cpu0 clock: %d\n", ret); 202 219 goto out_put_node; 203 - } 204 - 205 - cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); 206 - if (IS_ERR(cpu_reg)) { 207 - pr_warn("failed to get cpu0 regulator\n"); 208 - cpu_reg = NULL; 209 220 } 210 221 211 222 ret = of_init_opp_table(cpu_dev); ··· 275 264 opp_free_cpufreq_table(cpu_dev, &freq_table); 276 265 out_put_node: 277 266 of_node_put(np); 267 + out_put_parent: 268 + of_node_put(parent); 278 269 return ret; 279 270 } 280 271
+4 -6
drivers/cpufreq/cpufreq.c
··· 1075 1075 __func__, cpu_dev->id, cpu); 1076 1076 } 1077 1077 1078 + if ((cpus == 1) && (cpufreq_driver->target)) 1079 + __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); 1080 + 1078 1081 pr_debug("%s: removing link, cpu: %d\n", __func__, cpu); 1079 1082 cpufreq_cpu_put(data); 1080 1083 1081 1084 /* If cpu is last user of policy, free policy */ 1082 1085 if (cpus == 1) { 1083 - if (cpufreq_driver->target) 1084 - __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); 1085 - 1086 1086 lock_policy_rwsem_read(cpu); 1087 1087 kobj = &data->kobj; 1088 1088 cmp = &data->kobj_unregister; ··· 1832 1832 if (dev) { 1833 1833 switch (action) { 1834 1834 case CPU_ONLINE: 1835 - case CPU_ONLINE_FROZEN: 1836 1835 cpufreq_add_dev(dev, NULL); 1837 1836 break; 1838 1837 case CPU_DOWN_PREPARE: 1839 - case CPU_DOWN_PREPARE_FROZEN: 1838 + case CPU_UP_CANCELED_FROZEN: 1840 1839 __cpufreq_remove_dev(dev, NULL); 1841 1840 break; 1842 1841 case CPU_DOWN_FAILED: 1843 - case CPU_DOWN_FAILED_FROZEN: 1844 1842 cpufreq_add_dev(dev, NULL); 1845 1843 break; 1846 1844 }
+7 -4
drivers/cpufreq/cpufreq_governor.c
··· 255 255 if (have_governor_per_policy()) { 256 256 WARN_ON(dbs_data); 257 257 } else if (dbs_data) { 258 + dbs_data->usage_count++; 258 259 policy->governor_data = dbs_data; 259 260 return 0; 260 261 } ··· 267 266 } 268 267 269 268 dbs_data->cdata = cdata; 269 + dbs_data->usage_count = 1; 270 270 rc = cdata->init(dbs_data); 271 271 if (rc) { 272 272 pr_err("%s: POLICY_INIT: init() failed\n", __func__); ··· 296 294 set_sampling_rate(dbs_data, max(dbs_data->min_sampling_rate, 297 295 latency * LATENCY_MULTIPLIER)); 298 296 299 - if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { 297 + if ((cdata->governor == GOV_CONSERVATIVE) && 298 + (!policy->governor->initialized)) { 300 299 struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; 301 300 302 301 cpufreq_register_notifier(cs_ops->notifier_block, ··· 309 306 310 307 return 0; 311 308 case CPUFREQ_GOV_POLICY_EXIT: 312 - if ((policy->governor->initialized == 1) || 313 - have_governor_per_policy()) { 309 + if (!--dbs_data->usage_count) { 314 310 sysfs_remove_group(get_governor_parent_kobj(policy), 315 311 get_sysfs_attr(dbs_data)); 316 312 317 - if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { 313 + if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && 314 + (policy->governor->initialized == 1)) { 318 315 struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; 319 316 320 317 cpufreq_unregister_notifier(cs_ops->notifier_block,
+1
drivers/cpufreq/cpufreq_governor.h
··· 211 211 struct dbs_data { 212 212 struct common_dbs_data *cdata; 213 213 unsigned int min_sampling_rate; 214 + int usage_count; 214 215 void *tuners; 215 216 216 217 /* dbs_mutex protects dbs_enable in governor start/stop */
-1
drivers/cpufreq/cpufreq_ondemand.c
··· 547 547 tuners->io_is_busy = should_io_be_busy(); 548 548 549 549 dbs_data->tuners = tuners; 550 - pr_info("%s: tuners %p\n", __func__, tuners); 551 550 mutex_init(&dbs_data->mutex); 552 551 return 0; 553 552 }
+4 -3
drivers/cpufreq/cpufreq_stats.c
··· 349 349 350 350 switch (action) { 351 351 case CPU_ONLINE: 352 - case CPU_ONLINE_FROZEN: 353 352 cpufreq_update_policy(cpu); 354 353 break; 355 354 case CPU_DOWN_PREPARE: 356 - case CPU_DOWN_PREPARE_FROZEN: 357 355 cpufreq_stats_free_sysfs(cpu); 358 356 break; 359 357 case CPU_DEAD: 360 - case CPU_DEAD_FROZEN: 358 + cpufreq_stats_free_table(cpu); 359 + break; 360 + case CPU_UP_CANCELED_FROZEN: 361 + cpufreq_stats_free_sysfs(cpu); 361 362 cpufreq_stats_free_table(cpu); 362 363 break; 363 364 }
+20 -100
drivers/cpufreq/intel_pstate.c
··· 48 48 } 49 49 50 50 struct sample { 51 - ktime_t start_time; 52 - ktime_t end_time; 53 51 int core_pct_busy; 54 - int pstate_pct_busy; 55 - u64 duration_us; 56 - u64 idletime_us; 57 52 u64 aperf; 58 53 u64 mperf; 59 54 int freq; ··· 81 86 struct pstate_adjust_policy *pstate_policy; 82 87 struct pstate_data pstate; 83 88 struct _pid pid; 84 - struct _pid idle_pid; 85 89 86 90 int min_pstate_count; 87 - int idle_mode; 88 91 89 - ktime_t prev_sample; 90 - u64 prev_idle_time_us; 91 92 u64 prev_aperf; 92 93 u64 prev_mperf; 93 94 int sample_ptr; ··· 115 124 int min_perf_pct; 116 125 int32_t max_perf; 117 126 int32_t min_perf; 127 + int max_policy_pct; 128 + int max_sysfs_pct; 118 129 }; 119 130 120 131 static struct perf_limits limits = { ··· 125 132 .max_perf = int_tofp(1), 126 133 .min_perf_pct = 0, 127 134 .min_perf = 0, 135 + .max_policy_pct = 100, 136 + .max_sysfs_pct = 100, 128 137 }; 129 138 130 139 static inline void pid_reset(struct _pid *pid, int setpoint, int busy, ··· 193 198 pid_reset(&cpu->pid, 194 199 cpu->pstate_policy->setpoint, 195 200 100, 196 - cpu->pstate_policy->deadband, 197 - 0); 198 - } 199 - 200 - static inline void intel_pstate_idle_pid_reset(struct cpudata *cpu) 201 - { 202 - pid_p_gain_set(&cpu->idle_pid, cpu->pstate_policy->p_gain_pct); 203 - pid_d_gain_set(&cpu->idle_pid, cpu->pstate_policy->d_gain_pct); 204 - pid_i_gain_set(&cpu->idle_pid, cpu->pstate_policy->i_gain_pct); 205 - 206 - pid_reset(&cpu->idle_pid, 207 - 75, 208 - 50, 209 201 cpu->pstate_policy->deadband, 210 202 0); 211 203 } ··· 284 302 if (ret != 1) 285 303 return -EINVAL; 286 304 287 - limits.max_perf_pct = clamp_t(int, input, 0 , 100); 305 + limits.max_sysfs_pct = clamp_t(int, input, 0 , 100); 306 + limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); 288 307 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 289 308 return count; 290 309 } ··· 391 408 if (pstate == cpu->pstate.current_pstate) 392 409 return; 393 410 394 - #ifndef MODULE 395 411 trace_cpu_frequency(pstate * 100000, cpu->cpu); 396 - #endif 412 + 397 413 cpu->pstate.current_pstate = pstate; 398 414 wrmsrl(MSR_IA32_PERF_CTL, pstate << 8); 399 415 ··· 432 450 struct sample *sample) 433 451 { 434 452 u64 core_pct; 435 - sample->pstate_pct_busy = 100 - div64_u64( 436 - sample->idletime_us * 100, 437 - sample->duration_us); 438 453 core_pct = div64_u64(sample->aperf * 100, sample->mperf); 439 454 sample->freq = cpu->pstate.max_pstate * core_pct * 1000; 440 455 441 - sample->core_pct_busy = div_s64((sample->pstate_pct_busy * core_pct), 442 - 100); 456 + sample->core_pct_busy = core_pct; 443 457 } 444 458 445 459 static inline void intel_pstate_sample(struct cpudata *cpu) 446 460 { 447 - ktime_t now; 448 - u64 idle_time_us; 449 461 u64 aperf, mperf; 450 - 451 - now = ktime_get(); 452 - idle_time_us = get_cpu_idle_time_us(cpu->cpu, NULL); 453 462 454 463 rdmsrl(MSR_IA32_APERF, aperf); 455 464 rdmsrl(MSR_IA32_MPERF, mperf); 456 - /* for the first sample, don't actually record a sample, just 457 - * set the baseline */ 458 - if (cpu->prev_idle_time_us > 0) { 459 - cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT; 460 - cpu->samples[cpu->sample_ptr].start_time = cpu->prev_sample; 461 - cpu->samples[cpu->sample_ptr].end_time = now; 462 - cpu->samples[cpu->sample_ptr].duration_us = 463 - ktime_us_delta(now, cpu->prev_sample); 464 - cpu->samples[cpu->sample_ptr].idletime_us = 465 - idle_time_us - cpu->prev_idle_time_us; 465 + cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT; 466 + cpu->samples[cpu->sample_ptr].aperf = aperf; 467 + cpu->samples[cpu->sample_ptr].mperf = mperf; 468 + cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf; 469 + cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf; 466 470 467 - cpu->samples[cpu->sample_ptr].aperf = aperf; 468 - cpu->samples[cpu->sample_ptr].mperf = mperf; 469 - cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf; 470 - cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf; 471 + intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]); 471 472 472 - intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]); 473 - } 474 - 475 - cpu->prev_sample = now; 476 - cpu->prev_idle_time_us = idle_time_us; 477 473 cpu->prev_aperf = aperf; 478 474 cpu->prev_mperf = mperf; 479 475 } ··· 463 503 sample_time = cpu->pstate_policy->sample_rate_ms; 464 504 delay = msecs_to_jiffies(sample_time); 465 505 mod_timer_pinned(&cpu->timer, jiffies + delay); 466 - } 467 - 468 - static inline void intel_pstate_idle_mode(struct cpudata *cpu) 469 - { 470 - cpu->idle_mode = 1; 471 - } 472 - 473 - static inline void intel_pstate_normal_mode(struct cpudata *cpu) 474 - { 475 - cpu->idle_mode = 0; 476 506 } 477 507 478 508 static inline int intel_pstate_get_scaled_busy(struct cpudata *cpu) ··· 497 547 intel_pstate_pstate_decrease(cpu, steps); 498 548 } 499 549 500 - static inline void intel_pstate_adjust_idle_pstate(struct cpudata *cpu) 501 - { 502 - int busy_scaled; 503 - struct _pid *pid; 504 - int ctl = 0; 505 - int steps; 506 - 507 - pid = &cpu->idle_pid; 508 - 509 - busy_scaled = intel_pstate_get_scaled_busy(cpu); 510 - 511 - ctl = pid_calc(pid, 100 - busy_scaled); 512 - 513 - steps = abs(ctl); 514 - if (ctl < 0) 515 - intel_pstate_pstate_decrease(cpu, steps); 516 - else 517 - intel_pstate_pstate_increase(cpu, steps); 518 - 519 - if (cpu->pstate.current_pstate == cpu->pstate.min_pstate) 520 - intel_pstate_normal_mode(cpu); 521 - } 522 - 523 550 static void intel_pstate_timer_func(unsigned long __data) 524 551 { 525 552 struct cpudata *cpu = (struct cpudata *) __data; 526 553 527 554 intel_pstate_sample(cpu); 555 + intel_pstate_adjust_busy_pstate(cpu); 528 556 529 - if (!cpu->idle_mode) 530 - intel_pstate_adjust_busy_pstate(cpu); 531 - else 532 - intel_pstate_adjust_idle_pstate(cpu); 533 - 534 - #if defined(XPERF_FIX) 535 557 if (cpu->pstate.current_pstate == cpu->pstate.min_pstate) { 536 558 cpu->min_pstate_count++; 537 559 if (!(cpu->min_pstate_count % 5)) { 538 560 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); 539 - intel_pstate_idle_mode(cpu); 540 561 } 541 562 } else 542 563 cpu->min_pstate_count = 0; 543 - #endif 564 + 544 565 intel_pstate_set_sample_time(cpu); 545 566 } 546 567 ··· 552 631 (unsigned long)cpu; 553 632 cpu->timer.expires = jiffies + HZ/100; 554 633 intel_pstate_busy_pid_reset(cpu); 555 - intel_pstate_idle_pid_reset(cpu); 556 634 intel_pstate_sample(cpu); 557 635 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); 558 636 ··· 595 675 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); 596 676 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); 597 677 598 - limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq; 599 - limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100); 678 + limits.max_policy_pct = policy->max * 100 / policy->cpuinfo.max_freq; 679 + limits.max_policy_pct = clamp_t(int, limits.max_policy_pct, 0 , 100); 680 + limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); 600 681 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 601 682 602 683 return 0; ··· 709 788 710 789 pr_info("Intel P-state driver initializing.\n"); 711 790 712 - all_cpu_data = vmalloc(sizeof(void *) * num_possible_cpus()); 791 + all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus()); 713 792 if (!all_cpu_data) 714 793 return -ENOMEM; 715 - memset(all_cpu_data, 0, sizeof(void *) * num_possible_cpus()); 716 794 717 795 rc = cpufreq_register_driver(&intel_pstate_driver); 718 796 if (rc)
-4
drivers/cpufreq/kirkwood-cpufreq.c
··· 171 171 priv.dev = &pdev->dev; 172 172 173 173 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 174 - if (!res) { 175 - dev_err(&pdev->dev, "Cannot get memory resource\n"); 176 - return -ENODEV; 177 - } 178 174 priv.base = devm_ioremap_resource(&pdev->dev, res); 179 175 if (IS_ERR(priv.base)) 180 176 return PTR_ERR(priv.base);
+1 -1
include/acpi/acpiosxf.h
··· 77 77 /* 78 78 * OSL Initialization and shutdown primitives 79 79 */ 80 - acpi_status __initdata acpi_os_initialize(void); 80 + acpi_status __init acpi_os_initialize(void); 81 81 82 82 acpi_status acpi_os_terminate(void); 83 83
+8 -2
include/acpi/processor.h
··· 329 329 int acpi_processor_power_exit(struct acpi_processor *pr); 330 330 int acpi_processor_cst_has_changed(struct acpi_processor *pr); 331 331 int acpi_processor_hotplug(struct acpi_processor *pr); 332 - int acpi_processor_suspend(struct device *dev); 333 - int acpi_processor_resume(struct device *dev); 334 332 extern struct cpuidle_driver acpi_idle_driver; 333 + 334 + #ifdef CONFIG_PM_SLEEP 335 + void acpi_processor_syscore_init(void); 336 + void acpi_processor_syscore_exit(void); 337 + #else 338 + static inline void acpi_processor_syscore_init(void) {} 339 + static inline void acpi_processor_syscore_exit(void) {} 340 + #endif 335 341 336 342 /* in processor_thermal.c */ 337 343 int acpi_processor_get_limit_info(struct acpi_processor *pr);