summaryrefslogtreecommitdiffstats
path: root/arch/arm/xen
diff options
context:
space:
mode:
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>2015-11-23 10:40:12 +0000
committerDavid Vrabel <david.vrabel@citrix.com>2015-12-21 14:40:58 +0000
commite709fba132db696bbc21fca2e7f736198ec53eda (patch)
tree151b6fe65303471ee28329798983ec921d281c44 /arch/arm/xen
parentab76078a3d43226288fa43489b76b1416975705f (diff)
downloadtalos-obmc-linux-e709fba132db696bbc21fca2e7f736198ec53eda.tar.gz
talos-obmc-linux-e709fba132db696bbc21fca2e7f736198ec53eda.zip
xen/arm: introduce xen_read_wallclock
Read the wallclock from the shared info page at boot time. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arm/xen')
-rw-r--r--arch/arm/xen/enlighten.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 64f17264f2f5..6370222b8053 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -26,6 +26,7 @@
#include <linux/cpufreq.h>
#include <linux/cpu.h>
#include <linux/console.h>
+#include <linux/timekeeping.h>
#include <linux/mm.h>
@@ -93,6 +94,27 @@ static unsigned long long xen_stolen_accounting(int cpu)
return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
}
+static void xen_read_wallclock(struct timespec64 *ts)
+{
+ u32 version;
+ struct timespec64 now, ts_monotonic;
+ struct shared_info *s = HYPERVISOR_shared_info;
+ struct pvclock_wall_clock *wall_clock = &(s->wc);
+
+ /* get wallclock at system boot */
+ do {
+ version = wall_clock->version;
+ rmb(); /* fetch version before time */
+ now.tv_sec = ((uint64_t)wall_clock->sec_hi << 32) | wall_clock->sec;
+ now.tv_nsec = wall_clock->nsec;
+ rmb(); /* fetch time before checking version */
+ } while ((wall_clock->version & 1) || (version != wall_clock->version));
+
+ /* time since system boot */
+ ktime_get_ts64(&ts_monotonic);
+ *ts = timespec64_add(now, ts_monotonic);
+}
+
static void xen_percpu_init(void)
{
struct vcpu_register_vcpu_info info;
@@ -301,6 +323,11 @@ static int __init xen_pm_init(void)
pm_power_off = xen_power_off;
arm_pm_restart = xen_restart;
+ if (!xen_initial_domain()) {
+ struct timespec64 ts;
+ xen_read_wallclock(&ts);
+ do_settimeofday64(&ts);
+ }
return 0;
}
OpenPOWER on IntegriCloud