Merge branch 'fixes' of git://git.linaro.org/people/rmk/linux-arm
[linux-flexiantxendom0-3.2.10.git] / kernel / hrtimer.c
index 26dd32f..ae34bf5 100644 (file)
@@ -32,7 +32,7 @@
  */
 
 #include <linux/cpu.h>
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/percpu.h>
 #include <linux/hrtimer.h>
 #include <linux/notifier.h>
@@ -64,17 +64,20 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
        .clock_base =
        {
                {
-                       .index = CLOCK_REALTIME,
-                       .get_time = &ktime_get_real,
+                       .index = HRTIMER_BASE_MONOTONIC,
+                       .clockid = CLOCK_MONOTONIC,
+                       .get_time = &ktime_get,
                        .resolution = KTIME_LOW_RES,
                },
                {
-                       .index = CLOCK_MONOTONIC,
-                       .get_time = &ktime_get,
+                       .index = HRTIMER_BASE_REALTIME,
+                       .clockid = CLOCK_REALTIME,
+                       .get_time = &ktime_get_real,
                        .resolution = KTIME_LOW_RES,
                },
                {
-                       .index = CLOCK_BOOTTIME,
+                       .index = HRTIMER_BASE_BOOTTIME,
+                       .clockid = CLOCK_BOOTTIME,
                        .get_time = &ktime_get_boottime,
                        .resolution = KTIME_LOW_RES,
                },
@@ -196,7 +199,7 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
        struct hrtimer_cpu_base *new_cpu_base;
        int this_cpu = smp_processor_id();
        int cpu = hrtimer_get_target(this_cpu, pinned);
-       int basenum = hrtimer_clockid_to_base(base->index);
+       int basenum = base->index;
 
 again:
        new_cpu_base = &per_cpu(hrtimer_bases, cpu);
@@ -745,7 +748,7 @@ static inline void retrigger_next_event(void *arg) { }
  */
 void clock_was_set(void)
 {
-#ifdef CONFIG_HIGHRES_TIMERS
+#ifdef CONFIG_HIGH_RES_TIMERS
        /* Retrigger the CPU local events everywhere */
        on_each_cpu(retrigger_next_event, NULL, 1);
 #endif
@@ -857,6 +860,7 @@ static int enqueue_hrtimer(struct hrtimer *timer,
        debug_activate(timer);
 
        timerqueue_add(&base->active, &timer->node);
+       base->cpu_base->active_bases |= 1 << base->index;
 
        /*
         * HRTIMER_STATE_ENQUEUED is or'ed to the current state to preserve the
@@ -881,10 +885,13 @@ static void __remove_hrtimer(struct hrtimer *timer,
                             struct hrtimer_clock_base *base,
                             unsigned long newstate, int reprogram)
 {
+       struct timerqueue_node *next_timer;
        if (!(timer->state & HRTIMER_STATE_ENQUEUED))
                goto out;
 
-       if (&timer->node == timerqueue_getnext(&base->active)) {
+       next_timer = timerqueue_getnext(&base->active);
+       timerqueue_del(&base->active, &timer->node);
+       if (&timer->node == next_timer) {
 #ifdef CONFIG_HIGH_RES_TIMERS
                /* Reprogram the clock event device. if enabled */
                if (reprogram && hrtimer_hres_active()) {
@@ -897,7 +904,8 @@ static void __remove_hrtimer(struct hrtimer *timer,
                }
 #endif
        }
-       timerqueue_del(&base->active, &timer->node);
+       if (!timerqueue_getnext(&base->active))
+               base->cpu_base->active_bases &= ~(1 << base->index);
 out:
        timer->state = newstate;
 }
@@ -1235,7 +1243,6 @@ static void __run_hrtimer(struct hrtimer *timer, ktime_t *now)
 void hrtimer_interrupt(struct clock_event_device *dev)
 {
        struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
-       struct hrtimer_clock_base *base;
        ktime_t expires_next, now, entry_time, delta;
        int i, retries = 0;
 
@@ -1257,12 +1264,15 @@ retry:
         */
        cpu_base->expires_next.tv64 = KTIME_MAX;
 
-       base = cpu_base->clock_base;
-
        for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
-               ktime_t basenow;
+               struct hrtimer_clock_base *base;
                struct timerqueue_node *node;
+               ktime_t basenow;
+
+               if (!(cpu_base->active_bases & (1 << i)))
+                       continue;
 
+               base = cpu_base->clock_base + i;
                basenow = ktime_add(now, base->offset);
 
                while ((node = timerqueue_getnext(&base->active))) {
@@ -1295,7 +1305,6 @@ retry:
 
                        __run_hrtimer(timer, &basenow);
                }
-               base++;
        }
 
        /*
@@ -1526,7 +1535,7 @@ long __sched hrtimer_nanosleep_restart(struct restart_block *restart)
        struct timespec __user  *rmtp;
        int ret = 0;
 
-       hrtimer_init_on_stack(&t.timer, restart->nanosleep.index,
+       hrtimer_init_on_stack(&t.timer, restart->nanosleep.clockid,
                                HRTIMER_MODE_ABS);
        hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires);
 
@@ -1578,7 +1587,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
 
        restart = &current_thread_info()->restart_block;
        restart->fn = hrtimer_nanosleep_restart;
-       restart->nanosleep.index = t.timer.base->index;
+       restart->nanosleep.clockid = t.timer.base->clockid;
        restart->nanosleep.rmtp = rmtp;
        restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer);