Commit d004e024 authored by Hector Palacios's avatar Hector Palacios Committed by John Stultz

timekeeping: add arch_offset hook to ktime_get functions

ktime_get and ktime_get_ts were calling timekeeping_get_ns()
but later they were not calling arch_gettimeoffset() so architectures
using this mechanism returned 0 ns when calling these functions.

This happened for example when running Busybox's ping which calls
syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts) which eventually
calls ktime_get. As a result the returned ping travel time was zero.

CC: stable@kernel.org
Signed-off-by: default avatarHector Palacios <hector.palacios@digi.com>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent 367177e5
...@@ -249,6 +249,8 @@ ktime_t ktime_get(void) ...@@ -249,6 +249,8 @@ ktime_t ktime_get(void)
secs = xtime.tv_sec + wall_to_monotonic.tv_sec; secs = xtime.tv_sec + wall_to_monotonic.tv_sec;
nsecs = xtime.tv_nsec + wall_to_monotonic.tv_nsec; nsecs = xtime.tv_nsec + wall_to_monotonic.tv_nsec;
nsecs += timekeeping_get_ns(); nsecs += timekeeping_get_ns();
/* If arch requires, add in gettimeoffset() */
nsecs += arch_gettimeoffset();
} while (read_seqretry(&xtime_lock, seq)); } while (read_seqretry(&xtime_lock, seq));
/* /*
...@@ -280,6 +282,8 @@ void ktime_get_ts(struct timespec *ts) ...@@ -280,6 +282,8 @@ void ktime_get_ts(struct timespec *ts)
*ts = xtime; *ts = xtime;
tomono = wall_to_monotonic; tomono = wall_to_monotonic;
nsecs = timekeeping_get_ns(); nsecs = timekeeping_get_ns();
/* If arch requires, add in gettimeoffset() */
nsecs += arch_gettimeoffset();
} while (read_seqretry(&xtime_lock, seq)); } while (read_seqretry(&xtime_lock, seq));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment