Skip to contentSkip to conversation

ACPI patches on test branch, which are not on release branch

PATCH New Len Brown 1 participant 5 messages Oct 10, 2007

Subsystems (5)
lore
Share & tools
lore
author reviewer
#1 lore raw

PATCH 1/4 cpuidle: consolidate 2.6.22 cpuidle branch into one patch

From: Len Brown <[email protected]>

commit e5a16b1f9eec0af7cfa0830304b41c1c0833cf9f

Author: Len Brown <[email protected]>
Date:   Tue Oct 2 23:44:44 2007 -0400

cpuidle: shrink diff

processor_idle.c | 440 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 429 insertions(+), 11 deletions(-)

commit dfbb9d5aedfb18848a3e0d6f6e3e4969febb209c

Author: Len Brown <[email protected]>
Date:   Wed Sep 26 02:17:55 2007 -0400

cpuidle: reduce diff size

Reduces the cpuidle processor_idle.c diff vs 2.6.22 from this
processor_idle.c | 2006 ++++++++++++++++++++++++++----------------- 1 file changed, 1219 insertions(+), 787 deletions(-)

to this:
processor_idle.c | 502 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 458 insertions(+), 44 deletions(-)

...for the purpose of making the cpuilde patch less invasive and easier to review.

no functional changes. build tested only.

commit 889172fc915f5a7fe20f35b133cbd205ce69bf6c

Author: Venki Pallipadi <[email protected]>
Date:   Thu Sep 13 13:40:05 2007 -0700

cpuidle: Retain old ACPI policy for !CONFIG_CPU_IDLE

Retain the old policy in processor_idle, so that when CPU_IDLE is not configured, old C-state policy will still be used. This provides a clean gradual migration path from old ACPI policy to new cpuidle based policy.

commit 9544a8181edc7ecc33b3bfd69271571f98ed08bc

Author: Venki Pallipadi <[email protected]>
Date:   Thu Sep 13 13:39:17 2007 -0700

cpuidle: Configure governors by default

Quoting Len "Do not give an option to users to shoot themselves in the foot".

Remove the configurability of ladder and menu governors as they are needed for default policy of cpuidle. That way users will not be able to have cpuidle without any policy loosing all C-state power savings.

commit 8975059a2c1e56cfe83d1bcf031bcf4cb39be743

Author: Adam Belay <[email protected]>
Date:   Tue Aug 21 18:27:07 2007 -0400

CPUIDLE: load ACPI properly when CPUIDLE is disabled

Change the registration return codes for when CPUIDLE support is not compiled into the kernel. As a result, the ACPI processor driver will load properly even if CPUIDLE is unavailable. However, it may be possible to cleanup the ACPI processor driver further and eliminate some dead code paths.

commit e0322e2b58dd1b12ec669bf84693efe0dc2414a8

Author: Adam Belay <[email protected]>
Date:   Tue Aug 21 18:26:06 2007 -0400

CPUIDLE: remove cpuidle_get_bm_activity()

Remove cpuidle_get_bm_activity() and updates governors accordingly.

commit 18a6e770d5c82ba26653e53d240caa617e09e9ab

Author: Adam Belay <[email protected]>
Date:   Tue Aug 21 18:25:58 2007 -0400

CPUIDLE: max_cstate fix

Currently max_cstate is limited to 0, resulting in no idle processor power management on ACPI platforms. This patch restores the value to the array size.

commit 1fdc0887286179b40ce24bcdbde663172e205ef0

Author: Adam Belay <[email protected]>
Date:   Tue Aug 21 18:25:40 2007 -0400

CPUIDLE: handle BM detection inside the ACPI Processor driver

Update the ACPI processor driver to detect BM activity and limit state entry depth internally, rather than exposing such requirements to CPUIDLE. As a result, CPUIDLE can drop this ACPI-specific interface and become more platform independent. BM activity is now handled much more aggressively than it was in the original implementation, so some testing coverage may be needed to verify that this doesn't introduce any DMA buffer under-run issues.

commit 0ef38840db666f48e3cdd2b769da676c57228dd9

Author: Adam Belay <[email protected]>
Date:   Tue Aug 21 18:25:14 2007 -0400

CPUIDLE: menu governor updates

Tweak the menu governor to more effectively handle non-timer break events. Non-timer break events are detected by comparing the actual sleep time to the expected sleep time. In future revisions, it may be more reliable to use the timer data structures directly.

commit bb4d74fca63fa96cf3ace644b15ae0f12b7df5a1

Author: Adam Belay <[email protected]>
Date:   Tue Aug 21 18:24:40 2007 -0400

CPUIDLE: fix 'current_governor' sysfs entry

Allow the "current_governor" sysfs entry to properly handle input terminated with '\n'.

commit df3c71559bb69b125f1a48971bf0d17f78bbdf47

Author: Len Brown <[email protected]>
Date:   Sun Aug 12 02:00:45 2007 -0400

cpuidle: fix IA64 build (again)

commit a02064579e3f9530fd31baae16b1fc46b5a7bca8

Author: Venkatesh Pallipadi <[email protected]>
Date:   Sun Aug 12 01:39:27 2007 -0400

cpuidle: Remove support for runtime changing of max_cstate

Remove support for runtime changeability of max_cstate. Drivers can use use latency APIs.

max_cstate can still be used as a boot time option and dmi override.

commit 0912a44b13adf22f5e3f607d263aed23b4910d7e

Author: Venkatesh Pallipadi <[email protected]>
Date:   Sun Aug 12 01:39:16 2007 -0400

cpuidle: Remove ACPI cstate_limit calls from ipw2100

