Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.git] / kernel / hrtimer.c
index f5cfde8..eb1ddeb 100644 (file)
@@ -279,6 +279,8 @@ ktime_t ktime_add_ns(const ktime_t kt, u64 nsec)
 
        return ktime_add(kt, tmp);
 }
+
+EXPORT_SYMBOL_GPL(ktime_add_ns);
 # endif /* !CONFIG_KTIME_SCALAR */
 
 /*
@@ -556,7 +558,8 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
  */
 static int hrtimer_switch_to_hres(void)
 {
-       struct hrtimer_cpu_base *base = &__get_cpu_var(hrtimer_bases);
+       int cpu = smp_processor_id();
+       struct hrtimer_cpu_base *base = &per_cpu(hrtimer_bases, cpu);
        unsigned long flags;
 
        if (base->hres_active)
@@ -566,6 +569,8 @@ static int hrtimer_switch_to_hres(void)
 
        if (tick_init_highres()) {
                local_irq_restore(flags);
+               printk(KERN_WARNING "Could not switch to high resolution "
+                                   "mode on CPU %d\n", cpu);
                return 0;
        }
        base->hres_active = 1;
@@ -667,6 +672,7 @@ hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
 
        return orun;
 }
+EXPORT_SYMBOL_GPL(hrtimer_forward);
 
 /*
  * enqueue_hrtimer - internal function to (re)start a timer
@@ -680,6 +686,7 @@ static void enqueue_hrtimer(struct hrtimer *timer,
        struct rb_node **link = &base->active.rb_node;
        struct rb_node *parent = NULL;
        struct hrtimer *entry;
+       int leftmost = 1;
 
        /*
         * Find the right place in the rbtree:
@@ -691,18 +698,19 @@ static void enqueue_hrtimer(struct hrtimer *timer,
                 * We dont care about collisions. Nodes with
                 * the same expiry time stay together.
                 */
-               if (timer->expires.tv64 < entry->expires.tv64)
+               if (timer->expires.tv64 < entry->expires.tv64) {
                        link = &(*link)->rb_left;
-               else
+               } else {
                        link = &(*link)->rb_right;
+                       leftmost = 0;
+               }
        }
 
        /*
         * Insert the timer to the rbtree and check whether it
         * replaces the first pending timer
         */
-       if (!base->first || timer->expires.tv64 <
-           rb_entry(base->first, struct hrtimer, node)->expires.tv64) {
+       if (leftmost) {
                /*
                 * Reprogram the clock event device. When the timer is already
                 * expired hrtimer_enqueue_reprogram has either called the
@@ -1403,16 +1411,18 @@ static void migrate_hrtimers(int cpu)
 static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
                                        unsigned long action, void *hcpu)
 {
-       long cpu = (long)hcpu;
+       unsigned int cpu = (long)hcpu;
 
        switch (action) {
 
        case CPU_UP_PREPARE:
+       case CPU_UP_PREPARE_FROZEN:
                init_hrtimers_cpu(cpu);
                break;
 
 #ifdef CONFIG_HOTPLUG_CPU
        case CPU_DEAD:
+       case CPU_DEAD_FROZEN:
                clockevents_notify(CLOCK_EVT_NOTIFY_CPU_DEAD, &cpu);
                migrate_hrtimers(cpu);
                break;