aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/time.h15
-rw-r--r--kernel/time/timekeeping.c7
2 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/time.h b/include/linux/time.h
index 242f62499bb7..ea16c1a01d51 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -113,6 +113,21 @@ struct timespec current_kernel_time(void);
113#define CURRENT_TIME (current_kernel_time()) 113#define CURRENT_TIME (current_kernel_time())
114#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) 114#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })
115 115
116/* Some architectures do not supply their own clocksource.
117 * This is mainly the case in architectures that get their
118 * inter-tick times by reading the counter on their interval
119 * timer. Since these timers wrap every tick, they're not really
120 * useful as clocksources. Wrapping them to act like one is possible
121 * but not very efficient. So we provide a callout these arches
122 * can implement for use with the jiffies clocksource to provide
123 * finer then tick granular time.
124 */
125#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
126extern u32 arch_gettimeoffset(void);
127#else
128static inline u32 arch_gettimeoffset(void) { return 0; }
129#endif
130
116extern void do_gettimeofday(struct timeval *tv); 131extern void do_gettimeofday(struct timeval *tv);
117extern int do_settimeofday(struct timespec *tv); 132extern int do_settimeofday(struct timespec *tv);
118extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz); 133extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 687dff49f6e7..e97c50f8458b 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -77,6 +77,10 @@ static void clocksource_forward_now(void)
77 clock->cycle_last = cycle_now; 77 clock->cycle_last = cycle_now;
78 78
79 nsec = cyc2ns(clock, cycle_delta); 79 nsec = cyc2ns(clock, cycle_delta);
80
81 /* If arch requires, add in gettimeoffset() */
82 nsec += arch_gettimeoffset();
83
80 timespec_add_ns(&xtime, nsec); 84 timespec_add_ns(&xtime, nsec);
81 85
82 nsec = ((s64)cycle_delta * clock->mult_orig) >> clock->shift; 86 nsec = ((s64)cycle_delta * clock->mult_orig) >> clock->shift;
@@ -111,6 +115,9 @@ void getnstimeofday(struct timespec *ts)
111 /* convert to nanoseconds: */ 115 /* convert to nanoseconds: */
112 nsecs = cyc2ns(clock, cycle_delta); 116 nsecs = cyc2ns(clock, cycle_delta);
113 117
118 /* If arch requires, add in gettimeoffset() */
119 nsecs += arch_gettimeoffset();
120
114 } while (read_seqretry(&xtime_lock, seq)); 121 } while (read_seqretry(&xtime_lock, seq));
115 122
116 timespec_add_ns(ts, nsecs); 123 timespec_add_ns(ts, nsecs);