ipw2100 already has code to use accetable_latency interfaces to limit the C-state. Remove the calls to acpi_set_cstate_limit and acpi_get_cstate_limit as they are redundant.

commit c649a76e76be6bff1fd770d0a775798813a3f6e0

Author: Venkatesh Pallipadi <[email protected]>
Date:   Sun Aug 12 01:35:39 2007 -0400

cpuidle: compile fix for pause and resume functions

Fix the compilation failure when cpuidle is not compiled in.

commit 2305a5920fb8ee6ccec1c62ade05aa8351091d71

Author: Adam Belay <[email protected]>
Date:   Thu Jul 19 00:49:00 2007 -0400

cpuidle: re-write

Some portions have been rewritten to make the code cleaner and lighter weight. The following is a list of changes:

1.) the state name is now included in the sysfs interface 2.) detection, hotplug, and available state modifications are handled by CPUIDLE drivers directly
3.) the CPUIDLE idle handler is only ever installed when at least one cpuidle_device is enabled and ready
4.) the menu governor BM code no longer overflows
5.) the sysfs attributes are now printed as unsigned integers, avoiding negative values
6.) a variety of other small cleanups

Also, Idle drivers are no longer swappable during runtime through the CPUIDLE sysfs inteface. On i386 and x86_64 most idle handlers (e.g. poll, mwait, halt, etc.) don't benefit from an infrastructure that supports multiple states, so I think using a more general case idle handler selection mechanism would be cleaner.

commit df25b6b56955714e6e24b574d88d1fd11f0c3ee5

Author: Len Brown <[email protected]>
Date:   Tue Jul 24 17:08:21 2007 -0400

cpuidle: fix IA64 buid

commit fd6ada4c14488755ff7068860078c437431fbccd

Author: Adrian Bunk <[email protected]>
Date:   Mon Jul 9 11:33:13 2007 -0700

cpuidle: static

make cpuidle_replace_governor() static

commit c1d4a2cebcadf2429c0c72e1d29aa2a9684c32e0

Author: Adrian Bunk <[email protected]>
Date:   Tue Jul 3 00:54:40 2007 -0400

cpuidle: static

This patch makes the needlessly global struct menu_governor static.

commit dbf8780c6e8d572c2c273da97ed1cca7608fd999

Author: Andrew Morton <[email protected]>
Date:   Tue Jul 3 00:49:14 2007 -0400

export symbol tick_nohz_get_sleep_length

ERROR: "tick_nohz_get_sleep_length" [drivers/cpuidle/governors/menu.ko] undefined!
ERROR: "tick_nohz_get_idle_jiffies" [drivers/cpuidle/governors/menu.ko] undefined!

And please be sure to get your changes to core kernel suitably reviewed.

Cc Adam Belay <[email protected]>
Cc Venki Pallipadi <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc john stultz <[email protected]>

commit 29f0e248e7017be15f99febf9143a2cef00b2961

Author: Andrew Morton <[email protected]>
Date:   Tue Jul 3 00:43:04 2007 -0400

tick.h needs hrtimer.h

It uses hrtimers.

commit e40cede7d63a029e92712a3fe02faee60cc38fb4

Author: Venki Pallipadi <[email protected]>
Date:   Tue Jul 3 00:40:34 2007 -0400

cpuidle: first round of documentation updates

Documentation changes based on Pavel's feedback.

commit 83b42be2efece386976507555c29e7773a0dfcd1

Author: Venki Pallipadi <[email protected]>
Date:   Tue Jul 3 00:39:25 2007 -0400

cpuidle: add rating to the governors and pick the one with highest rating by default

Introduce a governor rating scheme to pick the right governor by default.

commit d2a74b8c5e8f22def4709330d4bfc4a29209b71c

Author: Venki Pallipadi <[email protected]>
Date:   Tue Jul 3 00:38:08 2007 -0400

cpuidle: make cpuidle sysfs driver governor switch off by default

Make default cpuidle sysfs to show current_governor and current_driver in read-only mode. More elaborate available_governors and available_drivers with writeable current_governor and current_driver interface only appear with "cpuidle_sysfs_switch" boot parameter.

commit 1f60a0e80bf83cf6b55c8845bbe5596ed8f6307b

Author: Venki Pallipadi <[email protected]>
Date:   Tue Jul 3 00:37:00 2007 -0400

cpuidle: menu governor: change the early break condition

Change the C-state early break out algorithm in menu governor.

We only look at early breakouts that result in wakeups shorter than idle state's target_residency. If such a breakout is frequent enough, eliminate the particular idle state upto a timeout period.

commit 45a42095cf64b003b4a69be3ce7f434f97d7af51

Author: Venki Pallipadi <[email protected]>
Date:   Tue Jul 3 00:35:38 2007 -0400

cpuidle: fix uninitialized variable in sysfs routine

Fix the uninitialized usage of ret.

commit 80dca7cdba3e6ee13eae277660873ab9584eb3be

Author: Venki Pallipadi <[email protected]>
Date:   Tue Jul 3 00:34:16 2007 -0400

cpuidle: reenable /proc/acpi//power interface for the time being

Keep /proc/acpi/processor/CPU*/power around for a while as powertop depends on it. It will be marked deprecated and removed in future. powertop can use cpuidle interfaces instead.

commit 589c37c2646c5e3813a51255a5ee1159cb4c33fc

Author: Venki Pallipadi <[email protected]>
Date:   Tue Jul 3 00:32:37 2007 -0400

cpuidle: menu governor and hrtimer compile fix

Compile fix for menu governor.

commit 0ba80bd9ab3ed304cb4f19b722e4cc6740588b5e

Author: Len Brown <[email protected]>
Date:   Thu May 31 22:51:43 2007 -0400

cpuidle: build fix - cpuidle vs ipw2100 module

ERROR: "acpi_set_cstate_limit" [drivers/net/wireless/ipw2100.ko] undefined!

commit d7d8fa7f96a7f7682be7c6cc0cc53fa7a18c3b58

Author: Adam Belay <[email protected]>
Date:   Sat Mar 24 03:47:07 2007 -0400

cpuidle: add the 'menu' governor

Here is my first take at implementing an idle PM governor that takes full advantage of NO_HZ. I call it the 'menu' governor because it considers the full list of idle states before each entry.

I've kept the implementation fairly simple. It attempts to guess the next residency time and then chooses a state that would meet at least the break-even point between power savings and entry cost. To this end, it selects the deepest idle state that satisfies the following constraints:
1. If the idle time elapsed since bus master activity was detected is below a threshold (currently 20 ms), then limit the selection to C2-type or above.
2. Do not choose a state with a break-even residency that exceeds the expected time remaining until the next timer interrupt.
3. Do not choose a state with a break-even residency that exceeds the elapsed time between the last pair of break events, excluding timer interrupts.

This governor has an advantage over "ladder" governor because it proactively checks how much time remains until the next timer interrupt using the tick infrastructure. Also, it handles device interrupt activity more intelligently by not including timer interrupts in break event calculations. Finally, it doesn't make policy decisions using the number of state entries, which can have variable residency times (NO_HZ makes these potentially very large), and instead only considers sleep time deltas.

The menu governor can be selected during runtime using the cpuidle sysfs interface like so:
"echo "menu" > /sys/devices/system/cpu/cpuidle/current_governor"

commit a4bec7e65aa3b7488b879d971651cc99a6c410fe

Author: Adam Belay <[email protected]>
Date:   Sat Mar 24 03:47:03 2007 -0400

cpuidle: export time until next timer interrupt using NO_HZ

Expose information about the time remaining until the next timer interrupt expires by utilizing the dynticks infrastructure. Also modify the main idle loop to allow dynticks to handle non-interrupt break events (e.g. DMA). Finally, expose sleep ticks information to external code. Thomas Gleixner is responsible for much of the code in this patch. However, I've made some additional changes, so I'm probably responsible if there are any bugs or oversights :)

commit 2929d8996fbc77f41a5ff86bb67cdde3ca7d2d72

Author: Adam Belay <[email protected]>
Date:   Sat Mar 24 03:46:58 2007 -0400

cpuidle: governor API changes

This patch prepares cpuidle for the menu governor. It adds an optional stage after idle state entry to give the governor an opportunity to check why the state was exited. Also it makes sure the idle loop returns after each state entry, allowing the appropriate dynticks code to run.

commit 3a7fd42f9825c3b03e364ca59baa751bb350775f

Author: Venki Pallipadi <[email protected]>
Date:   Thu Apr 26 00:03:59 2007 -0700

cpuidle: hang fix

Prevent hang on x86-64, when ACPI processor driver is added as a module on a system that does not support C-states.

x86-64 expects all idle handlers to enable interrupts before returning from idle handler. This is due to enter_idle(), exit_idle() races. Make cpuidle_idle_call() confirm to this when there is no pm_idle_old.

Also, cpuidle look at the return values of attch_driver() and set current_driver to NULL if attach fails on all CPUs.

commit 4893339a142afbd5b7c01ffadfd53d14746e858e

Author: Shaohua Li <[email protected]>
Date:   Thu Apr 26 10:40:09 2007 +0800

cpuidle: add support for max_cstate limit

With CPUIDLE framework, the max_cstate (to limit max cpu c-state) parameter is ingored. Some systems require it to ignore C2/C3 and some drivers like ipw require it too.

commit 43bbbbe1cb998cbd2df656f55bb3bfe30f30e7d1

Author: Shaohua Li <[email protected]>
Date:   Thu Apr 26 10:40:13 2007 +0800

cpuidle: add cpuidle_fore_redetect_devices API

add cpuidle_force_redetect_devices API,
which forces all CPU redetect idle states.
Next patch will use it.

commit d1edadd608f24836def5ec483d2edccfb37b1d19

Author: Shaohua Li <[email protected]>
Date:   Thu Apr 26 10:40:01 2007 +0800

cpuidle: fix sysfs related issue

Fix the cpuidle sysfs issue.
a. make kobject dynamicaly allocated
b. fixed sysfs init issue to avoid suspend/resume issue

commit 7169a5cc0d67b263978859672e86c13c23a5570d

Author: Randy Dunlap <[email protected]>
Date:   Wed Mar 28 22:52:53 2007 -0400

cpuidle: 1-bit field must be unsigned

A 1-bit bitfield has no room for a sign bit.
drivers/cpuidle/governors/ladder.c:54:16: error: dubious bitfield without explicit signed' or unsigned'

commit 4658620158dc2fbd9e4bcb213c5b6fb5d05ba7d4

Author: Venkatesh Pallipadi <[email protected]>
Date:   Wed Mar 28 22:52:41 2007 -0400

cpuidle: fix boot hang

Patch for cpuidle boot hang reported by Larry Finger here.
http://www.ussg.iu.edu/hypermail/linux/kernel/0703.2/2025.html

commit c17e168aa6e5fe3851baaae8df2fbc1cf11443a9

Author: Len Brown <[email protected]>
Date:   Wed Mar 7 04:37:53 2007 -0500

