diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-12-15 19:09:11 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-12-15 19:09:11 -0500 |
commit | e6f08d37e6641b38b2da4ad40d6ca2cfb616a1dc (patch) | |
tree | f6fbe6e761e72c972d6dc271cec087e870f6e033 /arch/powerpc/platforms | |
parent | 7c637b04fba553897f0de77d185e5263b06df06f (diff) | |
parent | e8bb3e00cff93ef2a0cfc09c3294aa37b4737e09 (diff) |
Merge branch 'cpuidle' into next
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/Kconfig | 6 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/Kconfig | 9 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/Makefile | 1 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/processor_idle.c | 329 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/pseries.h | 3 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/setup.c | 104 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/smp.c | 1 |
7 files changed, 366 insertions, 87 deletions
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig index 3fe6d927ad70..31e1adeaa92a 100644 --- a/arch/powerpc/platforms/Kconfig +++ b/arch/powerpc/platforms/Kconfig | |||
@@ -211,6 +211,12 @@ config PPC_PASEMI_CPUFREQ | |||
211 | 211 | ||
212 | endmenu | 212 | endmenu |
213 | 213 | ||
214 | menu "CPUIdle driver" | ||
215 | |||
216 | source "drivers/cpuidle/Kconfig" | ||
217 | |||
218 | endmenu | ||
219 | |||
214 | config PPC601_SYNC_FIX | 220 | config PPC601_SYNC_FIX |
215 | bool "Workarounds for PPC601 bugs" | 221 | bool "Workarounds for PPC601 bugs" |
216 | depends on 6xx && (PPC_PREP || PPC_PMAC) | 222 | depends on 6xx && (PPC_PREP || PPC_PMAC) |
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index c81f6bb9c10f..ae7b6d41fed3 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig | |||
@@ -120,3 +120,12 @@ config DTL | |||
120 | which are accessible through a debugfs file. | 120 | which are accessible through a debugfs file. |
121 | 121 | ||
122 | Say N if you are unsure. | 122 | Say N if you are unsure. |
123 | |||
124 | config PSERIES_IDLE | ||
125 | tristate "Cpuidle driver for pSeries platforms" | ||
126 | depends on CPU_IDLE | ||
127 | depends on PPC_PSERIES | ||
128 | default y | ||
129 | help | ||
130 | Select this option to enable processor idle state management | ||
131 | through cpuidle subsystem. | ||
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 3556e402cbf5..236db46b4078 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile | |||
@@ -22,6 +22,7 @@ obj-$(CONFIG_PHYP_DUMP) += phyp_dump.o | |||
22 | obj-$(CONFIG_CMM) += cmm.o | 22 | obj-$(CONFIG_CMM) += cmm.o |
23 | obj-$(CONFIG_DTL) += dtl.o | 23 | obj-$(CONFIG_DTL) += dtl.o |
24 | obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o | 24 | obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o |
25 | obj-$(CONFIG_PSERIES_IDLE) += processor_idle.o | ||
25 | 26 | ||
26 | ifeq ($(CONFIG_PPC_PSERIES),y) | 27 | ifeq ($(CONFIG_PPC_PSERIES),y) |
27 | obj-$(CONFIG_SUSPEND) += suspend.o | 28 | obj-$(CONFIG_SUSPEND) += suspend.o |
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c new file mode 100644 index 000000000000..085fd3f45ad2 --- /dev/null +++ b/arch/powerpc/platforms/pseries/processor_idle.c | |||
@@ -0,0 +1,329 @@ | |||
1 | /* | ||
2 | * processor_idle - idle state cpuidle driver. | ||
3 | * Adapted from drivers/idle/intel_idle.c and | ||
4 | * drivers/acpi/processor_idle.c | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/moduleparam.h> | ||
12 | #include <linux/cpuidle.h> | ||
13 | #include <linux/cpu.h> | ||
14 | |||
15 | #include <asm/paca.h> | ||
16 | #include <asm/reg.h> | ||
17 | #include <asm/system.h> | ||
18 | #include <asm/machdep.h> | ||
19 | #include <asm/firmware.h> | ||
20 | |||
21 | #include "plpar_wrappers.h" | ||
22 | #include "pseries.h" | ||
23 | |||
24 | struct cpuidle_driver pseries_idle_driver = { | ||
25 | .name = "pseries_idle", | ||
26 | .owner = THIS_MODULE, | ||
27 | }; | ||
28 | |||
29 | #define MAX_IDLE_STATE_COUNT 2 | ||
30 | |||
31 | static int max_idle_state = MAX_IDLE_STATE_COUNT - 1; | ||
32 | static struct cpuidle_device __percpu *pseries_cpuidle_devices; | ||
33 | static struct cpuidle_state *cpuidle_state_table; | ||
34 | |||
35 | void update_smt_snooze_delay(int snooze) | ||
36 | { | ||
37 | struct cpuidle_driver *drv = cpuidle_get_driver(); | ||
38 | if (drv) | ||
39 | drv->states[0].target_residency = snooze; | ||
40 | } | ||
41 | |||
42 | static inline void idle_loop_prolog(unsigned long *in_purr, ktime_t *kt_before) | ||
43 | { | ||
44 | |||
45 | *kt_before = ktime_get_real(); | ||
46 | *in_purr = mfspr(SPRN_PURR); | ||
47 | /* | ||
48 | * Indicate to the HV that we are idle. Now would be | ||
49 | * a good time to find other work to dispatch. | ||
50 | */ | ||
51 | get_lppaca()->idle = 1; | ||
52 | } | ||
53 | |||
54 | static inline s64 idle_loop_epilog(unsigned long in_purr, ktime_t kt_before) | ||
55 | { | ||
56 | get_lppaca()->wait_state_cycles += mfspr(SPRN_PURR) - in_purr; | ||
57 | get_lppaca()->idle = 0; | ||
58 | |||
59 | return ktime_to_us(ktime_sub(ktime_get_real(), kt_before)); | ||
60 | } | ||
61 | |||
62 | static int snooze_loop(struct cpuidle_device *dev, | ||
63 | struct cpuidle_driver *drv, | ||
64 | int index) | ||
65 | { | ||
66 | unsigned long in_purr; | ||
67 | ktime_t kt_before; | ||
68 | unsigned long start_snooze; | ||
69 | long snooze = drv->states[0].target_residency; | ||
70 | |||
71 | idle_loop_prolog(&in_purr, &kt_before); | ||
72 | |||
73 | if (snooze) { | ||
74 | start_snooze = get_tb() + snooze * tb_ticks_per_usec; | ||
75 | local_irq_enable(); | ||
76 | set_thread_flag(TIF_POLLING_NRFLAG); | ||
77 | |||
78 | while ((snooze < 0) || (get_tb() < start_snooze)) { | ||
79 | if (need_resched() || cpu_is_offline(dev->cpu)) | ||
80 | goto out; | ||
81 | ppc64_runlatch_off(); | ||
82 | HMT_low(); | ||
83 | HMT_very_low(); | ||
84 | } | ||
85 | |||
86 | HMT_medium(); | ||
87 | clear_thread_flag(TIF_POLLING_NRFLAG); | ||
88 | smp_mb(); | ||
89 | local_irq_disable(); | ||
90 | } | ||
91 | |||
92 | out: | ||
93 | HMT_medium(); | ||
94 | dev->last_residency = | ||
95 | (int)idle_loop_epilog(in_purr, kt_before); | ||
96 | return index; | ||
97 | } | ||
98 | |||
99 | static int dedicated_cede_loop(struct cpuidle_device *dev, | ||
100 | struct cpuidle_driver *drv, | ||
101 | int index) | ||
102 | { | ||
103 | unsigned long in_purr; | ||
104 | ktime_t kt_before; | ||
105 | |||
106 | idle_loop_prolog(&in_purr, &kt_before); | ||
107 | get_lppaca()->donate_dedicated_cpu = 1; | ||
108 | |||
109 | ppc64_runlatch_off(); | ||
110 | HMT_medium(); | ||
111 | cede_processor(); | ||
112 | |||
113 | get_lppaca()->donate_dedicated_cpu = 0; | ||
114 | dev->last_residency = | ||
115 | (int)idle_loop_epilog(in_purr, kt_before); | ||
116 | return index; | ||
117 | } | ||
118 | |||
119 | static int shared_cede_loop(struct cpuidle_device *dev, | ||
120 | struct cpuidle_driver *drv, | ||
121 | int index) | ||
122 | { | ||
123 | unsigned long in_purr; | ||
124 | ktime_t kt_before; | ||
125 | |||
126 | idle_loop_prolog(&in_purr, &kt_before); | ||
127 | |||
128 | /* | ||
129 | * Yield the processor to the hypervisor. We return if | ||
130 | * an external interrupt occurs (which are driven prior | ||
131 | * to returning here) or if a prod occurs from another | ||
132 | * processor. When returning here, external interrupts | ||
133 | * are enabled. | ||
134 | */ | ||
135 | cede_processor(); | ||
136 | |||
137 | dev->last_residency = | ||
138 | (int)idle_loop_epilog(in_purr, kt_before); | ||
139 | return index; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * States for dedicated partition case. | ||
144 | */ | ||
145 | static struct cpuidle_state dedicated_states[MAX_IDLE_STATE_COUNT] = { | ||
146 | { /* Snooze */ | ||
147 | .name = "snooze", | ||
148 | .desc = "snooze", | ||
149 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
150 | .exit_latency = 0, | ||
151 | .target_residency = 0, | ||
152 | .enter = &snooze_loop }, | ||
153 | { /* CEDE */ | ||
154 | .name = "CEDE", | ||
155 | .desc = "CEDE", | ||
156 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
157 | .exit_latency = 1, | ||
158 | .target_residency = 10, | ||
159 | .enter = &dedicated_cede_loop }, | ||
160 | }; | ||
161 | |||
162 | /* | ||
163 | * States for shared partition case. | ||
164 | */ | ||
165 | static struct cpuidle_state shared_states[MAX_IDLE_STATE_COUNT] = { | ||
166 | { /* Shared Cede */ | ||
167 | .name = "Shared Cede", | ||
168 | .desc = "Shared Cede", | ||
169 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
170 | .exit_latency = 0, | ||
171 | .target_residency = 0, | ||
172 | .enter = &shared_cede_loop }, | ||
173 | }; | ||
174 | |||
175 | int pseries_notify_cpuidle_add_cpu(int cpu) | ||
176 | { | ||
177 | struct cpuidle_device *dev = | ||
178 | per_cpu_ptr(pseries_cpuidle_devices, cpu); | ||
179 | if (dev && cpuidle_get_driver()) { | ||
180 | cpuidle_disable_device(dev); | ||
181 | cpuidle_enable_device(dev); | ||
182 | } | ||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | /* | ||
187 | * pseries_cpuidle_driver_init() | ||
188 | */ | ||
189 | static int pseries_cpuidle_driver_init(void) | ||
190 | { | ||
191 | int idle_state; | ||
192 | struct cpuidle_driver *drv = &pseries_idle_driver; | ||
193 | |||
194 | drv->state_count = 0; | ||
195 | |||
196 | for (idle_state = 0; idle_state < MAX_IDLE_STATE_COUNT; ++idle_state) { | ||
197 | |||
198 | if (idle_state > max_idle_state) | ||
199 | break; | ||
200 | |||
201 | /* is the state not enabled? */ | ||
202 | if (cpuidle_state_table[idle_state].enter == NULL) | ||
203 | continue; | ||
204 | |||
205 | drv->states[drv->state_count] = /* structure copy */ | ||
206 | cpuidle_state_table[idle_state]; | ||
207 | |||
208 | if (cpuidle_state_table == dedicated_states) | ||
209 | drv->states[drv->state_count].target_residency = | ||
210 | __get_cpu_var(smt_snooze_delay); | ||
211 | |||
212 | drv->state_count += 1; | ||
213 | } | ||
214 | |||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | /* pseries_idle_devices_uninit(void) | ||
219 | * unregister cpuidle devices and de-allocate memory | ||
220 | */ | ||
221 | static void pseries_idle_devices_uninit(void) | ||
222 | { | ||
223 | int i; | ||
224 | struct cpuidle_device *dev; | ||
225 | |||
226 | for_each_possible_cpu(i) { | ||
227 | dev = per_cpu_ptr(pseries_cpuidle_devices, i); | ||
228 | cpuidle_unregister_device(dev); | ||
229 | } | ||
230 | |||
231 | free_percpu(pseries_cpuidle_devices); | ||
232 | return; | ||
233 | } | ||
234 | |||
235 | /* pseries_idle_devices_init() | ||
236 | * allocate, initialize and register cpuidle device | ||
237 | */ | ||
238 | static int pseries_idle_devices_init(void) | ||
239 | { | ||
240 | int i; | ||
241 | struct cpuidle_driver *drv = &pseries_idle_driver; | ||
242 | struct cpuidle_device *dev; | ||
243 | |||
244 | pseries_cpuidle_devices = alloc_percpu(struct cpuidle_device); | ||
245 | if (pseries_cpuidle_devices == NULL) | ||
246 | return -ENOMEM; | ||
247 | |||
248 | for_each_possible_cpu(i) { | ||
249 | dev = per_cpu_ptr(pseries_cpuidle_devices, i); | ||
250 | dev->state_count = drv->state_count; | ||
251 | dev->cpu = i; | ||
252 | if (cpuidle_register_device(dev)) { | ||
253 | printk(KERN_DEBUG \ | ||
254 | "cpuidle_register_device %d failed!\n", i); | ||
255 | return -EIO; | ||
256 | } | ||
257 | } | ||
258 | |||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | /* | ||
263 | * pseries_idle_probe() | ||
264 | * Choose state table for shared versus dedicated partition | ||
265 | */ | ||
266 | static int pseries_idle_probe(void) | ||
267 | { | ||
268 | |||
269 | if (!firmware_has_feature(FW_FEATURE_SPLPAR)) | ||
270 | return -ENODEV; | ||
271 | |||
272 | if (cpuidle_disable != IDLE_NO_OVERRIDE) | ||
273 | return -ENODEV; | ||
274 | |||
275 | if (max_idle_state == 0) { | ||
276 | printk(KERN_DEBUG "pseries processor idle disabled.\n"); | ||
277 | return -EPERM; | ||
278 | } | ||
279 | |||
280 | if (get_lppaca()->shared_proc) | ||
281 | cpuidle_state_table = shared_states; | ||
282 | else | ||
283 | cpuidle_state_table = dedicated_states; | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static int __init pseries_processor_idle_init(void) | ||
289 | { | ||
290 | int retval; | ||
291 | |||
292 | retval = pseries_idle_probe(); | ||
293 | if (retval) | ||
294 | return retval; | ||
295 | |||
296 | pseries_cpuidle_driver_init(); | ||
297 | retval = cpuidle_register_driver(&pseries_idle_driver); | ||
298 | if (retval) { | ||
299 | printk(KERN_DEBUG "Registration of pseries driver failed.\n"); | ||
300 | return retval; | ||
301 | } | ||
302 | |||
303 | retval = pseries_idle_devices_init(); | ||
304 | if (retval) { | ||
305 | pseries_idle_devices_uninit(); | ||
306 | cpuidle_unregister_driver(&pseries_idle_driver); | ||
307 | return retval; | ||
308 | } | ||
309 | |||
310 | printk(KERN_DEBUG "pseries_idle_driver registered\n"); | ||
311 | |||
312 | return 0; | ||
313 | } | ||
314 | |||
315 | static void __exit pseries_processor_idle_exit(void) | ||
316 | { | ||
317 | |||
318 | pseries_idle_devices_uninit(); | ||
319 | cpuidle_unregister_driver(&pseries_idle_driver); | ||
320 | |||
321 | return; | ||
322 | } | ||
323 | |||
324 | module_init(pseries_processor_idle_init); | ||
325 | module_exit(pseries_processor_idle_exit); | ||
326 | |||
327 | MODULE_AUTHOR("Deepthi Dharwar <deepthi@linux.vnet.ibm.com>"); | ||
328 | MODULE_DESCRIPTION("Cpuidle driver for POWER"); | ||
329 | MODULE_LICENSE("GPL"); | ||
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h index 24c7162f11d9..9a3dda07566f 100644 --- a/arch/powerpc/platforms/pseries/pseries.h +++ b/arch/powerpc/platforms/pseries/pseries.h | |||
@@ -57,4 +57,7 @@ extern struct device_node *dlpar_configure_connector(u32); | |||
57 | extern int dlpar_attach_node(struct device_node *); | 57 | extern int dlpar_attach_node(struct device_node *); |
58 | extern int dlpar_detach_node(struct device_node *); | 58 | extern int dlpar_detach_node(struct device_node *); |
59 | 59 | ||
60 | /* Snooze Delay, pseries_idle */ | ||
61 | DECLARE_PER_CPU(long, smt_snooze_delay); | ||
62 | |||
60 | #endif /* _PSERIES_PSERIES_H */ | 63 | #endif /* _PSERIES_PSERIES_H */ |
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 01df08dbc43c..164839cb9fcd 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/irq.h> | 39 | #include <linux/irq.h> |
40 | #include <linux/seq_file.h> | 40 | #include <linux/seq_file.h> |
41 | #include <linux/root_dev.h> | 41 | #include <linux/root_dev.h> |
42 | #include <linux/cpuidle.h> | ||
42 | 43 | ||
43 | #include <asm/mmu.h> | 44 | #include <asm/mmu.h> |
44 | #include <asm/processor.h> | 45 | #include <asm/processor.h> |
@@ -74,9 +75,6 @@ EXPORT_SYMBOL(CMO_PageSize); | |||
74 | 75 | ||
75 | int fwnmi_active; /* TRUE if an FWNMI handler is present */ | 76 | int fwnmi_active; /* TRUE if an FWNMI handler is present */ |
76 | 77 | ||
77 | static void pseries_shared_idle_sleep(void); | ||
78 | static void pseries_dedicated_idle_sleep(void); | ||
79 | |||
80 | static struct device_node *pSeries_mpic_node; | 78 | static struct device_node *pSeries_mpic_node; |
81 | 79 | ||
82 | static void pSeries_show_cpuinfo(struct seq_file *m) | 80 | static void pSeries_show_cpuinfo(struct seq_file *m) |
@@ -351,6 +349,21 @@ static int alloc_dispatch_log_kmem_cache(void) | |||
351 | } | 349 | } |
352 | early_initcall(alloc_dispatch_log_kmem_cache); | 350 | early_initcall(alloc_dispatch_log_kmem_cache); |
353 | 351 | ||
352 | static void pSeries_idle(void) | ||
353 | { | ||
354 | /* This would call on the cpuidle framework, and the back-end pseries | ||
355 | * driver to go to idle states | ||
356 | */ | ||
357 | if (cpuidle_idle_call()) { | ||
358 | /* On error, execute default handler | ||
359 | * to go into low thread priority and possibly | ||
360 | * low power mode. | ||
361 | */ | ||
362 | HMT_low(); | ||
363 | HMT_very_low(); | ||
364 | } | ||
365 | } | ||
366 | |||
354 | static void __init pSeries_setup_arch(void) | 367 | static void __init pSeries_setup_arch(void) |
355 | { | 368 | { |
356 | /* Discover PIC type and setup ppc_md accordingly */ | 369 | /* Discover PIC type and setup ppc_md accordingly */ |
@@ -373,18 +386,9 @@ static void __init pSeries_setup_arch(void) | |||
373 | 386 | ||
374 | pSeries_nvram_init(); | 387 | pSeries_nvram_init(); |
375 | 388 | ||
376 | /* Choose an idle loop */ | ||
377 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { | 389 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { |
378 | vpa_init(boot_cpuid); | 390 | vpa_init(boot_cpuid); |
379 | if (get_lppaca()->shared_proc) { | 391 | ppc_md.power_save = pSeries_idle; |
380 | printk(KERN_DEBUG "Using shared processor idle loop\n"); | ||
381 | ppc_md.power_save = pseries_shared_idle_sleep; | ||
382 | } else { | ||
383 | printk(KERN_DEBUG "Using dedicated idle loop\n"); | ||
384 | ppc_md.power_save = pseries_dedicated_idle_sleep; | ||
385 | } | ||
386 | } else { | ||
387 | printk(KERN_DEBUG "Using default idle loop\n"); | ||
388 | } | 392 | } |
389 | 393 | ||
390 | if (firmware_has_feature(FW_FEATURE_LPAR)) | 394 | if (firmware_has_feature(FW_FEATURE_LPAR)) |
@@ -585,80 +589,6 @@ static int __init pSeries_probe(void) | |||
585 | return 1; | 589 | return 1; |
586 | } | 590 | } |
587 | 591 | ||
588 | |||
589 | DECLARE_PER_CPU(long, smt_snooze_delay); | ||
590 | |||
591 | static void pseries_dedicated_idle_sleep(void) | ||
592 | { | ||
593 | unsigned int cpu = smp_processor_id(); | ||
594 | unsigned long start_snooze; | ||
595 | unsigned long in_purr, out_purr; | ||
596 | long snooze = __get_cpu_var(smt_snooze_delay); | ||
597 | |||
598 | /* | ||
599 | * Indicate to the HV that we are idle. Now would be | ||
600 | * a good time to find other work to dispatch. | ||
601 | */ | ||
602 | get_lppaca()->idle = 1; | ||
603 | get_lppaca()->donate_dedicated_cpu = 1; | ||
604 | in_purr = mfspr(SPRN_PURR); | ||
605 | |||
606 | /* | ||
607 | * We come in with interrupts disabled, and need_resched() | ||
608 | * has been checked recently. If we should poll for a little | ||
609 | * while, do so. | ||
610 | */ | ||
611 | if (snooze) { | ||
612 | start_snooze = get_tb() + snooze * tb_ticks_per_usec; | ||
613 | local_irq_enable(); | ||
614 | set_thread_flag(TIF_POLLING_NRFLAG); | ||
615 | |||
616 | while ((snooze < 0) || (get_tb() < start_snooze)) { | ||
617 | if (need_resched() || cpu_is_offline(cpu)) | ||
618 | goto out; | ||
619 | ppc64_runlatch_off(); | ||
620 | HMT_low(); | ||
621 | HMT_very_low(); | ||
622 | } | ||
623 | |||
624 | HMT_medium(); | ||
625 | clear_thread_flag(TIF_POLLING_NRFLAG); | ||
626 | smp_mb(); | ||
627 | local_irq_disable(); | ||
628 | if (need_resched() || cpu_is_offline(cpu)) | ||
629 | goto out; | ||
630 | } | ||
631 | |||
632 | cede_processor(); | ||
633 | |||
634 | out: | ||
635 | HMT_medium(); | ||
636 | out_purr = mfspr(SPRN_PURR); | ||
637 | get_lppaca()->wait_state_cycles += out_purr - in_purr; | ||
638 | get_lppaca()->donate_dedicated_cpu = 0; | ||
639 | get_lppaca()->idle = 0; | ||
640 | } | ||
641 | |||
642 | static void pseries_shared_idle_sleep(void) | ||
643 | { | ||
644 | /* | ||
645 | * Indicate to the HV that we are idle. Now would be | ||
646 | * a good time to find other work to dispatch. | ||
647 | */ | ||
648 | get_lppaca()->idle = 1; | ||
649 | |||
650 | /* | ||
651 | * Yield the processor to the hypervisor. We return if | ||
652 | * an external interrupt occurs (which are driven prior | ||
653 | * to returning here) or if a prod occurs from another | ||
654 | * processor. When returning here, external interrupts | ||
655 | * are enabled. | ||
656 | */ | ||
657 | cede_processor(); | ||
658 | |||
659 | get_lppaca()->idle = 0; | ||
660 | } | ||
661 | |||
662 | static int pSeries_pci_probe_mode(struct pci_bus *bus) | 592 | static int pSeries_pci_probe_mode(struct pci_bus *bus) |
663 | { | 593 | { |
664 | if (firmware_has_feature(FW_FEATURE_LPAR)) | 594 | if (firmware_has_feature(FW_FEATURE_LPAR)) |
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c index 26e93fd4c62b..bbc3c42f6730 100644 --- a/arch/powerpc/platforms/pseries/smp.c +++ b/arch/powerpc/platforms/pseries/smp.c | |||
@@ -148,6 +148,7 @@ static void __devinit smp_xics_setup_cpu(int cpu) | |||
148 | set_cpu_current_state(cpu, CPU_STATE_ONLINE); | 148 | set_cpu_current_state(cpu, CPU_STATE_ONLINE); |
149 | set_default_offline_state(cpu); | 149 | set_default_offline_state(cpu); |
150 | #endif | 150 | #endif |
151 | pseries_notify_cpuidle_add_cpu(cpu); | ||
151 | } | 152 | } |
152 | 153 | ||
153 | static int __devinit smp_pSeries_kick_cpu(int nr) | 154 | static int __devinit smp_pSeries_kick_cpu(int nr) |