Pull mca-cleanup into release branch
[sfrench/cifs-2.6.git] / arch / ia64 / kernel / time.c
index a094ec49ccfab6fe8822771f9335def7a51cacf8..ac167436e9364ffc23fe3bde276019e5fae93d7e 100644 (file)
@@ -32,7 +32,7 @@
 
 extern unsigned long wall_jiffies;
 
-#define TIME_KEEPER_ID 0       /* smp_processor_id() of time-keeper */
+volatile int time_keeper_id = 0; /* smp_processor_id() of time-keeper */
 
 #ifdef CONFIG_IA64_DEBUG_IRQ
 
@@ -71,7 +71,7 @@ timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
 
                new_itm += local_cpu_data->itm_delta;
 
-               if (smp_processor_id() == TIME_KEEPER_ID) {
+               if (smp_processor_id() == time_keeper_id) {
                        /*
                         * Here we are in the timer irq handler. We have irqs locally
                         * disabled, but we don't know if the timer_bh is running on
@@ -236,6 +236,11 @@ static struct irqaction timer_irqaction = {
        .name =         "timer"
 };
 
+void __devinit ia64_disable_timer(void)
+{
+       ia64_set_itv(1 << 16);
+}
+
 void __init
 time_init (void)
 {
@@ -250,32 +255,27 @@ time_init (void)
        set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
 }
 
-#define SMALLUSECS 100
-
-void
-udelay (unsigned long usecs)
+/*
+ * Generic udelay assumes that if preemption is allowed and the thread
+ * migrates to another CPU, that the ITC values are synchronized across
+ * all CPUs.
+ */
+static void
+ia64_itc_udelay (unsigned long usecs)
 {
-       unsigned long start;
-       unsigned long cycles;
-       unsigned long smallusecs;
+       unsigned long start = ia64_get_itc();
+       unsigned long end = start + usecs*local_cpu_data->cyc_per_usec;
 
-       /*
-        * Execute the non-preemptible delay loop (because the ITC might
-        * not be synchronized between CPUS) in relatively short time
-        * chunks, allowing preemption between the chunks.
-        */
-       while (usecs > 0) {
-               smallusecs = (usecs > SMALLUSECS) ? SMALLUSECS : usecs;
-               preempt_disable();
-               cycles = smallusecs*local_cpu_data->cyc_per_usec;
-               start = ia64_get_itc();
+       while (time_before(ia64_get_itc(), end))
+               cpu_relax();
+}
 
-               while (ia64_get_itc() - start < cycles)
-                       cpu_relax();
+void (*ia64_udelay)(unsigned long usecs) = &ia64_itc_udelay;
 
-               preempt_enable();
-               usecs -= smallusecs;
-       }
+void
+udelay (unsigned long usecs)
+{
+       (*ia64_udelay)(usecs);
 }
 EXPORT_SYMBOL(udelay);