cpuidle: ladder does not depend on ACPI

build fix for CONFIG_ACPI=n

In file included from drivers/cpuidle/governors/ladder.c:21:
include/acpi/processor.h:88: error: expected specifier-qualifier-list before ‘acpi_integer’ include/acpi/processor.h:106: error: expected specifier-qualifier-list before ‘acpi_integer’ include/acpi/processor.h:168: error: expected specifier-qualifier-list before ‘acpi_handle’

commit 8c91d958246bde68db0c3f0c57b535962ce861cb

Author: Adrian Bunk <[email protected]>
Date:   Tue Mar 6 02:29:40 2007 -0800

cpuidle: make code static

This patch makes the following needlessly global code static:
- driver.c: __cpuidle_find_driver()
- governor.c: __cpuidle_find_governor()
- ladder.c: struct ladder_governor

commit 0c39dc3187094c72c33ab65a64d2017b21f372d2

Author: Venkatesh Pallipadi <[email protected]>
Date:   Wed Mar 7 02:38:22 2007 -0500

cpu_idle: fix build break

This patch fixes a build breakage with !CONFIG_HOTPLUG_CPU and CONFIG_CPU_IDLE.

commit 8112e3b115659b07df340ef170515799c0105f82

Author: Venkatesh Pallipadi <[email protected]>
Date:   Tue Mar 6 02:29:39 2007 -0800

cpuidle: build fix for !CPU_IDLE

Fix the compile issues when CPU_IDLE is not configured.

commit 1eb4431e9599cd25e0d9872f3c2c8986821839dd

Author: Venkatesh Pallipadi <[email protected]>
Date:   Thu Feb 22 13:54:57 2007 -0800

cpuidle take2: Basic documentation for cpuidle

Documentation for cpuidle infrastructure

commit ef5f15a8b79123a047285ec2e3899108661df779

Author: Venkatesh Pallipadi <[email protected]>
Date:   Thu Feb 22 13:54:03 2007 -0800

cpuidle take2: Hookup ACPI C-states driver with cpuidle

Hookup ACPI C-states onto generic cpuidle infrastructure.

drivers/acpi/procesor_idle.c is now a ACPI C-states driver that registers as a driver in cpuidle infrastructure and the policy part is removed from drivers/acpi/processor_idle.c. We use governor in cpuidle instead.

commit 987196fa82d4db52c407e8c9d5dec884ba602183

Author: Venkatesh Pallipadi <[email protected]>
Date:   Thu Feb 22 13:52:57 2007 -0800

cpuidle take2: Core cpuidle infrastructure

Announcing 'cpuidle', a new CPU power management infrastructure to manage idle CPUs in a clean and efficient manner.
cpuidle separates out the drivers that can provide support for multiple types of idle states and policy governors that decide on what idle state to use at run time.
A cpuidle driver can support multiple idle states based on parameters like varying power consumption, wakeup latency, etc (ACPI C-states for example). A cpuidle governor can be usage model specific (laptop, server, laptop on battery etc).
Main advantage of the infrastructure being, it allows independent development of drivers and governors and allows for better CPU power management.

A huge thanks to Adam Belay and Shaohua Li who were part of this mini-project since its beginning and are greatly responsible for this patchset.

This patch:

Core cpuidle infrastructure.
Introduces a new abstraction layer for cpuidle:
* which manages drivers that can support multiple idles states. Drivers can be generic or particular to specific hardware/platform
* allows pluging in multiple policy governors that can take idle state policy decision
* The core also has a set of sysfs interfaces with which administrato can know about supported drivers and governors and switch them at run time.

---
 arch/i386/Kconfig                  |    2 +
 arch/x86_64/Kconfig                |    2 +
 drivers/Makefile                   |    1 +
 drivers/acpi/osl.c                 |    8 -
 drivers/acpi/processor_core.c      |   22 ++-
 drivers/acpi/processor_idle.c      |  482 +++++++++++++++++++++++++++++++++---
 drivers/cpuidle/Kconfig            |   20 ++
 drivers/cpuidle/Makefile           |    5 +
 drivers/cpuidle/cpuidle.c          |  295 ++++++++++++++++++++++
 drivers/cpuidle/cpuidle.h          |   33 +++
 drivers/cpuidle/driver.c           |   56 +++++
 drivers/cpuidle/governor.c         |  141 +++++++++++
 drivers/cpuidle/governors/Makefile |    6 +
 drivers/cpuidle/governors/ladder.c |  166 +++++++++++++
 drivers/cpuidle/governors/menu.c   |  137 ++++++++++
 drivers/cpuidle/sysfs.c            |  361 +++++++++++++++++++++++++++
 drivers/net/wireless/ipw2100.c     |   29 ---
 drivers/net/wireless/ipw2100.h     |    2 -
 include/acpi/processor.h           |    5 +
 include/linux/acpi.h               |   26 --
 include/linux/cpuidle.h            |  180 ++++++++++++++
 include/linux/tick.h               |    9 +
 kernel/time/tick-sched.c           |   16 ++
 23 files changed, 1895 insertions(+), 109 deletions(-)
 create mode 100644 drivers/cpuidle/Kconfig
 create mode 100644 drivers/cpuidle/Makefile
 create mode 100644 drivers/cpuidle/cpuidle.c
 create mode 100644 drivers/cpuidle/cpuidle.h
 create mode 100644 drivers/cpuidle/driver.c
 create mode 100644 drivers/cpuidle/governor.c
 create mode 100644 drivers/cpuidle/governors/Makefile
 create mode 100644 drivers/cpuidle/governors/ladder.c
 create mode 100644 drivers/cpuidle/governors/menu.c
 create mode 100644 drivers/cpuidle/sysfs.c
 create mode 100644 include/linux/cpuidle.h
