]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/cpuidle/cpuidle.c
Merge branch 'master' into tk71
[mv-sheeva.git] / drivers / cpuidle / cpuidle.c
index a507108433785f8432b3d15504c3a036b461c1a0..bf5092455a8f813f58fe88b07baaeea1b772ae87 100644 (file)
@@ -49,7 +49,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev);
  */
 static void cpuidle_idle_call(void)
 {
-       struct cpuidle_device *dev = __get_cpu_var(cpuidle_devices);
+       struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
        struct cpuidle_state *target_state;
        int next_state;
 
@@ -96,7 +96,15 @@ static void cpuidle_idle_call(void)
 
        /* enter the state and update stats */
        dev->last_state = target_state;
+
+       trace_power_start(POWER_CSTATE, next_state, dev->cpu);
+       trace_cpu_idle(next_state, dev->cpu);
+
        dev->last_residency = target_state->enter(dev, target_state);
+
+       trace_power_end(dev->cpu);
+       trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu);
+
        if (dev->last_state)
                target_state = dev->last_state;
 
@@ -106,7 +114,6 @@ static void cpuidle_idle_call(void)
        /* give the governor an opportunity to reflect on the outcome */
        if (cpuidle_curr_governor->reflect)
                cpuidle_curr_governor->reflect(dev);
-       trace_power_end(smp_processor_id());
 }
 
 /**
@@ -154,6 +161,45 @@ void cpuidle_resume_and_unlock(void)
 
 EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock);
 
+#ifdef CONFIG_ARCH_HAS_CPU_RELAX
+static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st)
+{
+       ktime_t t1, t2;
+       s64 diff;
+       int ret;
+
+       t1 = ktime_get();
+       local_irq_enable();
+       while (!need_resched())
+               cpu_relax();
+
+       t2 = ktime_get();
+       diff = ktime_to_us(ktime_sub(t2, t1));
+       if (diff > INT_MAX)
+               diff = INT_MAX;
+
+       ret = (int) diff;
+       return ret;
+}
+
+static void poll_idle_init(struct cpuidle_device *dev)
+{
+       struct cpuidle_state *state = &dev->states[0];
+
+       cpuidle_set_statedata(state, NULL);
+
+       snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
+       snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
+       state->exit_latency = 0;
+       state->target_residency = 0;
+       state->power_usage = -1;
+       state->flags = 0;
+       state->enter = poll_idle;
+}
+#else
+static void poll_idle_init(struct cpuidle_device *dev) {}
+#endif /* CONFIG_ARCH_HAS_CPU_RELAX */
+
 /**
  * cpuidle_enable_device - enables idle PM for a CPU
  * @dev: the CPU
@@ -178,6 +224,8 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
                        return ret;
        }
 
+       poll_idle_init(dev);
+
        if ((ret = cpuidle_add_state_sysfs(dev)))
                return ret;
 
@@ -232,45 +280,6 @@ void cpuidle_disable_device(struct cpuidle_device *dev)
 
 EXPORT_SYMBOL_GPL(cpuidle_disable_device);
 
-#ifdef CONFIG_ARCH_HAS_CPU_RELAX
-static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st)
-{
-       ktime_t t1, t2;
-       s64 diff;
-       int ret;
-
-       t1 = ktime_get();
-       local_irq_enable();
-       while (!need_resched())
-               cpu_relax();
-
-       t2 = ktime_get();
-       diff = ktime_to_us(ktime_sub(t2, t1));
-       if (diff > INT_MAX)
-               diff = INT_MAX;
-
-       ret = (int) diff;
-       return ret;
-}
-
-static void poll_idle_init(struct cpuidle_device *dev)
-{
-       struct cpuidle_state *state = &dev->states[0];
-
-       cpuidle_set_statedata(state, NULL);
-
-       snprintf(state->name, CPUIDLE_NAME_LEN, "C0");
-       snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
-       state->exit_latency = 0;
-       state->target_residency = 0;
-       state->power_usage = -1;
-       state->flags = CPUIDLE_FLAG_POLL;
-       state->enter = poll_idle;
-}
-#else
-static void poll_idle_init(struct cpuidle_device *dev) {}
-#endif /* CONFIG_ARCH_HAS_CPU_RELAX */
-
 /**
  * __cpuidle_register_device - internal register function called before register
  * and enable routines
@@ -291,8 +300,6 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
 
        init_completion(&dev->kobj_unregister);
 
-       poll_idle_init(dev);
-
        /*
         * cpuidle driver should set the dev->power_specified bit
         * before registering the device if the driver provides