]> git.karo-electronics.de Git - linux-beck.git/commitdiff
hrtimer: Cleanup hrtimer accessors to the timekepeing state
authorJohn Stultz <john.stultz@linaro.org>
Wed, 16 Jul 2014 21:03:52 +0000 (21:03 +0000)
committerJohn Stultz <john.stultz@linaro.org>
Wed, 23 Jul 2014 17:16:50 +0000 (10:16 -0700)
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: John Stultz <john.stultz@linaro.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
include/linux/hrtimer.h
include/linux/time.h
kernel/time/hrtimer.c
kernel/time/timekeeping.c

index bb4ffff31c69bdd50b8a66716df6d58d5af76ff6..e84eb4f228cd922fab26dd90ccf8bab5353cdba3 100644 (file)
@@ -331,9 +331,12 @@ extern ktime_t ktime_get_real(void);
 extern ktime_t ktime_get_boottime(void);
 extern ktime_t ktime_get_monotonic_offset(void);
 extern ktime_t ktime_get_clocktai(void);
-extern ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot,
-                                        ktime_t *offs_tai);
-
+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);
 DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
 
 
index d5d229b2e5af1815d38d7d87d217ee8340b9ec1d..f6d990d1c79aaaa72d8c416897d89f2339f36cbe 100644 (file)
@@ -133,8 +133,6 @@ unsigned long get_seconds(void);
 struct timespec current_kernel_time(void);
 struct timespec __current_kernel_time(void); /* does not take xtime_lock */
 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);
 
 #define CURRENT_TIME           (current_kernel_time())
index 66a6dc1075adc0bfbfa35789fa184c1de7f31293..2f4ef8a1e5ff737370dcf45395b18a1733d7b0c5 100644 (file)
@@ -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)
 {
-       ktime_t xtim, mono, boot;
-       struct timespec xts, tom, slp;
-       s32 tai_offset;
+       ktime_t xtim, mono, boot, tai;
+       ktime_t off_real, off_boot, off_tai;
 
-       get_xtime_and_monotonic_and_sleep_offset(&xts, &tom, &slp);
-       tai_offset = timekeeping_get_tai_offset();
+       mono = ktime_get_update_offsets_tick(&off_real, &off_boot, &off_tai);
+       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_MONOTONIC].softirq_time = mono;
        base->clock_base[HRTIMER_BASE_BOOTTIME].softirq_time = boot;
-       base->clock_base[HRTIMER_BASE_TAI].softirq_time =
-                               ktime_add(xtim, ktime_set(tai_offset, 0));
+       base->clock_base[HRTIMER_BASE_TAI].softirq_time = tai;
 }
 
 /*
@@ -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_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);
 }
 
 /*
index 908861c58e62fd1e95b149f69d53f612c54a005f..b94fa3652aaa8325103157668976ab2e0ce1bda3 100644 (file)
@@ -1581,29 +1581,39 @@ void do_timer(unsigned long ticks)
 }
 
 /**
- * get_xtime_and_monotonic_and_sleep_offset() - get xtime, wall_to_monotonic,
- *    and sleep offsets.
- * @xtim:      pointer to timespec to be set with xtime
- * @wtom:      pointer to timespec to be set with wall_to_monotonic
- * @sleep:     pointer to timespec to be set with time in suspend
+ * ktime_get_update_offsets_tick - hrtimer helper
+ * @offs_real: pointer to storage for monotonic -> realtime offset
+ * @offs_boot: pointer to storage for monotonic -> boottime offset
+ * @offs_tai:  pointer to storage for monotonic -> clock tai offset
+ *
+ * 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;
-       unsigned long seq;
+       struct timespec ts;
+       ktime_t now;
+       unsigned int seq;
 
        do {
                seq = read_seqcount_begin(&timekeeper_seq);
-               *xtim = tk_xtime(tk);
-               *wtom = tk->wall_to_monotonic;
-               *sleep = tk->total_sleep_time;
+
+               ts = tk_xtime(tk);
+
+               *offs_real = tk->offs_real;
+               *offs_boot = tk->offs_boot;
+               *offs_tai = tk->offs_tai;
        } 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
 /**
- * ktime_get_update_offsets - hrtimer helper
+ * ktime_get_update_offsets_now - hrtimer helper
  * @offs_real: pointer to storage for monotonic -> realtime offset
  * @offs_boot: pointer to storage for monotonic -> boottime 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,
  * Returns current monotonic time and updates the offsets
  * 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)
 {
        struct timekeeper *tk = &timekeeper;