Commit 10fcca9d authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Thomas Gleixner

cpuidle/powernv: Convert to hotplug state machine

Install the callbacks via the state machine.

v1…v2: - Use only CPUHP_CPUIDLE_DEAD (requested by Daniel Lezcano)
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-pm@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160824091259.ozyslcopxvbfdqzy@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 529351fd
...@@ -119,40 +119,30 @@ static struct cpuidle_state powernv_states[CPUIDLE_STATE_MAX] = { ...@@ -119,40 +119,30 @@ static struct cpuidle_state powernv_states[CPUIDLE_STATE_MAX] = {
.enter = snooze_loop }, .enter = snooze_loop },
}; };
static int powernv_cpuidle_add_cpu_notifier(struct notifier_block *n, static int powernv_cpuidle_cpu_online(unsigned int cpu)
unsigned long action, void *hcpu)
{ {
int hotcpu = (unsigned long)hcpu; struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
struct cpuidle_device *dev =
per_cpu(cpuidle_devices, hotcpu);
if (dev && cpuidle_get_driver()) { if (dev && cpuidle_get_driver()) {
switch (action) { cpuidle_pause_and_lock();
case CPU_ONLINE: cpuidle_enable_device(dev);
case CPU_ONLINE_FROZEN: cpuidle_resume_and_unlock();
cpuidle_pause_and_lock(); }
cpuidle_enable_device(dev); return 0;
cpuidle_resume_and_unlock(); }
break;
case CPU_DEAD: static int powernv_cpuidle_cpu_dead(unsigned int cpu)
case CPU_DEAD_FROZEN: {
cpuidle_pause_and_lock(); struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
cpuidle_disable_device(dev);
cpuidle_resume_and_unlock();
break;
default: if (dev && cpuidle_get_driver()) {
return NOTIFY_DONE; cpuidle_pause_and_lock();
} cpuidle_disable_device(dev);
cpuidle_resume_and_unlock();
} }
return NOTIFY_OK; return 0;
} }
static struct notifier_block setup_hotplug_notifier = {
.notifier_call = powernv_cpuidle_add_cpu_notifier,
};
/* /*
* powernv_cpuidle_driver_init() * powernv_cpuidle_driver_init()
*/ */
...@@ -355,7 +345,14 @@ static int __init powernv_processor_idle_init(void) ...@@ -355,7 +345,14 @@ static int __init powernv_processor_idle_init(void)
return retval; return retval;
} }
register_cpu_notifier(&setup_hotplug_notifier); retval = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
"cpuidle/powernv:online",
powernv_cpuidle_cpu_online, NULL);
WARN_ON(retval < 0);
retval = cpuhp_setup_state_nocalls(CPUHP_CPUIDLE_DEAD,
"cpuidle/powernv:dead", NULL,
powernv_cpuidle_cpu_dead);
WARN_ON(retval < 0);
printk(KERN_DEBUG "powernv_idle_driver registered\n"); printk(KERN_DEBUG "powernv_idle_driver registered\n");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment