Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
[sfrench/cifs-2.6.git] / arch / tile / kernel / time.c
index 7c353d8c2da926c9b057616db17f269fd6981f66..5d10642db63e8e9f98934e36200128a9dfd26073 100644 (file)
 #include <linux/smp.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/timekeeper_internal.h>
 #include <asm/irq_regs.h>
 #include <asm/traps.h>
+#include <asm/vdso.h>
 #include <hv/hypervisor.h>
 #include <arch/interrupts.h>
 #include <arch/spr_def.h>
@@ -110,7 +112,6 @@ void __init time_init(void)
        setup_tile_timer();
 }
 
-
 /*
  * Define the tile timer clock event device.  The timer is driven by
  * the TILE_TIMER_CONTROL register, which consists of a 31-bit down
@@ -237,3 +238,37 @@ cycles_t ns2cycles(unsigned long nsecs)
        struct clock_event_device *dev = &__raw_get_cpu_var(tile_timer);
        return ((u64)nsecs * dev->mult) >> dev->shift;
 }
+
+void update_vsyscall_tz(void)
+{
+       /* Userspace gettimeofday will spin while this value is odd. */
+       ++vdso_data->tz_update_count;
+       smp_wmb();
+       vdso_data->tz_minuteswest = sys_tz.tz_minuteswest;
+       vdso_data->tz_dsttime = sys_tz.tz_dsttime;
+       smp_wmb();
+       ++vdso_data->tz_update_count;
+}
+
+void update_vsyscall(struct timekeeper *tk)
+{
+       struct timespec wall_time = tk_xtime(tk);
+       struct timespec *wtm = &tk->wall_to_monotonic;
+       struct clocksource *clock = tk->clock;
+
+       if (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 = clock->cycle_last;
+       vdso_data->xtime_clock_sec = wall_time.tv_sec;
+       vdso_data->xtime_clock_nsec = wall_time.tv_nsec;
+       vdso_data->wtom_clock_sec = wtm->tv_sec;
+       vdso_data->wtom_clock_nsec = wtm->tv_nsec;
+       vdso_data->mult = clock->mult;
+       vdso_data->shift = clock->shift;
+       smp_wmb();
+       ++vdso_data->tb_update_count;
+}