powerpc/pseries/cpuidle: Replace pseries_notify_cpuidle_add call with notifier
authorDeepthi Dharwar <deepthi@linux.vnet.ibm.com>
Sun, 20 May 2012 18:34:27 +0000 (18:34 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 3 Jul 2012 04:14:40 +0000 (14:14 +1000)
The following patch is to remove the pseries_notify_add_cpu() call
and replace it by a hot plug notifier.

This would prevent cpuidle resources being released and allocated each
time cpu comes online on pseries.

The earlier design was causing a lockdep problem
in start_secondary as reported on this thread
-https://lkml.org/lkml/2012/5/17/2

This applies on 3.4-rc7

Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/processor.h
arch/powerpc/platforms/pseries/processor_idle.c
arch/powerpc/platforms/pseries/smp.c

index 413a5eaef56c94340d16451a0f65e56453c5b38d..53b6dfa83344a9f3dbe6b68ef72c6d60948f26ab 100644 (file)
@@ -389,10 +389,8 @@ extern int powersave_nap;  /* set if nap mode can be used in idle loop */
 
 #ifdef CONFIG_PSERIES_IDLE
 extern void update_smt_snooze_delay(int snooze);
-extern int pseries_notify_cpuidle_add_cpu(int cpu);
 #else
 static inline void update_smt_snooze_delay(int snooze) {}
-static inline int pseries_notify_cpuidle_add_cpu(int cpu) { return 0; }
 #endif
 
 extern void flush_instruction_cache(void);
index e61483e8e96083b14d92430bae3f463947635fa8..a97ef6692dad3e6d91ddc336674d813dc0672389 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/moduleparam.h>
 #include <linux/cpuidle.h>
 #include <linux/cpu.h>
+#include <linux/notifier.h>
 
 #include <asm/paca.h>
 #include <asm/reg.h>
@@ -186,17 +187,28 @@ static struct cpuidle_state shared_states[MAX_IDLE_STATE_COUNT] = {
                .enter = &shared_cede_loop },
 };
 
-int pseries_notify_cpuidle_add_cpu(int cpu)
+static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n,
+                       unsigned long action, void *hcpu)
 {
+       int hotcpu = (unsigned long)hcpu;
        struct cpuidle_device *dev =
-                       per_cpu_ptr(pseries_cpuidle_devices, cpu);
-       if (dev && cpuidle_get_driver()) {
-               cpuidle_disable_device(dev);
-               cpuidle_enable_device(dev);
+                       per_cpu_ptr(pseries_cpuidle_devices, hotcpu);
+
+       switch (action & 0xf) {
+       case CPU_ONLINE:
+               if (dev && cpuidle_get_driver()) {
+                       cpuidle_disable_device(dev);
+                       cpuidle_enable_device(dev);
+               }
+               break;
        }
-       return 0;
+       return NOTIFY_OK;
 }
 
+static struct notifier_block setup_hotplug_notifier = {
+       .notifier_call = pseries_cpuidle_add_cpu_notifier,
+};
+
 /*
  * pseries_cpuidle_driver_init()
  */
@@ -321,6 +333,7 @@ static int __init pseries_processor_idle_init(void)
                return retval;
        }
 
+       register_cpu_notifier(&setup_hotplug_notifier);
        printk(KERN_DEBUG "pseries_idle_driver registered\n");
 
        return 0;
index e16bb8d48550b60e249ade3aac24b00ed2159233..71706bc34a0dd8a117f5ef71d70b93ab65880ca3 100644 (file)
@@ -147,7 +147,6 @@ static void __devinit smp_xics_setup_cpu(int cpu)
        set_cpu_current_state(cpu, CPU_STATE_ONLINE);
        set_default_offline_state(cpu);
 #endif
-       pseries_notify_cpuidle_add_cpu(cpu);
 }
 
 static int __devinit smp_pSeries_kick_cpu(int nr)