arch/i386/Kconfig +2 -0
index 97b64d7..3328e0a 100644
@@ -1069,6 +1069,8 @@ endif # APM
 
 source "arch/i386/kernel/cpu/cpufreq/Kconfig"
 
+source "drivers/cpuidle/Kconfig"
+
 endmenu
 
 menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
arch/x86_64/Kconfig +2 -0
index b4d9089..e8dbb37 100644
@@ -706,6 +706,8 @@ source "drivers/acpi/Kconfig"
 
 source "arch/x86_64/kernel/cpufreq/Kconfig"
 
+source "drivers/cpuidle/Kconfig"
+
 endmenu
 
 menu "Bus options (PCI etc.)"
drivers/Makefile +1 -0
index f0878b2..10a9c52 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_MCA)		+= mca/
 obj-$(CONFIG_EISA)		+= eisa/
 obj-$(CONFIG_LGUEST_GUEST)	+= lguest/
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
+obj-$(CONFIG_CPU_IDLE)		+= cpuidle/
 obj-$(CONFIG_MMC)		+= mmc/
 obj-$(CONFIG_NEW_LEDS)		+= leds/
 obj-$(CONFIG_INFINIBAND)	+= infiniband/
drivers/acpi/osl.c +0 -8
index 12c09fa..5d14d4f 100644
@@ -1043,14 +1043,6 @@ static int __init acpi_wake_gpes_always_on_setup(char *str)
 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
 
 /*
- * max_cstate is defined in the base kernel so modules can
- * change it w/o depending on the state of the processor module.
- */
-unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
-
-EXPORT_SYMBOL(max_cstate);
-
-/*
  * Acquire a spinlock.
  *
  * handle is a pointer to the spinlock_t.
drivers/acpi/processor_core.c +17 -5
index 9f11dc2..a735108 100644
@@ -44,6 +44,7 @@
 #include <linux/seq_file.h>
 #include <linux/dmi.h>
 #include <linux/moduleparam.h>
+#include <linux/cpuidle.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
@@ -1049,11 +1050,13 @@ static int __init acpi_processor_init(void)
 		return -ENOMEM;
 	acpi_processor_dir->owner = THIS_MODULE;
 
+	result = cpuidle_register_driver(&acpi_idle_driver);
+	if (result < 0)
+		goto out_proc;
+
 	result = acpi_bus_register_driver(&acpi_processor_driver);
-	if (result < 0) {
-		remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
-		return result;
-	}
+	if (result < 0)
+		goto out_cpuidle;
 
 	acpi_processor_install_hotplug_notify();
 
@@ -1062,11 +1065,18 @@ static int __init acpi_processor_init(void)
 	acpi_processor_ppc_init();
 
 	return 0;
+
+out_cpuidle:
+	cpuidle_unregister_driver(&acpi_idle_driver);
+
+out_proc:
+	remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
+
+	return result;
 }
 
 static void __exit acpi_processor_exit(void)
 {
-
 	acpi_processor_ppc_exit();
 
 	acpi_thermal_cpufreq_exit();
@@ -1075,6 +1085,8 @@ static void __exit acpi_processor_exit(void)
 
 	acpi_bus_unregister_driver(&acpi_processor_driver);
 
+	cpuidle_unregister_driver(&acpi_idle_driver);
+
 	remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
 
 	return;
drivers/acpi/processor_idle.c +443 -39

640 lines not on this page · raw message

drivers/cpuidle/Kconfig new file +20 -0
new file mode 100644
index 0000000..3bed412
@@ -0,0 +1,20 @@
+
+config CPU_IDLE
+	bool "CPU idle PM support"
+	help
+	  CPU idle is a generic framework for supporting software-controlled
+	  idle processor power management.  It includes modular cross-platform
+	  governors that can be swapped during runtime.
+
+	  If you're using a mobile platform that supports CPU idle PM (e.g.
+	  an ACPI-capable notebook), you should say Y here.
+
+config CPU_IDLE_GOV_LADDER
+	bool
+	depends on CPU_IDLE
+	default y
+
+config CPU_IDLE_GOV_MENU
+	bool
+	depends on CPU_IDLE && NO_HZ
+	default y
drivers/cpuidle/Makefile new file +5 -0
new file mode 100644
index 0000000..5634f88
@@ -0,0 +1,5 @@
+#
+# Makefile for cpuidle.
+#
+
+obj-y += cpuidle.o driver.o governor.o sysfs.o governors/
drivers/cpuidle/cpuidle.c new file +295 -0

295 lines not on this page · raw message

drivers/cpuidle/cpuidle.h new file +33 -0
new file mode 100644
index 0000000..9476ba3
@@ -0,0 +1,33 @@
+/*
+ * cpuidle.h - The internal header file
+ */
+
+#ifndef __DRIVER_CPUIDLE_H
+#define __DRIVER_CPUIDLE_H
+
+#include <linux/sysdev.h>
+
+/* For internal use only */
+extern struct cpuidle_governor *cpuidle_curr_governor;
+extern struct cpuidle_driver *cpuidle_curr_driver;
+extern struct list_head cpuidle_governors;
+extern struct list_head cpuidle_detected_devices;
+extern struct mutex cpuidle_lock;
+extern spinlock_t cpuidle_driver_lock;
+
+/* idle loop */
+extern void cpuidle_install_idle_handler(void);
+extern void cpuidle_uninstall_idle_handler(void);
+
+/* governors */
+extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
+
+/* sysfs */
+extern int cpuidle_add_class_sysfs(struct sysdev_class *cls);
+extern void cpuidle_remove_class_sysfs(struct sysdev_class *cls);
+extern int cpuidle_add_state_sysfs(struct cpuidle_device *device);
+extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device);
+extern int cpuidle_add_sysfs(struct sys_device *sysdev);
+extern void cpuidle_remove_sysfs(struct sys_device *sysdev);
+
+#endif /* __DRIVER_CPUIDLE_H */
drivers/cpuidle/driver.c new file +56 -0

56 lines not on this page · raw message

drivers/cpuidle/governor.c new file +141 -0

141 lines not on this page · raw message

drivers/cpuidle/governors/Makefile new file +6 -0
new file mode 100644
index 0000000..1b51272
@@ -0,0 +1,6 @@
+#
+# Makefile for cpuidle governors.
+#
+
+obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o
+obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o
drivers/cpuidle/governors/ladder.c new file +166 -0

166 lines not on this page · raw message

drivers/cpuidle/governors/menu.c new file +137 -0

137 lines not on this page · raw message

drivers/cpuidle/sysfs.c new file +361 -0

361 lines not on this page · raw message

drivers/net/wireless/ipw2100.c +0 -29
index 8990585..e8a94b7 100644
@@ -1858,14 +1858,6 @@ static void ipw2100_down(struct ipw2100_priv *priv)
 
 	modify_acceptable_latency("ipw2100", INFINITE_LATENCY);
 
-#ifdef ACPI_CSTATE_LIMIT_DEFINED
-	if (priv->config & CFG_C3_DISABLED) {
-		IPW_DEBUG_INFO(": Resetting C3 transitions.\n");
-		acpi_set_cstate_limit(priv->cstate_limit);
-		priv->config &= ~CFG_C3_DISABLED;
-	}
-#endif
-
 	/* We have to signal any supplicant if we are disassociating */
 	if (associated)
 		wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
@@ -2088,14 +2080,6 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
 	/* RF_KILL is now enabled (else we wouldn't be here) */
 	priv->status |= STATUS_RF_KILL_HW;
 
-#ifdef ACPI_CSTATE_LIMIT_DEFINED
-	if (priv->config & CFG_C3_DISABLED) {
-		IPW_DEBUG_INFO(": Resetting C3 transitions.\n");
-		acpi_set_cstate_limit(priv->cstate_limit);
-		priv->config &= ~CFG_C3_DISABLED;
-	}
-#endif
-
 	/* Make sure the RF Kill check timer is running */
 	priv->stop_rf_kill = 0;
 	cancel_delayed_work(&priv->rf_kill);
@@ -2326,23 +2310,10 @@ static void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i)
 	u32 match, reg;
 	int j;
 #endif
-#ifdef ACPI_CSTATE_LIMIT_DEFINED
-	int limit;
-#endif
 
 	IPW_DEBUG_INFO(": PCI latency error detected at 0x%04zX.\n",
 		       i * sizeof(struct ipw2100_status));
 
