Commit 62027aea23fcd14478abdddd3b74a4e0f5fb2984

Authored by Len Brown
1 parent 6dccf9c508

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>

Showing 5 changed files with 20 additions and 0 deletions Side-by-side Diff

Documentation/kernel-parameters.txt
... ... @@ -546,6 +546,9 @@
546 546 /proc/<pid>/coredump_filter.
547 547 See also Documentation/filesystems/proc.txt.
548 548  
  549 + cpuidle.off=1 [CPU_IDLE]
  550 + disable the cpuidle sub-system
  551 +
549 552 cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver
550 553 Format:
551 554 <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
drivers/cpuidle/cpuidle.c
... ... @@ -28,7 +28,13 @@
28 28 static void (*pm_idle_old)(void);
29 29  
30 30 static int enabled_devices;
  31 +static int off __read_mostly;
31 32  
  33 +int cpuidle_disabled(void)
  34 +{
  35 + return off;
  36 +}
  37 +
32 38 #if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT)
33 39 static void cpuidle_kick_cpus(void)
34 40 {
... ... @@ -427,6 +433,9 @@
427 433 {
428 434 int ret;
429 435  
  436 + if (cpuidle_disabled())
  437 + return -ENODEV;
  438 +
430 439 pm_idle_old = pm_idle;
431 440  
432 441 ret = cpuidle_add_class_sysfs(&cpu_sysdev_class);
... ... @@ -438,5 +447,6 @@
438 447 return 0;
439 448 }
440 449  
  450 +module_param(off, int, 0444);
441 451 core_initcall(cpuidle_init);
drivers/cpuidle/cpuidle.h
... ... @@ -13,6 +13,7 @@
13 13 extern struct list_head cpuidle_detected_devices;
14 14 extern struct mutex cpuidle_lock;
15 15 extern spinlock_t cpuidle_driver_lock;
  16 +extern int cpuidle_disabled(void);
16 17  
17 18 /* idle loop */
18 19 extern void cpuidle_install_idle_handler(void);
drivers/cpuidle/driver.c
... ... @@ -26,6 +26,9 @@
26 26 if (!drv)
27 27 return -EINVAL;
28 28  
  29 + if (cpuidle_disabled())
  30 + return -ENODEV;
  31 +
29 32 spin_lock(&cpuidle_driver_lock);
30 33 if (cpuidle_curr_driver) {
31 34 spin_unlock(&cpuidle_driver_lock);
drivers/cpuidle/governor.c
... ... @@ -81,6 +81,9 @@
81 81 if (!gov || !gov->select)
82 82 return -EINVAL;
83 83  
  84 + if (cpuidle_disabled())
  85 + return -ENODEV;
  86 +
84 87 mutex_lock(&cpuidle_lock);
85 88 if (__cpuidle_find_governor(gov->name) == NULL) {
86 89 ret = 0;