aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2016-08-24 05:12:59 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-09-06 12:30:24 -0400
commit10fcca9d8704a04c6e86398f930fa28e0fb03ce4 (patch)
tree53c611d556352f4240ec81ad4f3e476bb9efd75d
parent529351fd3c50215a462e5e604d7ceaaf27a8a0e5 (diff)
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: Sebastian 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.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--drivers/cpuidle/cpuidle-powernv.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index f7ca891b5b59..7fe442ca38f4 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -119,40 +119,30 @@ static struct cpuidle_state powernv_states[CPUIDLE_STATE_MAX] = {
119 .enter = snooze_loop }, 119 .enter = snooze_loop },
120}; 120};
121 121
122static int powernv_cpuidle_add_cpu_notifier(struct notifier_block *n, 122static int powernv_cpuidle_cpu_online(unsigned int cpu)
123 unsigned long action, void *hcpu)
124{ 123{
125 int hotcpu = (unsigned long)hcpu; 124 struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
126 struct cpuidle_device *dev =
127 per_cpu(cpuidle_devices, hotcpu);
128 125
129 if (dev && cpuidle_get_driver()) { 126 if (dev && cpuidle_get_driver()) {
130 switch (action) { 127 cpuidle_pause_and_lock();
131 case CPU_ONLINE: 128 cpuidle_enable_device(dev);
132 case CPU_ONLINE_FROZEN: 129 cpuidle_resume_and_unlock();
133 cpuidle_pause_and_lock(); 130 }
134 cpuidle_enable_device(dev); 131 return 0;
135 cpuidle_resume_and_unlock(); 132}
136 break;
137 133
138 case CPU_DEAD: 134static int powernv_cpuidle_cpu_dead(unsigned int cpu)
139 case CPU_DEAD_FROZEN: 135{
140 cpuidle_pause_and_lock(); 136 struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
141 cpuidle_disable_device(dev);
142 cpuidle_resume_and_unlock();
143 break;
144 137
145 default: 138 if (dev && cpuidle_get_driver()) {
146 return NOTIFY_DONE; 139 cpuidle_pause_and_lock();
147 } 140 cpuidle_disable_device(dev);
141 cpuidle_resume_and_unlock();
148 } 142 }
149 return NOTIFY_OK; 143 return 0;
150} 144}
151 145
152static struct notifier_block setup_hotplug_notifier = {
153 .notifier_call = powernv_cpuidle_add_cpu_notifier,
154};
155
156/* 146/*
157 * powernv_cpuidle_driver_init() 147 * powernv_cpuidle_driver_init()
158 */ 148 */
@@ -355,7 +345,14 @@ static int __init powernv_processor_idle_init(void)
355 return retval; 345 return retval;
356 } 346 }
357 347
358 register_cpu_notifier(&setup_hotplug_notifier); 348 retval = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
349 "cpuidle/powernv:online",
350 powernv_cpuidle_cpu_online, NULL);
351 WARN_ON(retval < 0);
352 retval = cpuhp_setup_state_nocalls(CPUHP_CPUIDLE_DEAD,
353 "cpuidle/powernv:dead", NULL,
354 powernv_cpuidle_cpu_dead);
355 WARN_ON(retval < 0);
359 printk(KERN_DEBUG "powernv_idle_driver registered\n"); 356 printk(KERN_DEBUG "powernv_idle_driver registered\n");
360 return 0; 357 return 0;
361} 358}