-#ifdef ACPI_CSTATE_LIMIT_DEFINED
-	IPW_DEBUG_INFO(": Disabling C3 transitions.\n");
-	limit = acpi_get_cstate_limit();
-	if (limit > 2) {
-		priv->cstate_limit = limit;
-		acpi_set_cstate_limit(2);
-		priv->config |= CFG_C3_DISABLED;
-	}
-#endif
-
 #ifdef IPW2100_DEBUG_C3
 	/* Halt the fimrware so we can get a good image */
 	write_register(priv->net_dev, IPW_REG_RESET_REG,
drivers/net/wireless/ipw2100.h +0 -2
index de7d384..2b8be24 100644
@@ -479,7 +479,6 @@ enum {
 #define CFG_ASSOCIATE           (1<<6)
 #define CFG_FIXED_RATE          (1<<7)
 #define CFG_ADHOC_CREATE        (1<<8)
-#define CFG_C3_DISABLED         (1<<9)
 #define CFG_PASSIVE_SCAN        (1<<10)
 #ifdef CONFIG_IPW2100_MONITOR
 #define CFG_CRC_CHECK           (1<<11)
@@ -508,7 +507,6 @@ struct ipw2100_priv {
 	u8 bssid[ETH_ALEN];
 	u8 channel;
 	int last_mode;
-	int cstate_limit;
 
 	unsigned long connect_start;
 	unsigned long last_reset;
include/acpi/processor.h +5 -0
index 99934a9..26d79f6 100644
@@ -3,6 +3,7 @@
 
 #include <linux/kernel.h>
 #include <linux/cpu.h>
+#include <linux/cpuidle.h>
 
 #include <asm/acpi.h>
 
@@ -75,7 +76,9 @@ struct acpi_processor_cx {
 };
 
 struct acpi_processor_power {
+	struct cpuidle_device dev;
 	struct acpi_processor_cx *state;
+	struct acpi_processor_cx *bm_state;
 	unsigned long bm_check_timestamp;
 	u32 default_state;
 	u32 bm_activity;
@@ -199,6 +202,7 @@ struct acpi_processor_flags {
 	u8 bm_check:1;
 	u8 has_cst:1;
 	u8 power_setup_done:1;
+	u8 bm_rld_set:1;
 };
 
 struct acpi_processor {
@@ -322,6 +326,7 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
 			      struct acpi_device *device);
 int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
 int acpi_processor_resume(struct acpi_device * device);
+extern struct cpuidle_driver acpi_idle_driver;
 
 /* in processor_thermal.c */
 int acpi_processor_get_limit_info(struct acpi_processor *pr);
include/linux/acpi.h +0 -26
index bf5e000..8ccedf7 100644
@@ -189,32 +189,6 @@ extern int ec_transaction(u8 command,
 extern int acpi_blacklisted(void);
 extern void acpi_bios_year(char *s);
 
-#define	ACPI_CSTATE_LIMIT_DEFINED	/* for driver builds */
-#ifdef	CONFIG_ACPI
-
-/*
- * Set highest legal C-state
- * 0: C0 okay, but not C1
- * 1: C1 okay, but not C2
- * 2: C2 okay, but not C3 etc.
- */
-
-extern unsigned int max_cstate;
-
-static inline unsigned int acpi_get_cstate_limit(void)
-{
-	return max_cstate;
-}
-static inline void acpi_set_cstate_limit(unsigned int new_limit)
-{
-	max_cstate = new_limit;
-	return;
-}
-#else
-static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
-static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
-#endif
-
 #ifdef CONFIG_ACPI_NUMA
 int acpi_get_pxm(acpi_handle handle);
 int acpi_get_node(acpi_handle *handle);
include/linux/cpuidle.h new file +180 -0

180 lines not on this page · raw message

include/linux/tick.h +9 -0
index 9a7252e..f4a1395 100644
@@ -40,6 +40,7 @@ enum tick_nohz_mode {
  * @idle_sleeps:	Number of idle calls, where the sched tick was stopped
  * @idle_entrytime:	Time when the idle call was entered
  * @idle_sleeptime:	Sum of the time slept in idle with sched tick stopped
+ * @sleep_length:	Duration of the current idle sleep
  */
 struct tick_sched {
 	struct hrtimer			sched_timer;
@@ -52,6 +53,7 @@ struct tick_sched {
 	unsigned long			idle_sleeps;
 	ktime_t				idle_entrytime;
 	ktime_t				idle_sleeptime;
+	ktime_t				sleep_length;
 	unsigned long			last_jiffies;
 	unsigned long			next_jiffies;
 	ktime_t				idle_expires;
@@ -100,10 +102,17 @@ static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
 extern void tick_nohz_stop_sched_tick(void);
 extern void tick_nohz_restart_sched_tick(void);
 extern void tick_nohz_update_jiffies(void);
+extern ktime_t tick_nohz_get_sleep_length(void);
 # else
 static inline void tick_nohz_stop_sched_tick(void) { }
 static inline void tick_nohz_restart_sched_tick(void) { }
 static inline void tick_nohz_update_jiffies(void) { }
+static inline ktime_t tick_nohz_get_sleep_length(void)
+{
+	ktime_t len = { .tv64 = NSEC_PER_SEC/HZ };
+
+	return len;
+}
 # endif /* !NO_HZ */
 
 #endif
kernel/time/tick-sched.c +16 -0
index 8c3fef1..637519a 100644
@@ -153,6 +153,7 @@ void tick_nohz_stop_sched_tick(void)
 	unsigned long seq, last_jiffies, next_jiffies, delta_jiffies, flags;
 	struct tick_sched *ts;
 	ktime_t last_update, expires, now, delta;
+	struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev;
 	int cpu;
 
 	local_irq_save(flags);
@@ -302,11 +303,26 @@ void tick_nohz_stop_sched_tick(void)
 out:
 	ts->next_jiffies = next_jiffies;
 	ts->last_jiffies = last_jiffies;
+	ts->sleep_length = ktime_sub(dev->next_event, now);
 end:
 	local_irq_restore(flags);
 }
 
 /**
+ * tick_nohz_get_sleep_length - return the length of the current sleep
+ *
+ * Called from power state control code with interrupts disabled
+ */
+ktime_t tick_nohz_get_sleep_length(void)
+{
+	struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
+
+	return ts->sleep_length;
+}
+
+EXPORT_SYMBOL_GPL(tick_nohz_get_sleep_length);
+
+/**
  * nohz_restart_sched_tick - restart the idle tick from the idle task
  *
  * Restart the idle tick when the CPU is woken up from idle
Signature · 5 lines
1.5.3.4.206.g58ba4
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author reviewer
#2 lore raw

PATCH 2/4 ACPI: cpuidle: port idle timer suspend/resume workaround to cpuidle

From: Len Brown <[email protected]>

Some timers stop during C2 and C3, and so there are various generations of timer broadcast workarounds to deal with that. But that (already complex) code gets confused during suspend.

As it is unlikely that deep C-states would save much power during the actual suspend/resume process anyway, deep C-states were disabled via the addition of .suspend/.resume hooks in to the ACPI processor driver.

Here that workaround is ported to the cpuidle version of the ACPI idle loop. Technically, ACPI could un-register itself from cpuidle on .suspend, but that code path is currently quite cumbersome. So instead,
we simply invoke C1 from the C2 and C3 handlers for the duration of .suspend/.resume.

---
 drivers/acpi/processor_idle.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/acpi/processor_idle.c +6 -0
index 99da6a7..0cad56c 100644
@@ -1416,6 +1416,9 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 	if (unlikely(!pr))
 		return 0;
 
+	if (acpi_idle_suspend)
+		return(acpi_idle_enter_c1(dev, state));
+
 	if (pr->flags.bm_check)
 		acpi_idle_update_bm_rld(pr, cx);
 
@@ -1477,6 +1480,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	if (unlikely(!pr))
 		return 0;
 
+	if (acpi_idle_suspend)
+		return(acpi_idle_enter_c1(dev, state));
+
 	local_irq_disable();
 	current_thread_info()->status &= ~TS_POLLING;
 	/*
Signature · 1 line
1.5.3.4.206.g58ba4
author reviewer
#3 lore raw

PATCH 3/4 ACPICA: hw: remove use_lock flag from acpi_hw_register_{read, write}

From: Alexey Starikovskiy <[email protected]>

use_lock flag is used once for acpi_hw_register_read, and never for acpi_hw_register_write. It will greatly simplify understanding of locking if we just drop this use_lock altogether, and wrap the only call to ..._read in lock/unlock.

---
 drivers/acpi/events/evevent.c   |    6 +--
 drivers/acpi/hardware/hwregs.c  |   89 +++++++++++++++-----------------------
 drivers/acpi/hardware/hwsleep.c |   27 ++++--------
 include/acpi/achware.h          |    4 +-
 4 files changed, 48 insertions(+), 78 deletions(-)
drivers/acpi/events/evevent.c +2 -4
index a1f87b5..e412878 100644
@@ -239,10 +239,8 @@ u32 acpi_ev_fixed_event_detect(void)
 	 * Read the fixed feature status and enable registers, as all the cases
 	 * depend on their values.  Ignore errors here.
 	 */
-	(void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
-				    ACPI_REGISTER_PM1_STATUS, &fixed_status);
-	(void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
-				    ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
+	(void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status);
+	(void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
 			  "Fixed Event Block: Enable %08X Status %08X\n",
drivers/acpi/hardware/hwregs.c +35 -54

248 lines not on this page · raw message

drivers/acpi/hardware/hwsleep.c +9 -18
index cf69c00..4d0c677 100644
@@ -313,8 +313,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
 
 	/* Get current value of PM1A control */
 
-	status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
-				       ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
+	status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
 	}
@@ -341,15 +340,13 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
 
 	/* Write #1: fill in SLP_TYP data */
 
-	status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
-					ACPI_REGISTER_PM1A_CONTROL,
+	status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
 					PM1Acontrol);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
 	}
 
-	status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
-					ACPI_REGISTER_PM1B_CONTROL,
+	status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
 					PM1Bcontrol);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
@@ -364,15 +361,13 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
 
 	ACPI_FLUSH_CPU_CACHE();
 
-	status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
-					ACPI_REGISTER_PM1A_CONTROL,
+	status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
 					PM1Acontrol);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
 	}
 
-	status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
-					ACPI_REGISTER_PM1B_CONTROL,
+	status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
 					PM1Bcontrol);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
@@ -392,8 +387,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
 		 */
 		acpi_os_stall(10000000);
 
-		status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
-						ACPI_REGISTER_PM1_CONTROL,
+		status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
 						sleep_enable_reg_info->
 						access_bit_mask);
 		if (ACPI_FAILURE(status)) {
@@ -520,8 +514,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
 
 		/* Get current value of PM1A control */
 
-		status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
-					       ACPI_REGISTER_PM1_CONTROL,
+		status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
 					       &PM1Acontrol);
 		if (ACPI_SUCCESS(status)) {
 
@@ -543,11 +536,9 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
 
 			/* Just ignore any errors */
 
-			(void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
-						     ACPI_REGISTER_PM1A_CONTROL,
+			(void)acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
 						     PM1Acontrol);
-			(void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
-						     ACPI_REGISTER_PM1B_CONTROL,
+			(void)acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
 						     PM1Bcontrol);
 		}
 	}
