提交 a06df062 编写于 作者: D Daniel Lezcano 提交者: Rafael J. Wysocki

cpuidle: initialize the broadcast timer framework

The commit 89878baa73f0f1c679355006bd8632e5d78f96c2 introduced
the CPUIDLE_FLAG_TIMER_STOP flag where we specify a specific idle
state stops the local timer.

Now use this flag to check at init time if one state will need
the broadcast timer and, in this case, setup the broadcast timer
framework. That prevents multiple code duplication in the drivers.
Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 4dbad816
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/cpuidle.h> #include <linux/cpuidle.h>
#include <linux/cpumask.h>
#include <linux/clockchips.h>
#include "cpuidle.h" #include "cpuidle.h"
...@@ -19,9 +21,28 @@ DEFINE_SPINLOCK(cpuidle_driver_lock); ...@@ -19,9 +21,28 @@ DEFINE_SPINLOCK(cpuidle_driver_lock);
static void __cpuidle_set_cpu_driver(struct cpuidle_driver *drv, int cpu); static void __cpuidle_set_cpu_driver(struct cpuidle_driver *drv, int cpu);
static struct cpuidle_driver * __cpuidle_get_cpu_driver(int cpu); static struct cpuidle_driver * __cpuidle_get_cpu_driver(int cpu);
static void __cpuidle_driver_init(struct cpuidle_driver *drv) static void cpuidle_setup_broadcast_timer(void *arg)
{ {
int cpu = smp_processor_id();
clockevents_notify((long)(arg), &cpu);
}
static void __cpuidle_driver_init(struct cpuidle_driver *drv, int cpu)
{
int i;
drv->refcnt = 0; drv->refcnt = 0;
for (i = drv->state_count - 1; i >= 0 ; i--) {
if (!(drv->states[i].flags & CPUIDLE_FLAG_TIMER_STOP))
continue;
drv->bctimer = 1;
on_each_cpu_mask(get_cpu_mask(cpu), cpuidle_setup_broadcast_timer,
(void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, 1);
break;
}
} }
static int __cpuidle_register_driver(struct cpuidle_driver *drv, int cpu) static int __cpuidle_register_driver(struct cpuidle_driver *drv, int cpu)
...@@ -35,7 +56,7 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv, int cpu) ...@@ -35,7 +56,7 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv, int cpu)
if (__cpuidle_get_cpu_driver(cpu)) if (__cpuidle_get_cpu_driver(cpu))
return -EBUSY; return -EBUSY;
__cpuidle_driver_init(drv); __cpuidle_driver_init(drv, cpu);
__cpuidle_set_cpu_driver(drv, cpu); __cpuidle_set_cpu_driver(drv, cpu);
...@@ -49,6 +70,12 @@ static void __cpuidle_unregister_driver(struct cpuidle_driver *drv, int cpu) ...@@ -49,6 +70,12 @@ static void __cpuidle_unregister_driver(struct cpuidle_driver *drv, int cpu)
if (!WARN_ON(drv->refcnt > 0)) if (!WARN_ON(drv->refcnt > 0))
__cpuidle_set_cpu_driver(NULL, cpu); __cpuidle_set_cpu_driver(NULL, cpu);
if (drv->bctimer) {
drv->bctimer = 0;
on_each_cpu_mask(get_cpu_mask(cpu), cpuidle_setup_broadcast_timer,
(void *)CLOCK_EVT_NOTIFY_BROADCAST_OFF, 1);
}
} }
#ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS #ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS
......
...@@ -107,6 +107,8 @@ struct cpuidle_driver { ...@@ -107,6 +107,8 @@ struct cpuidle_driver {
/* set to 1 to use the core cpuidle time keeping (for all states). */ /* set to 1 to use the core cpuidle time keeping (for all states). */
unsigned int en_core_tk_irqen:1; unsigned int en_core_tk_irqen:1;
/* used by the cpuidle framework to setup the broadcast timer */
unsigned int bctimer:1;
/* states array must be ordered in decreasing power consumption */ /* states array must be ordered in decreasing power consumption */
struct cpuidle_state states[CPUIDLE_STATE_MAX]; struct cpuidle_state states[CPUIDLE_STATE_MAX];
int state_count; int state_count;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册