]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/s390/kernel/time.c
Merge branch 'ioat-md-accel-for-linus' of git://lost.foo-projects.org/~dwillia2/git/iop
[linux-2.6-omap-h63xx.git] / arch / s390 / kernel / time.c
index ee9fd7b859282941db4ad38ee896ea933cc1809e..48dae49bc1ec474ffe80f3eed427a610f48d48bf 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/time.h>
+#include <linux/sysdev.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/smp.h>
@@ -225,10 +226,10 @@ static int nohz_idle_notify(struct notifier_block *self,
                            unsigned long action, void *hcpu)
 {
        switch (action) {
-       case CPU_IDLE:
+       case S390_CPU_IDLE:
                stop_hz_timer();
                break;
-       case CPU_NOT_IDLE:
+       case S390_CPU_NOT_IDLE:
                start_hz_timer();
                break;
        }
@@ -280,7 +281,6 @@ static void clock_comparator_interrupt(__u16 code)
 }
 
 static void etr_reset(void);
-static void etr_init(void);
 static void etr_ext_handler(__u16);
 
 /*
@@ -355,7 +355,6 @@ void __init time_init(void)
 #ifdef CONFIG_VIRT_TIMER
        vtime_init();
 #endif
-       etr_init();
 }
 
 /*
@@ -426,11 +425,11 @@ static struct etr_aib etr_port1;
 static int etr_port1_uptodate;
 static unsigned long etr_events;
 static struct timer_list etr_timer;
-static struct tasklet_struct etr_tasklet;
 static DEFINE_PER_CPU(atomic_t, etr_sync_word);
 
 static void etr_timeout(unsigned long dummy);
-static void etr_tasklet_fn(unsigned long dummy);
+static void etr_work_fn(struct work_struct *work);
+static DECLARE_WORK(etr_work, etr_work_fn);
 
 /*
  * The etr get_clock function. It will write the current clock value
@@ -507,29 +506,31 @@ static void etr_reset(void)
        }
 }
 
-static void etr_init(void)
+static int __init etr_init(void)
 {
        struct etr_aib aib;
 
        if (test_bit(ETR_FLAG_ENOSYS, &etr_flags))
-               return;
+               return 0;
        /* Check if this machine has the steai instruction. */
        if (etr_steai(&aib, ETR_STEAI_STEPPING_PORT) == 0)
                set_bit(ETR_FLAG_STEAI, &etr_flags);
        setup_timer(&etr_timer, etr_timeout, 0UL);
-       tasklet_init(&etr_tasklet, etr_tasklet_fn, 0);
        if (!etr_port0_online && !etr_port1_online)
                set_bit(ETR_FLAG_EACCES, &etr_flags);
        if (etr_port0_online) {
                set_bit(ETR_EVENT_PORT0_CHANGE, &etr_events);
-               tasklet_hi_schedule(&etr_tasklet);
+               schedule_work(&etr_work);
        }
        if (etr_port1_online) {
                set_bit(ETR_EVENT_PORT1_CHANGE, &etr_events);
-               tasklet_hi_schedule(&etr_tasklet);
+               schedule_work(&etr_work);
        }
+       return 0;
 }
 
+arch_initcall(etr_init);
+
 /*
  * Two sorts of ETR machine checks. The architecture reads:
  * "When a machine-check niterruption occurs and if a switch-to-local or
@@ -549,7 +550,7 @@ void etr_switch_to_local(void)
                return;
        etr_disable_sync_clock(NULL);
        set_bit(ETR_EVENT_SWITCH_LOCAL, &etr_events);
-       tasklet_hi_schedule(&etr_tasklet);
+       schedule_work(&etr_work);
 }
 
 /*
@@ -564,7 +565,7 @@ void etr_sync_check(void)
                return;
        etr_disable_sync_clock(NULL);
        set_bit(ETR_EVENT_SYNC_CHECK, &etr_events);
-       tasklet_hi_schedule(&etr_tasklet);
+       schedule_work(&etr_work);
 }
 
 /*
@@ -591,13 +592,13 @@ static void etr_ext_handler(__u16 code)
                 * Both ports are not up-to-date now.
                 */
                set_bit(ETR_EVENT_PORT_ALERT, &etr_events);
-       tasklet_hi_schedule(&etr_tasklet);
+       schedule_work(&etr_work);
 }
 
 static void etr_timeout(unsigned long dummy)
 {
        set_bit(ETR_EVENT_UPDATE, &etr_events);
-       tasklet_hi_schedule(&etr_tasklet);
+       schedule_work(&etr_work);
 }
 
 /*
@@ -747,6 +748,7 @@ static void etr_adjust_time(unsigned long long clock, unsigned long long delay)
        }
 }
 
+#ifdef CONFIG_SMP
 static void etr_sync_cpu_start(void *dummy)
 {
        int *in_sync = dummy;
@@ -758,8 +760,14 @@ static void etr_sync_cpu_start(void *dummy)
         * __udelay will stop the cpu on an enabled wait psw until the
         * TOD is running again.
         */
-       while (*in_sync == 0)
+       while (*in_sync == 0) {
                __udelay(1);
+               /*
+                * A different cpu changes *in_sync. Therefore use
+                * barrier() to force memory access.
+                */
+               barrier();
+       }
        if (*in_sync != 1)
                /* Didn't work. Clear per-cpu in sync bit again. */
                etr_disable_sync_clock(NULL);
@@ -773,6 +781,7 @@ static void etr_sync_cpu_start(void *dummy)
 static void etr_sync_cpu_end(void *dummy)
 {
 }
+#endif /* CONFIG_SMP */
 
 /*
  * Sync the TOD clock using the port refered to by aibp. This port
@@ -919,7 +928,7 @@ static struct etr_eacr etr_handle_update(struct etr_aib *aib,
        if (!eacr.e0 && !eacr.e1)
                return eacr;
 
-       /* Update port0 or port1 with aib stored in etr_tasklet_fn. */
+       /* Update port0 or port1 with aib stored in etr_work_fn. */
        if (aib->esw.q == 0) {
                /* Information for port 0 stored. */
                if (eacr.p0 && !etr_port0_uptodate) {
@@ -999,7 +1008,7 @@ static void etr_update_eacr(struct etr_eacr eacr)
  * particular this is the only function that calls etr_update_eacr(),
  * it "controls" the etr control register.
  */
-static void etr_tasklet_fn(unsigned long dummy)
+static void etr_work_fn(struct work_struct *work)
 {
        unsigned long long now;
        struct etr_eacr eacr;
@@ -1212,13 +1221,13 @@ static ssize_t etr_online_store(struct sys_device *dev,
                        return count;   /* Nothing to do. */
                etr_port0_online = value;
                set_bit(ETR_EVENT_PORT0_CHANGE, &etr_events);
-               tasklet_hi_schedule(&etr_tasklet);
+               schedule_work(&etr_work);
        } else {
                if (etr_port1_online == value)
                        return count;   /* Nothing to do. */
                etr_port1_online = value;
                set_bit(ETR_EVENT_PORT1_CHANGE, &etr_events);
-               tasklet_hi_schedule(&etr_tasklet);
+               schedule_work(&etr_work);
        }
        return count;
 }