Commit 76f41088 authored by John Stultz's avatar John Stultz

hrtimer: Cleanup hrtimer accessors to the timekepeing state

Rather then having two similar but totally different implementations
that provide timekeeping state to the hrtimer code, try to unify the
two implementations to be more simliar.

Thus this clarifies ktime_get_update_offsets to
ktime_get_update_offsets_now and changes get_xtime...  to
ktime_get_update_offsets_tick.
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent e06fde37
...@@ -331,9 +331,12 @@ extern ktime_t ktime_get_real(void); ...@@ -331,9 +331,12 @@ extern ktime_t ktime_get_real(void);
extern ktime_t ktime_get_boottime(void); extern ktime_t ktime_get_boottime(void);
extern ktime_t ktime_get_monotonic_offset(void); extern ktime_t ktime_get_monotonic_offset(void);
extern ktime_t ktime_get_clocktai(void); extern ktime_t ktime_get_clocktai(void);
extern ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot, extern ktime_t ktime_get_update_offsets_tick(ktime_t *offs_real,
ktime_t *offs_boot,
ktime_t *offs_tai);
extern ktime_t ktime_get_update_offsets_now(ktime_t *offs_real,
ktime_t *offs_boot,
ktime_t *offs_tai); ktime_t *offs_tai);
DECLARE_PER_CPU(struct tick_device, tick_cpu_device); DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
......
...@@ -133,8 +133,6 @@ unsigned long get_seconds(void); ...@@ -133,8 +133,6 @@ unsigned long get_seconds(void);
struct timespec current_kernel_time(void); struct timespec current_kernel_time(void);
struct timespec __current_kernel_time(void); /* does not take xtime_lock */ struct timespec __current_kernel_time(void); /* does not take xtime_lock */
struct timespec get_monotonic_coarse(void); struct timespec get_monotonic_coarse(void);
void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
struct timespec *wtom, struct timespec *sleep);
void timekeeping_inject_sleeptime(struct timespec *delta); void timekeeping_inject_sleeptime(struct timespec *delta);
#define CURRENT_TIME (current_kernel_time()) #define CURRENT_TIME (current_kernel_time())
......
...@@ -114,21 +114,18 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id) ...@@ -114,21 +114,18 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
*/ */
static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base) static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
{ {
ktime_t xtim, mono, boot; ktime_t xtim, mono, boot, tai;
struct timespec xts, tom, slp; ktime_t off_real, off_boot, off_tai;
s32 tai_offset;
get_xtime_and_monotonic_and_sleep_offset(&xts, &tom, &slp); mono = ktime_get_update_offsets_tick(&off_real, &off_boot, &off_tai);
tai_offset = timekeeping_get_tai_offset(); boot = ktime_add(mono, off_boot);
xtim = ktime_add(mono, off_real);
tai = ktime_add(xtim, off_tai);
xtim = timespec_to_ktime(xts);
mono = ktime_add(xtim, timespec_to_ktime(tom));
boot = ktime_add(mono, timespec_to_ktime(slp));
base->clock_base[HRTIMER_BASE_REALTIME].softirq_time = xtim; base->clock_base[HRTIMER_BASE_REALTIME].softirq_time = xtim;
base->clock_base[HRTIMER_BASE_MONOTONIC].softirq_time = mono; base->clock_base[HRTIMER_BASE_MONOTONIC].softirq_time = mono;
base->clock_base[HRTIMER_BASE_BOOTTIME].softirq_time = boot; base->clock_base[HRTIMER_BASE_BOOTTIME].softirq_time = boot;
base->clock_base[HRTIMER_BASE_TAI].softirq_time = base->clock_base[HRTIMER_BASE_TAI].softirq_time = tai;
ktime_add(xtim, ktime_set(tai_offset, 0));
} }
/* /*
...@@ -673,7 +670,7 @@ static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base) ...@@ -673,7 +670,7 @@ static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base)
ktime_t *offs_boot = &base->clock_base[HRTIMER_BASE_BOOTTIME].offset; ktime_t *offs_boot = &base->clock_base[HRTIMER_BASE_BOOTTIME].offset;
ktime_t *offs_tai = &base->clock_base[HRTIMER_BASE_TAI].offset; ktime_t *offs_tai = &base->clock_base[HRTIMER_BASE_TAI].offset;
return ktime_get_update_offsets(offs_real, offs_boot, offs_tai); return ktime_get_update_offsets_now(offs_real, offs_boot, offs_tai);
} }
/* /*
......
...@@ -1581,29 +1581,39 @@ void do_timer(unsigned long ticks) ...@@ -1581,29 +1581,39 @@ void do_timer(unsigned long ticks)
} }
/** /**
* get_xtime_and_monotonic_and_sleep_offset() - get xtime, wall_to_monotonic, * ktime_get_update_offsets_tick - hrtimer helper
* and sleep offsets. * @offs_real: pointer to storage for monotonic -> realtime offset
* @xtim: pointer to timespec to be set with xtime * @offs_boot: pointer to storage for monotonic -> boottime offset
* @wtom: pointer to timespec to be set with wall_to_monotonic * @offs_tai: pointer to storage for monotonic -> clock tai offset
* @sleep: pointer to timespec to be set with time in suspend *
*/ * Returns monotonic time at last tick and various offsets
void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim, */
struct timespec *wtom, struct timespec *sleep) ktime_t ktime_get_update_offsets_tick(ktime_t *offs_real, ktime_t *offs_boot,
ktime_t *offs_tai)
{ {
struct timekeeper *tk = &timekeeper; struct timekeeper *tk = &timekeeper;
unsigned long seq; struct timespec ts;
ktime_t now;
unsigned int seq;
do { do {
seq = read_seqcount_begin(&timekeeper_seq); seq = read_seqcount_begin(&timekeeper_seq);
*xtim = tk_xtime(tk);
*wtom = tk->wall_to_monotonic; ts = tk_xtime(tk);
*sleep = tk->total_sleep_time;
*offs_real = tk->offs_real;
*offs_boot = tk->offs_boot;
*offs_tai = tk->offs_tai;
} while (read_seqcount_retry(&timekeeper_seq, seq)); } while (read_seqcount_retry(&timekeeper_seq, seq));
now = ktime_set(ts.tv_sec, ts.tv_nsec);
now = ktime_sub(now, *offs_real);
return now;
} }
#ifdef CONFIG_HIGH_RES_TIMERS #ifdef CONFIG_HIGH_RES_TIMERS
/** /**
* ktime_get_update_offsets - hrtimer helper * ktime_get_update_offsets_now - hrtimer helper
* @offs_real: pointer to storage for monotonic -> realtime offset * @offs_real: pointer to storage for monotonic -> realtime offset
* @offs_boot: pointer to storage for monotonic -> boottime offset * @offs_boot: pointer to storage for monotonic -> boottime offset
* @offs_tai: pointer to storage for monotonic -> clock tai offset * @offs_tai: pointer to storage for monotonic -> clock tai offset
...@@ -1611,7 +1621,7 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim, ...@@ -1611,7 +1621,7 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
* Returns current monotonic time and updates the offsets * Returns current monotonic time and updates the offsets
* Called from hrtimer_interrupt() or retrigger_next_event() * Called from hrtimer_interrupt() or retrigger_next_event()
*/ */
ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot, ktime_t ktime_get_update_offsets_now(ktime_t *offs_real, ktime_t *offs_boot,
ktime_t *offs_tai) ktime_t *offs_tai)
{ {
struct timekeeper *tk = &timekeeper; struct timekeeper *tk = &timekeeper;
......
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