Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 97989
b: refs/heads/master
c: dcb84f3
h: refs/heads/master
i:
  97987: fcaf63a
v: v3
  • Loading branch information
Venkatesh Pallipadi authored and Len Brown committed Jun 11, 2008
1 parent 4d4d75e commit e035528
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e1094bfa26e5e94af2fea79e004614dbce42b008
refs/heads/master: dcb84f335bee9c9a7781cfc5d74492dccaf066d2
13 changes: 7 additions & 6 deletions trunk/drivers/acpi/processor_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
return -EINVAL;
}

dev->cpu = pr->id;
for (i = 0; i < CPUIDLE_STATE_MAX; i++) {
dev->states[i].name[0] = '\0';
dev->states[i].desc[0] = '\0';
Expand Down Expand Up @@ -1738,7 +1739,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)

int acpi_processor_cst_has_changed(struct acpi_processor *pr)
{
int ret;
int ret = 0;

if (boot_option_idle_override)
return 0;
Expand All @@ -1756,8 +1757,10 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
cpuidle_pause_and_lock();
cpuidle_disable_device(&pr->power.dev);
acpi_processor_get_power_info(pr);
acpi_processor_setup_cpuidle(pr);
ret = cpuidle_enable_device(&pr->power.dev);
if (pr->flags.power) {
acpi_processor_setup_cpuidle(pr);
ret = cpuidle_enable_device(&pr->power.dev);
}
cpuidle_resume_and_unlock();

return ret;
Expand Down Expand Up @@ -1813,7 +1816,6 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
if (pr->flags.power) {
#ifdef CONFIG_CPU_IDLE
acpi_processor_setup_cpuidle(pr);
pr->power.dev.cpu = pr->id;
if (cpuidle_register_device(&pr->power.dev))
return -EIO;
#endif
Expand Down Expand Up @@ -1850,8 +1852,7 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
return 0;

#ifdef CONFIG_CPU_IDLE
if (pr->flags.power)
cpuidle_unregister_device(&pr->power.dev);
cpuidle_unregister_device(&pr->power.dev);
#endif
pr->flags.power_setup_done = 0;

Expand Down
40 changes: 35 additions & 5 deletions trunk/drivers/cpuidle/cpuidle.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ static void cpuidle_kick_cpus(void)
static void cpuidle_kick_cpus(void) {}
#endif

static int __cpuidle_register_device(struct cpuidle_device *dev);

/**
* cpuidle_idle_call - the main idle loop
*
Expand Down Expand Up @@ -138,6 +140,12 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
if (!dev->state_count)
return -EINVAL;

if (dev->registered == 0) {
ret = __cpuidle_register_device(dev);
if (ret)
return ret;
}

if ((ret = cpuidle_add_state_sysfs(dev)))
return ret;

Expand Down Expand Up @@ -232,10 +240,13 @@ static void poll_idle_init(struct cpuidle_device *dev) {}
#endif /* CONFIG_ARCH_HAS_CPU_RELAX */

/**
* cpuidle_register_device - registers a CPU's idle PM feature
* __cpuidle_register_device - internal register function called before register
* and enable routines
* @dev: the cpu
*
* cpuidle_lock mutex must be held before this is called
*/
int cpuidle_register_device(struct cpuidle_device *dev)
static int __cpuidle_register_device(struct cpuidle_device *dev)
{
int ret;
struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
Expand All @@ -247,18 +258,34 @@ int cpuidle_register_device(struct cpuidle_device *dev)

init_completion(&dev->kobj_unregister);

mutex_lock(&cpuidle_lock);

poll_idle_init(dev);

per_cpu(cpuidle_devices, dev->cpu) = dev;
list_add(&dev->device_list, &cpuidle_detected_devices);
if ((ret = cpuidle_add_sysfs(sys_dev))) {
mutex_unlock(&cpuidle_lock);
module_put(cpuidle_curr_driver->owner);
return ret;
}

dev->registered = 1;
return 0;
}

/**
* cpuidle_register_device - registers a CPU's idle PM feature
* @dev: the cpu
*/
int cpuidle_register_device(struct cpuidle_device *dev)
{
int ret;

mutex_lock(&cpuidle_lock);

if ((ret = __cpuidle_register_device(dev))) {
mutex_unlock(&cpuidle_lock);
return ret;
}

cpuidle_enable_device(dev);
cpuidle_install_idle_handler();

Expand All @@ -278,6 +305,9 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
{
struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);

if (dev->registered == 0)
return;

cpuidle_pause_and_lock();

cpuidle_disable_device(dev);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/cpuidle.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct cpuidle_state_kobj {
};

struct cpuidle_device {
unsigned int registered:1;
unsigned int enabled:1;
unsigned int cpu;

Expand Down

0 comments on commit e035528

Please sign in to comment.