Merge tag 'iwlwifi-next-for-kalle-2014-12-30' of https://git.kernel.org/pub/scm/linux...
[cascardo/linux.git] / arch / tile / kernel / time.c
index d8fbc28..d412b08 100644 (file)
@@ -98,8 +98,8 @@ void __init calibrate_delay(void)
 {
        loops_per_jiffy = get_clock_rate() / HZ;
        pr_info("Clock rate yields %lu.%02lu BogoMIPS (lpj=%lu)\n",
-               loops_per_jiffy/(500000/HZ),
-               (loops_per_jiffy/(5000/HZ)) % 100, loops_per_jiffy);
+               loops_per_jiffy / (500000 / HZ),
+               (loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy);
 }
 
 /* Called fairly late in init/main.c, but before we go smp. */
@@ -162,7 +162,7 @@ static DEFINE_PER_CPU(struct clock_event_device, tile_timer) = {
 
 void setup_tile_timer(void)
 {
-       struct clock_event_device *evt = &__get_cpu_var(tile_timer);
+       struct clock_event_device *evt = this_cpu_ptr(&tile_timer);
 
        /* Fill in fields that are speed-specific. */
        clockevents_calc_mult_shift(evt, cycles_per_sec, TILE_MINSEC);
@@ -182,7 +182,7 @@ void setup_tile_timer(void)
 void do_timer_interrupt(struct pt_regs *regs, int fault_num)
 {
        struct pt_regs *old_regs = set_irq_regs(regs);
-       struct clock_event_device *evt = &__get_cpu_var(tile_timer);
+       struct clock_event_device *evt = this_cpu_ptr(&tile_timer);
 
        /*
         * Mask the timer interrupt here, since we are a oneshot timer
@@ -194,7 +194,7 @@ void do_timer_interrupt(struct pt_regs *regs, int fault_num)
        irq_enter();
 
        /* Track interrupt count. */
-       __get_cpu_var(irq_stat).irq_timer_count++;
+       __this_cpu_inc(irq_stat.irq_timer_count);
 
        /* Call the generic timer handler */
        evt->event_handler(evt);
@@ -235,7 +235,7 @@ cycles_t ns2cycles(unsigned long nsecs)
         * We do not have to disable preemption here as each core has the same
         * clock frequency.
         */
-       struct clock_event_device *dev = &__raw_get_cpu_var(tile_timer);
+       struct clock_event_device *dev = raw_cpu_ptr(&tile_timer);
 
        /*
         * as in clocksource.h and x86's timer.h, we split the calculation
@@ -249,33 +249,52 @@ cycles_t ns2cycles(unsigned long nsecs)
 
 void update_vsyscall_tz(void)
 {
-       /* Userspace gettimeofday will spin while this value is odd. */
-       ++vdso_data->tz_update_count;
-       smp_wmb();
+       write_seqcount_begin(&vdso_data->tz_seq);
        vdso_data->tz_minuteswest = sys_tz.tz_minuteswest;
        vdso_data->tz_dsttime = sys_tz.tz_dsttime;
-       smp_wmb();
-       ++vdso_data->tz_update_count;
+       write_seqcount_end(&vdso_data->tz_seq);
 }
 
 void update_vsyscall(struct timekeeper *tk)
 {
-       struct timespec *wtm = &tk->wall_to_monotonic;
-       struct clocksource *clock = tk->tkr.clock;
-
-       if (clock != &cycle_counter_cs)
+       if (tk->tkr.clock != &cycle_counter_cs)
                return;
 
-       /* Userspace gettimeofday will spin while this value is odd. */
-       ++vdso_data->tb_update_count;
-       smp_wmb();
-       vdso_data->xtime_tod_stamp = tk->tkr.cycle_last;
-       vdso_data->xtime_clock_sec = tk->xtime_sec;
-       vdso_data->xtime_clock_nsec = tk->tkr.xtime_nsec;
-       vdso_data->wtom_clock_sec = wtm->tv_sec;
-       vdso_data->wtom_clock_nsec = wtm->tv_nsec;
-       vdso_data->mult = tk->tkr.mult;
-       vdso_data->shift = tk->tkr.shift;
-       smp_wmb();
-       ++vdso_data->tb_update_count;
+       write_seqcount_begin(&vdso_data->tb_seq);
+
+       vdso_data->cycle_last           = tk->tkr.cycle_last;
+       vdso_data->mask                 = tk->tkr.mask;
+       vdso_data->mult                 = tk->tkr.mult;
+       vdso_data->shift                = tk->tkr.shift;
+
+       vdso_data->wall_time_sec        = tk->xtime_sec;
+       vdso_data->wall_time_snsec      = tk->tkr.xtime_nsec;
+
+       vdso_data->monotonic_time_sec   = tk->xtime_sec
+                                       + tk->wall_to_monotonic.tv_sec;
+       vdso_data->monotonic_time_snsec = tk->tkr.xtime_nsec
+                                       + ((u64)tk->wall_to_monotonic.tv_nsec
+                                               << tk->tkr.shift);
+       while (vdso_data->monotonic_time_snsec >=
+                                       (((u64)NSEC_PER_SEC) << tk->tkr.shift)) {
+               vdso_data->monotonic_time_snsec -=
+                                       ((u64)NSEC_PER_SEC) << tk->tkr.shift;
+               vdso_data->monotonic_time_sec++;
+       }
+
+       vdso_data->wall_time_coarse_sec = tk->xtime_sec;
+       vdso_data->wall_time_coarse_nsec = (long)(tk->tkr.xtime_nsec >>
+                                                tk->tkr.shift);
+
+       vdso_data->monotonic_time_coarse_sec =
+               vdso_data->wall_time_coarse_sec + tk->wall_to_monotonic.tv_sec;
+       vdso_data->monotonic_time_coarse_nsec =
+               vdso_data->wall_time_coarse_nsec + tk->wall_to_monotonic.tv_nsec;
+
+       while (vdso_data->monotonic_time_coarse_nsec >= NSEC_PER_SEC) {
+               vdso_data->monotonic_time_coarse_nsec -= NSEC_PER_SEC;
+               vdso_data->monotonic_time_coarse_sec++;
+       }
+
+       write_seqcount_end(&vdso_data->tb_seq);
 }