| From 9c84f8943b8bb242d3eab46ab23bc6daeaa7a02f Mon Sep 17 00:00:00 2001 |
| From: Len Brown <len.brown@intel.com> |
| Date: Fri, 1 Apr 2011 18:13:10 -0400 |
| Subject: cpuidle: create bootparam "cpuidle.off=1" |
| |
| useful for disabling cpuidle to fall back |
| to architecture-default idle loop |
| |
| cpuidle drivers and governors will fail to register. |
| on x86 they'll say so: |
| |
| intel_idle: intel_idle yielding to (null) |
| ACPI: acpi_idle yielding to (null) |
| |
| Signed-off-by: Len Brown <len.brown@intel.com> |
| (cherry picked from commit 62027aea23fcd14478abdddd3b74a4e0f5fb2984) |
| |
| Signed-off-by: Simon Horman <horms@verge.net.au> |
| --- |
| Documentation/kernel-parameters.txt | 3 +++ |
| drivers/cpuidle/cpuidle.c | 10 ++++++++++ |
| drivers/cpuidle/cpuidle.h | 1 + |
| drivers/cpuidle/driver.c | 3 +++ |
| drivers/cpuidle/governor.c | 3 +++ |
| 5 files changed, 20 insertions(+) |
| |
| --- a/Documentation/kernel-parameters.txt |
| +++ b/Documentation/kernel-parameters.txt |
| @@ -548,6 +548,9 @@ bytes respectively. Such letter suffixes |
| /proc/<pid>/coredump_filter. |
| See also Documentation/filesystems/proc.txt. |
| |
| + cpuidle.off=1 [CPU_IDLE] |
| + disable the cpuidle sub-system |
| + |
| cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver |
| Format: |
| <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>] |
| --- a/drivers/cpuidle/cpuidle.c |
| +++ b/drivers/cpuidle/cpuidle.c |
| @@ -28,6 +28,12 @@ LIST_HEAD(cpuidle_detected_devices); |
| static void (*pm_idle_old)(void); |
| |
| static int enabled_devices; |
| +static int off __read_mostly; |
| + |
| +int cpuidle_disabled(void) |
| +{ |
| + return off; |
| +} |
| |
| #if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT) |
| static void cpuidle_kick_cpus(void) |
| @@ -427,6 +433,9 @@ static int __init cpuidle_init(void) |
| { |
| int ret; |
| |
| + if (cpuidle_disabled()) |
| + return -ENODEV; |
| + |
| pm_idle_old = pm_idle; |
| |
| ret = cpuidle_add_class_sysfs(&cpu_sysdev_class); |
| @@ -438,4 +447,5 @@ static int __init cpuidle_init(void) |
| return 0; |
| } |
| |
| +module_param(off, int, 0444); |
| core_initcall(cpuidle_init); |
| --- a/drivers/cpuidle/cpuidle.h |
| +++ b/drivers/cpuidle/cpuidle.h |
| @@ -13,6 +13,7 @@ extern struct list_head cpuidle_governor |
| extern struct list_head cpuidle_detected_devices; |
| extern struct mutex cpuidle_lock; |
| extern spinlock_t cpuidle_driver_lock; |
| +extern int cpuidle_disabled(void); |
| |
| /* idle loop */ |
| extern void cpuidle_install_idle_handler(void); |
| --- a/drivers/cpuidle/driver.c |
| +++ b/drivers/cpuidle/driver.c |
| @@ -26,6 +26,9 @@ int cpuidle_register_driver(struct cpuid |
| if (!drv) |
| return -EINVAL; |
| |
| + if (cpuidle_disabled()) |
| + return -ENODEV; |
| + |
| spin_lock(&cpuidle_driver_lock); |
| if (cpuidle_curr_driver) { |
| spin_unlock(&cpuidle_driver_lock); |
| --- a/drivers/cpuidle/governor.c |
| +++ b/drivers/cpuidle/governor.c |
| @@ -81,6 +81,9 @@ int cpuidle_register_governor(struct cpu |
| if (!gov || !gov->select) |
| return -EINVAL; |
| |
| + if (cpuidle_disabled()) |
| + return -ENODEV; |
| + |
| mutex_lock(&cpuidle_lock); |
| if (__cpuidle_find_governor(gov->name) == NULL) { |
| ret = 0; |