summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0082-timekeeping-Provide-hrtimer-update-function.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0082-timekeeping-Provide-hrtimer-update-function.patch')
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0082-timekeeping-Provide-hrtimer-update-function.patch94
1 files changed, 94 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0082-timekeeping-Provide-hrtimer-update-function.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0082-timekeeping-Provide-hrtimer-update-function.patch
new file mode 100644
index 00000000..a9735408
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0082-timekeeping-Provide-hrtimer-update-function.patch
@@ -0,0 +1,94 @@
1From d6cadfb2bf29a5913562d3f63c49a937bc98540d Mon Sep 17 00:00:00 2001
2From: Thomas Gleixner <tglx@linutronix.de>
3Date: Tue, 10 Jul 2012 18:43:24 -0400
4Subject: [PATCH 082/109] timekeeping: Provide hrtimer update function
5
6This is a backport of f6c06abfb3972ad4914cef57d8348fcb2932bc3b
7
8To finally fix the infamous leap second issue and other race windows
9caused by functions which change the offsets between the various time
10bases (CLOCK_MONOTONIC, CLOCK_REALTIME and CLOCK_BOOTTIME) we need a
11function which atomically gets the current monotonic time and updates
12the offsets of CLOCK_REALTIME and CLOCK_BOOTTIME with minimalistic
13overhead. The previous patch which provides ktime_t offsets allows us
14to make this function almost as cheap as ktime_get() which is going to
15be replaced in hrtimer_interrupt().
16
17Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
18Reviewed-by: Ingo Molnar <mingo@kernel.org>
19Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
20Acked-by: Prarit Bhargava <prarit@redhat.com>
21Signed-off-by: John Stultz <johnstul@us.ibm.com>
22Link: http://lkml.kernel.org/r/1341960205-56738-7-git-send-email-johnstul@us.ibm.com
23Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
24[John Stultz: Backported to 3.2]
25Cc: Prarit Bhargava <prarit@redhat.com>
26Cc: Thomas Gleixner <tglx@linutronix.de>
27Cc: Linux Kernel <linux-kernel@vger.kernel.org>
28Signed-off-by: John Stultz <johnstul@us.ibm.com>
29Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
30---
31 include/linux/hrtimer.h | 1 +
32 kernel/time/timekeeping.c | 34 ++++++++++++++++++++++++++++++++++
33 2 files changed, 35 insertions(+), 0 deletions(-)
34
35diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
36index c9ec940..cc07d27 100644
37--- a/include/linux/hrtimer.h
38+++ b/include/linux/hrtimer.h
39@@ -327,6 +327,7 @@ extern ktime_t ktime_get(void);
40 extern ktime_t ktime_get_real(void);
41 extern ktime_t ktime_get_boottime(void);
42 extern ktime_t ktime_get_monotonic_offset(void);
43+extern ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot);
44
45 DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
46
47diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
48index d5d0e5d..4938c5e 100644
49--- a/kernel/time/timekeeping.c
50+++ b/kernel/time/timekeeping.c
51@@ -1240,6 +1240,40 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
52 } while (read_seqretry(&xtime_lock, seq));
53 }
54
55+#ifdef CONFIG_HIGH_RES_TIMERS
56+/**
57+ * ktime_get_update_offsets - hrtimer helper
58+ * @real: pointer to storage for monotonic -> realtime offset
59+ * @_boot: pointer to storage for monotonic -> boottime offset
60+ *
61+ * Returns current monotonic time and updates the offsets
62+ * Called from hrtimer_interupt() or retrigger_next_event()
63+ */
64+ktime_t ktime_get_update_offsets(ktime_t *real, ktime_t *boot)
65+{
66+ ktime_t now;
67+ unsigned int seq;
68+ u64 secs, nsecs;
69+
70+ do {
71+ seq = read_seqbegin(&xtime_lock);
72+
73+ secs = xtime.tv_sec;
74+ nsecs = xtime.tv_nsec;
75+ nsecs += timekeeping_get_ns();
76+ /* If arch requires, add in gettimeoffset() */
77+ nsecs += arch_gettimeoffset();
78+
79+ *real = offs_real;
80+ *boot = offs_boot;
81+ } while (read_seqretry(&xtime_lock, seq));
82+
83+ now = ktime_add_ns(ktime_set(secs, 0), nsecs);
84+ now = ktime_sub(now, *real);
85+ return now;
86+}
87+#endif
88+
89 /**
90 * ktime_get_monotonic_offset() - get wall_to_monotonic in ktime_t format
91 */
92--
931.7.7.6
94