|
@@ -153,8 +153,8 @@ __cacheline_aligned_in_smp DEFINE_SEQLOCK(xtime_lock);
|
|
* - wall_to_monotonic is no longer the boot time, getboottime must be
|
|
* - wall_to_monotonic is no longer the boot time, getboottime must be
|
|
* used instead.
|
|
* used instead.
|
|
*/
|
|
*/
|
|
-struct timespec xtime __attribute__ ((aligned (16)));
|
|
|
|
-struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
|
|
|
|
|
|
+static struct timespec xtime __attribute__ ((aligned (16)));
|
|
|
|
+static struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
|
|
static struct timespec total_sleep_time;
|
|
static struct timespec total_sleep_time;
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -170,11 +170,10 @@ void timekeeping_leap_insert(int leapsecond)
|
|
{
|
|
{
|
|
xtime.tv_sec += leapsecond;
|
|
xtime.tv_sec += leapsecond;
|
|
wall_to_monotonic.tv_sec -= leapsecond;
|
|
wall_to_monotonic.tv_sec -= leapsecond;
|
|
- update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult);
|
|
|
|
|
|
+ update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
|
|
|
|
+ timekeeper.mult);
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef CONFIG_GENERIC_TIME
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* timekeeping_forward_now - update clock to the current time
|
|
* timekeeping_forward_now - update clock to the current time
|
|
*
|
|
*
|
|
@@ -328,7 +327,8 @@ int do_settimeofday(struct timespec *tv)
|
|
timekeeper.ntp_error = 0;
|
|
timekeeper.ntp_error = 0;
|
|
ntp_clear();
|
|
ntp_clear();
|
|
|
|
|
|
- update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult);
|
|
|
|
|
|
+ update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
|
|
|
|
+ timekeeper.mult);
|
|
|
|
|
|
write_sequnlock_irqrestore(&xtime_lock, flags);
|
|
write_sequnlock_irqrestore(&xtime_lock, flags);
|
|
|
|
|
|
@@ -376,52 +376,6 @@ void timekeeping_notify(struct clocksource *clock)
|
|
tick_clock_notify();
|
|
tick_clock_notify();
|
|
}
|
|
}
|
|
|
|
|
|
-#else /* GENERIC_TIME */
|
|
|
|
-
|
|
|
|
-static inline void timekeeping_forward_now(void) { }
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * ktime_get - get the monotonic time in ktime_t format
|
|
|
|
- *
|
|
|
|
- * returns the time in ktime_t format
|
|
|
|
- */
|
|
|
|
-ktime_t ktime_get(void)
|
|
|
|
-{
|
|
|
|
- struct timespec now;
|
|
|
|
-
|
|
|
|
- ktime_get_ts(&now);
|
|
|
|
-
|
|
|
|
- return timespec_to_ktime(now);
|
|
|
|
-}
|
|
|
|
-EXPORT_SYMBOL_GPL(ktime_get);
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * ktime_get_ts - get the monotonic clock in timespec format
|
|
|
|
- * @ts: pointer to timespec variable
|
|
|
|
- *
|
|
|
|
- * The function calculates the monotonic clock from the realtime
|
|
|
|
- * clock and the wall_to_monotonic offset and stores the result
|
|
|
|
- * in normalized timespec format in the variable pointed to by @ts.
|
|
|
|
- */
|
|
|
|
-void ktime_get_ts(struct timespec *ts)
|
|
|
|
-{
|
|
|
|
- struct timespec tomono;
|
|
|
|
- unsigned long seq;
|
|
|
|
-
|
|
|
|
- do {
|
|
|
|
- seq = read_seqbegin(&xtime_lock);
|
|
|
|
- getnstimeofday(ts);
|
|
|
|
- tomono = wall_to_monotonic;
|
|
|
|
-
|
|
|
|
- } while (read_seqretry(&xtime_lock, seq));
|
|
|
|
-
|
|
|
|
- set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec,
|
|
|
|
- ts->tv_nsec + tomono.tv_nsec);
|
|
|
|
-}
|
|
|
|
-EXPORT_SYMBOL_GPL(ktime_get_ts);
|
|
|
|
-
|
|
|
|
-#endif /* !GENERIC_TIME */
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* ktime_get_real - get the real (wall-) time in ktime_t format
|
|
* ktime_get_real - get the real (wall-) time in ktime_t format
|
|
*
|
|
*
|
|
@@ -579,9 +533,9 @@ static int timekeeping_resume(struct sys_device *dev)
|
|
|
|
|
|
if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) {
|
|
if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) {
|
|
ts = timespec_sub(ts, timekeeping_suspend_time);
|
|
ts = timespec_sub(ts, timekeeping_suspend_time);
|
|
- xtime = timespec_add_safe(xtime, ts);
|
|
|
|
|
|
+ xtime = timespec_add(xtime, ts);
|
|
wall_to_monotonic = timespec_sub(wall_to_monotonic, ts);
|
|
wall_to_monotonic = timespec_sub(wall_to_monotonic, ts);
|
|
- total_sleep_time = timespec_add_safe(total_sleep_time, ts);
|
|
|
|
|
|
+ total_sleep_time = timespec_add(total_sleep_time, ts);
|
|
}
|
|
}
|
|
/* re-base the last cycle value */
|
|
/* re-base the last cycle value */
|
|
timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock);
|
|
timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock);
|
|
@@ -784,10 +738,11 @@ void update_wall_time(void)
|
|
return;
|
|
return;
|
|
|
|
|
|
clock = timekeeper.clock;
|
|
clock = timekeeper.clock;
|
|
-#ifdef CONFIG_GENERIC_TIME
|
|
|
|
- offset = (clock->read(clock) - clock->cycle_last) & clock->mask;
|
|
|
|
-#else
|
|
|
|
|
|
+
|
|
|
|
+#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
|
|
offset = timekeeper.cycle_interval;
|
|
offset = timekeeper.cycle_interval;
|
|
|
|
+#else
|
|
|
|
+ offset = (clock->read(clock) - clock->cycle_last) & clock->mask;
|
|
#endif
|
|
#endif
|
|
timekeeper.xtime_nsec = (s64)xtime.tv_nsec << timekeeper.shift;
|
|
timekeeper.xtime_nsec = (s64)xtime.tv_nsec << timekeeper.shift;
|
|
|
|
|
|
@@ -856,7 +811,8 @@ void update_wall_time(void)
|
|
}
|
|
}
|
|
|
|
|
|
/* check to see if there is a new clocksource to use */
|
|
/* check to see if there is a new clocksource to use */
|
|
- update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult);
|
|
|
|
|
|
+ update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
|
|
|
|
+ timekeeper.mult);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -887,7 +843,7 @@ EXPORT_SYMBOL_GPL(getboottime);
|
|
*/
|
|
*/
|
|
void monotonic_to_bootbased(struct timespec *ts)
|
|
void monotonic_to_bootbased(struct timespec *ts)
|
|
{
|
|
{
|
|
- *ts = timespec_add_safe(*ts, total_sleep_time);
|
|
|
|
|
|
+ *ts = timespec_add(*ts, total_sleep_time);
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(monotonic_to_bootbased);
|
|
EXPORT_SYMBOL_GPL(monotonic_to_bootbased);
|
|
|
|
|
|
@@ -902,6 +858,11 @@ struct timespec __current_kernel_time(void)
|
|
return xtime;
|
|
return xtime;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+struct timespec __get_wall_to_monotonic(void)
|
|
|
|
+{
|
|
|
|
+ return wall_to_monotonic;
|
|
|
|
+}
|
|
|
|
+
|
|
struct timespec current_kernel_time(void)
|
|
struct timespec current_kernel_time(void)
|
|
{
|
|
{
|
|
struct timespec now;
|
|
struct timespec now;
|