Skip to content

Commit

Permalink
cpuidle: create bootparam "cpuidle.off=1"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lenb committed Aug 3, 2011
1 parent 6dccf9c commit 62027ae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/kernel-parameters.txt
Expand Up @@ -546,6 +546,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
/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>]
Expand Down
10 changes: 10 additions & 0 deletions drivers/cpuidle/cpuidle.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -438,4 +447,5 @@ static int __init cpuidle_init(void)
return 0;
}

module_param(off, int, 0444);
core_initcall(cpuidle_init);
1 change: 1 addition & 0 deletions drivers/cpuidle/cpuidle.h
Expand Up @@ -13,6 +13,7 @@ extern struct list_head cpuidle_governors;
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);
Expand Down
3 changes: 3 additions & 0 deletions drivers/cpuidle/driver.c
Expand Up @@ -26,6 +26,9 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)
if (!drv)
return -EINVAL;

if (cpuidle_disabled())
return -ENODEV;

spin_lock(&cpuidle_driver_lock);
if (cpuidle_curr_driver) {
spin_unlock(&cpuidle_driver_lock);
Expand Down
3 changes: 3 additions & 0 deletions drivers/cpuidle/governor.c
Expand Up @@ -81,6 +81,9 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
if (!gov || !gov->select)
return -EINVAL;

if (cpuidle_disabled())
return -ENODEV;

mutex_lock(&cpuidle_lock);
if (__cpuidle_find_governor(gov->name) == NULL) {
ret = 0;
Expand Down

0 comments on commit 62027ae

Please sign in to comment.