include/acpi/achware.h +2 -2
index 9df275c..4053df9 100644
@@ -71,9 +71,9 @@ u32 acpi_hw_get_mode(void);
 struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id);
 
 acpi_status
-acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value);
+acpi_hw_register_read(u32 register_id, u32 * return_value);
 
-acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value);
+acpi_status acpi_hw_register_write(u32 register_id, u32 value);
 
 acpi_status
 acpi_hw_low_level_read(u32 width,
Signature · 1 line
1.5.3.4.206.g58ba4
author reviewer
#4 lore raw

PATCH 4/4 ACPICA: hw: Don't carry spinlock over suspend

From: Alexey Starikovskiy <[email protected]>

ACPI uses acpi_get_register() in order to get into suspend. This function is guarded by acpi_gbl_hardware_lock, which will be carried into resume phase.
At resume interrupts are enabled and first ACPI interrupt deadlocks on this lock.
Solution seems to be to not lock register read, as there are no concurrent activity at this point.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=7499

---
 drivers/acpi/hardware/hwsleep.c |    3 ++-
 include/acpi/acpixf.h           |    2 ++
 2 files changed, 4 insertions(+), 1 deletions(-)
drivers/acpi/hardware/hwsleep.c +2 -1
index 4d0c677..c0577ca 100644
@@ -398,7 +398,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
 	/* Wait until we enter sleep state */
 
 	do {
-		status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value);
+		status = acpi_get_register_unlocked(ACPI_BITREG_WAKE_STATUS,
+						    &in_value);
 		if (ACPI_FAILURE(status)) {
 			return_ACPI_STATUS(status);
 		}
include/acpi/acpixf.h +2 -0
index 3d7ab9e..9512f04 100644
@@ -314,6 +314,8 @@ acpi_resource_to_address64(struct acpi_resource *resource,
  */
 acpi_status acpi_get_register(u32 register_id, u32 * return_value);
 
+acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value);
+
 acpi_status acpi_set_register(u32 register_id, u32 value);
 
 acpi_status
Signature · 1 line
1.5.3.4.206.g58ba4