sched/idle, PPC: Remove redundant cpuidle_idle_call()
[deliverable/linux.git] / drivers / cpuidle / cpuidle-pseries.c
index 21154782402a812335749978c9695227aa989d4f..d4864892951b618cd3e2a42e2128078c97f8909c 100644 (file)
@@ -24,14 +24,12 @@ struct cpuidle_driver pseries_idle_driver = {
        .owner            = THIS_MODULE,
 };
 
-#define MAX_IDLE_STATE_COUNT   2
-
-static int max_idle_state = MAX_IDLE_STATE_COUNT - 1;
-static struct cpuidle_device __percpu *pseries_cpuidle_devices;
+static int max_idle_state;
 static struct cpuidle_state *cpuidle_state_table;
 
 static inline void idle_loop_prolog(unsigned long *in_purr)
 {
+       ppc64_runlatch_off();
        *in_purr = mfspr(SPRN_PURR);
        /*
         * Indicate to the HV that we are idle. Now would be
@@ -48,6 +46,10 @@ static inline void idle_loop_epilog(unsigned long in_purr)
        wait_cycles += mfspr(SPRN_PURR) - in_purr;
        get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles);
        get_lppaca()->idle = 0;
+
+       if (irqs_disabled())
+               local_irq_enable();
+       ppc64_runlatch_on();
 }
 
 static int snooze_loop(struct cpuidle_device *dev,
@@ -55,13 +57,12 @@ static int snooze_loop(struct cpuidle_device *dev,
                        int index)
 {
        unsigned long in_purr;
-       int cpu = dev->cpu;
 
        idle_loop_prolog(&in_purr);
        local_irq_enable();
        set_thread_flag(TIF_POLLING_NRFLAG);
 
-       while ((!need_resched()) && cpu_online(cpu)) {
+       while (!need_resched()) {
                HMT_low();
                HMT_very_low();
        }
@@ -136,7 +137,7 @@ static int shared_cede_loop(struct cpuidle_device *dev,
 /*
  * States for dedicated partition case.
  */
-static struct cpuidle_state dedicated_states[MAX_IDLE_STATE_COUNT] = {
+static struct cpuidle_state dedicated_states[] = {
        { /* Snooze */
                .name = "snooze",
                .desc = "snooze",
@@ -156,7 +157,7 @@ static struct cpuidle_state dedicated_states[MAX_IDLE_STATE_COUNT] = {
 /*
  * States for shared partition case.
  */
-static struct cpuidle_state shared_states[MAX_IDLE_STATE_COUNT] = {
+static struct cpuidle_state shared_states[] = {
        { /* Shared Cede */
                .name = "Shared Cede",
                .desc = "Shared Cede",
@@ -166,29 +167,12 @@ static struct cpuidle_state shared_states[MAX_IDLE_STATE_COUNT] = {
                .enter = &shared_cede_loop },
 };
 
-void update_smt_snooze_delay(int cpu, int residency)
-{
-       struct cpuidle_driver *drv = cpuidle_get_driver();
-       struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
-
-       if (cpuidle_state_table != dedicated_states)
-               return;
-
-       if (residency < 0) {
-               /* Disable the Nap state on that cpu */
-               if (dev)
-                       dev->states_usage[1].disable = 1;
-       } else
-               if (drv)
-                       drv->states[1].target_residency = residency;
-}
-
 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, hotcpu);
+                               per_cpu(cpuidle_devices, hotcpu);
 
        if (dev && cpuidle_get_driver()) {
                switch (action) {
@@ -227,12 +211,8 @@ static int pseries_cpuidle_driver_init(void)
 
        drv->state_count = 0;
 
-       for (idle_state = 0; idle_state < MAX_IDLE_STATE_COUNT; ++idle_state) {
-
-               if (idle_state > max_idle_state)
-                       break;
-
-               /* is the state not enabled? */
+       for (idle_state = 0; idle_state < max_idle_state; ++idle_state) {
+               /* Is the state not enabled? */
                if (cpuidle_state_table[idle_state].enter == NULL)
                        continue;
 
@@ -245,50 +225,6 @@ static int pseries_cpuidle_driver_init(void)
        return 0;
 }
 
-/* pseries_idle_devices_uninit(void)
- * unregister cpuidle devices and de-allocate memory
- */
-static void pseries_idle_devices_uninit(void)
-{
-       int i;
-       struct cpuidle_device *dev;
-
-       for_each_possible_cpu(i) {
-               dev = per_cpu_ptr(pseries_cpuidle_devices, i);
-               cpuidle_unregister_device(dev);
-       }
-
-       free_percpu(pseries_cpuidle_devices);
-       return;
-}
-
-/* pseries_idle_devices_init()
- * allocate, initialize and register cpuidle device
- */
-static int pseries_idle_devices_init(void)
-{
-       int i;
-       struct cpuidle_driver *drv = &pseries_idle_driver;
-       struct cpuidle_device *dev;
-
-       pseries_cpuidle_devices = alloc_percpu(struct cpuidle_device);
-       if (pseries_cpuidle_devices == NULL)
-               return -ENOMEM;
-
-       for_each_possible_cpu(i) {
-               dev = per_cpu_ptr(pseries_cpuidle_devices, i);
-               dev->state_count = drv->state_count;
-               dev->cpu = i;
-               if (cpuidle_register_device(dev)) {
-                       printk(KERN_DEBUG \
-                               "cpuidle_register_device %d failed!\n", i);
-                       return -EIO;
-               }
-       }
-
-       return 0;
-}
-
 /*
  * pseries_idle_probe()
  * Choose state table for shared versus dedicated partition
@@ -296,21 +232,19 @@ static int pseries_idle_devices_init(void)
 static int pseries_idle_probe(void)
 {
 
-       if (!firmware_has_feature(FW_FEATURE_SPLPAR))
-               return -ENODEV;
-
        if (cpuidle_disable != IDLE_NO_OVERRIDE)
                return -ENODEV;
 
-       if (max_idle_state == 0) {
-               printk(KERN_DEBUG "pseries processor idle disabled.\n");
-               return -EPERM;
-       }
-
-       if (lppaca_shared_proc(get_lppaca()))
-               cpuidle_state_table = shared_states;
-       else
-               cpuidle_state_table = dedicated_states;
+       if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
+               if (lppaca_shared_proc(get_lppaca())) {
+                       cpuidle_state_table = shared_states;
+                       max_idle_state = ARRAY_SIZE(shared_states);
+               } else {
+                       cpuidle_state_table = dedicated_states;
+                       max_idle_state = ARRAY_SIZE(dedicated_states);
+               }
+       } else
+               return -ENODEV;
 
        return 0;
 }
@@ -324,38 +258,15 @@ static int __init pseries_processor_idle_init(void)
                return retval;
 
        pseries_cpuidle_driver_init();
-       retval = cpuidle_register_driver(&pseries_idle_driver);
+       retval = cpuidle_register(&pseries_idle_driver, NULL);
        if (retval) {
                printk(KERN_DEBUG "Registration of pseries driver failed.\n");
                return retval;
        }
 
-       retval = pseries_idle_devices_init();
-       if (retval) {
-               pseries_idle_devices_uninit();
-               cpuidle_unregister_driver(&pseries_idle_driver);
-               return retval;
-       }
-
        register_cpu_notifier(&setup_hotplug_notifier);
        printk(KERN_DEBUG "pseries_idle_driver registered\n");
-
        return 0;
 }
 
-static void __exit pseries_processor_idle_exit(void)
-{
-
-       unregister_cpu_notifier(&setup_hotplug_notifier);
-       pseries_idle_devices_uninit();
-       cpuidle_unregister_driver(&pseries_idle_driver);
-
-       return;
-}
-
-module_init(pseries_processor_idle_init);
-module_exit(pseries_processor_idle_exit);
-
-MODULE_AUTHOR("Deepthi Dharwar <deepthi@linux.vnet.ibm.com>");
-MODULE_DESCRIPTION("Cpuidle driver for POWER");
-MODULE_LICENSE("GPL");
+device_initcall(pseries_processor_idle_init);
This page took 0.026069 seconds and 5 git commands to generate.