Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pseries/cpuidle: Move processor_idle.c to drivers/cpuidle.

Move the file from arch specific pseries/processor_idle.c
to drivers/cpuidle/cpuidle-pseries.c
Make the relevant Makefile and Kconfig changes.
Also, introduce Kconfig.powerpc in drivers/cpuidle
for all powerpc cpuidle drivers.

Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Deepthi Dharwar and committed by
Benjamin Herrenschmidt
962e7bd4 d765ff23

+78 -15
+1 -1
arch/powerpc/include/asm/processor.h
··· 451 451 extern int powersave_nap; /* set if nap mode can be used in idle loop */ 452 452 extern void power7_nap(void); 453 453 454 - #ifdef CONFIG_PSERIES_IDLE 454 + #ifdef CONFIG_PSERIES_CPUIDLE 455 455 extern void update_smt_snooze_delay(int cpu, int residency); 456 456 #else 457 457 static inline void update_smt_snooze_delay(int cpu, int residency) {}
-9
arch/powerpc/platforms/pseries/Kconfig
··· 119 119 which are accessible through a debugfs file. 120 120 121 121 Say N if you are unsure. 122 - 123 - config PSERIES_IDLE 124 - bool "Cpuidle driver for pSeries platforms" 125 - depends on CPU_IDLE 126 - depends on PPC_PSERIES 127 - default y 128 - help 129 - Select this option to enable processor idle state management 130 - through cpuidle subsystem.
-1
arch/powerpc/platforms/pseries/Makefile
··· 21 21 obj-$(CONFIG_CMM) += cmm.o 22 22 obj-$(CONFIG_DTL) += dtl.o 23 23 obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o 24 - obj-$(CONFIG_PSERIES_IDLE) += processor_idle.o 25 24 obj-$(CONFIG_LPARCFG) += lparcfg.o 26 25 27 26 ifeq ($(CONFIG_PPC_PSERIES),y)
+57 -4
arch/powerpc/platforms/pseries/processor_idle.c drivers/cpuidle/cpuidle-pseries.c
··· 1 1 /* 2 - * processor_idle - idle state cpuidle driver. 2 + * cpuidle-pseries - idle state cpuidle driver. 3 3 * Adapted from drivers/idle/intel_idle.c and 4 4 * drivers/acpi/processor_idle.c 5 5 * ··· 27 27 #define MAX_IDLE_STATE_COUNT 2 28 28 29 29 static int max_idle_state = MAX_IDLE_STATE_COUNT - 1; 30 + static struct cpuidle_device __percpu *pseries_cpuidle_devices; 30 31 static struct cpuidle_state *cpuidle_state_table; 31 32 32 33 static inline void idle_loop_prolog(unsigned long *in_purr) ··· 188 187 { 189 188 int hotcpu = (unsigned long)hcpu; 190 189 struct cpuidle_device *dev = 191 - per_cpu_ptr(cpuidle_devices, hotcpu); 190 + per_cpu_ptr(pseries_cpuidle_devices, hotcpu); 192 191 193 192 if (dev && cpuidle_get_driver()) { 194 193 switch (action) { ··· 245 244 return 0; 246 245 } 247 246 247 + /* pseries_idle_devices_uninit(void) 248 + * unregister cpuidle devices and de-allocate memory 249 + */ 250 + static void pseries_idle_devices_uninit(void) 251 + { 252 + int i; 253 + struct cpuidle_device *dev; 254 + 255 + for_each_possible_cpu(i) { 256 + dev = per_cpu_ptr(pseries_cpuidle_devices, i); 257 + cpuidle_unregister_device(dev); 258 + } 259 + 260 + free_percpu(pseries_cpuidle_devices); 261 + return; 262 + } 263 + 264 + /* pseries_idle_devices_init() 265 + * allocate, initialize and register cpuidle device 266 + */ 267 + static int pseries_idle_devices_init(void) 268 + { 269 + int i; 270 + struct cpuidle_driver *drv = &pseries_idle_driver; 271 + struct cpuidle_device *dev; 272 + 273 + pseries_cpuidle_devices = alloc_percpu(struct cpuidle_device); 274 + if (pseries_cpuidle_devices == NULL) 275 + return -ENOMEM; 276 + 277 + for_each_possible_cpu(i) { 278 + dev = per_cpu_ptr(pseries_cpuidle_devices, i); 279 + dev->state_count = drv->state_count; 280 + dev->cpu = i; 281 + if (cpuidle_register_device(dev)) { 282 + printk(KERN_DEBUG \ 283 + "cpuidle_register_device %d failed!\n", i); 284 + return -EIO; 285 + } 286 + } 287 + 288 + return 0; 289 + } 290 + 248 291 /* 249 292 * pseries_idle_probe() 250 293 * Choose state table for shared versus dedicated partition ··· 324 279 return retval; 325 280 326 281 pseries_cpuidle_driver_init(); 327 - retval = cpuidle_register(&pseries_idle_driver, NULL); 282 + retval = cpuidle_register_driver(&pseries_idle_driver); 328 283 if (retval) { 329 284 printk(KERN_DEBUG "Registration of pseries driver failed.\n"); 285 + return retval; 286 + } 287 + 288 + retval = pseries_idle_devices_init(); 289 + if (retval) { 290 + pseries_idle_devices_uninit(); 291 + cpuidle_unregister_driver(&pseries_idle_driver); 330 292 return retval; 331 293 } 332 294 ··· 347 295 { 348 296 349 297 unregister_cpu_notifier(&setup_hotplug_notifier); 350 - cpuidle_unregister(&pseries_idle_driver); 298 + pseries_idle_devices_uninit(); 299 + cpuidle_unregister_driver(&pseries_idle_driver); 351 300 352 301 return; 353 302 }
+5
drivers/cpuidle/Kconfig
··· 35 35 source "drivers/cpuidle/Kconfig.arm" 36 36 endmenu 37 37 38 + menu "POWERPC CPU Idle Drivers" 39 + depends on PPC 40 + source "drivers/cpuidle/Kconfig.powerpc" 41 + endmenu 42 + 38 43 endif 39 44 40 45 config ARCH_NEEDS_CPU_IDLE_COUPLED
+11
drivers/cpuidle/Kconfig.powerpc
··· 1 + # 2 + # POWERPC CPU Idle Drivers 3 + # 4 + config PSERIES_CPUIDLE 5 + bool "Cpuidle driver for pSeries platforms" 6 + depends on CPU_IDLE 7 + depends on PPC_PSERIES 8 + default y 9 + help 10 + Select this option to enable processor idle state management 11 + through cpuidle subsystem.
+4
drivers/cpuidle/Makefile
··· 13 13 obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o 14 14 obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o 15 15 obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o 16 + 17 + ############################################################################### 18 + # POWERPC drivers 19 + obj-$(CONFIG_PSERIES_CPUIDLE) += cpuidle-pseries.o