aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/clocksource.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/clocksource.h')
-rw-r--r--include/linux/clocksource.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 55e434feec99..f88d32f8ff7c 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -45,7 +45,8 @@ struct clocksource;
45 * @read: returns a cycle value 45 * @read: returns a cycle value
46 * @mask: bitmask for two's complement 46 * @mask: bitmask for two's complement
47 * subtraction of non 64 bit counters 47 * subtraction of non 64 bit counters
48 * @mult: cycle to nanosecond multiplier 48 * @mult: cycle to nanosecond multiplier (adjusted by NTP)
49 * @mult_orig: cycle to nanosecond multiplier (unadjusted by NTP)
49 * @shift: cycle to nanosecond divisor (power of two) 50 * @shift: cycle to nanosecond divisor (power of two)
50 * @flags: flags describing special properties 51 * @flags: flags describing special properties
51 * @vread: vsyscall based read 52 * @vread: vsyscall based read
@@ -63,6 +64,7 @@ struct clocksource {
63 cycle_t (*read)(void); 64 cycle_t (*read)(void);
64 cycle_t mask; 65 cycle_t mask;
65 u32 mult; 66 u32 mult;
67 u32 mult_orig;
66 u32 shift; 68 u32 shift;
67 unsigned long flags; 69 unsigned long flags;
68 cycle_t (*vread)(void); 70 cycle_t (*vread)(void);
@@ -77,6 +79,7 @@ struct clocksource {
77 /* timekeeping specific data, ignore */ 79 /* timekeeping specific data, ignore */
78 cycle_t cycle_interval; 80 cycle_t cycle_interval;
79 u64 xtime_interval; 81 u64 xtime_interval;
82 u32 raw_interval;
80 /* 83 /*
81 * Second part is written at each timer interrupt 84 * Second part is written at each timer interrupt
82 * Keep it in a different cache line to dirty no 85 * Keep it in a different cache line to dirty no
@@ -85,6 +88,7 @@ struct clocksource {
85 cycle_t cycle_last ____cacheline_aligned_in_smp; 88 cycle_t cycle_last ____cacheline_aligned_in_smp;
86 u64 xtime_nsec; 89 u64 xtime_nsec;
87 s64 error; 90 s64 error;
91 struct timespec raw_time;
88 92
89#ifdef CONFIG_CLOCKSOURCE_WATCHDOG 93#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
90 /* Watchdog related data, used by the framework */ 94 /* Watchdog related data, used by the framework */
@@ -201,17 +205,19 @@ static inline void clocksource_calculate_interval(struct clocksource *c,
201{ 205{
202 u64 tmp; 206 u64 tmp;
203 207
204 /* XXX - All of this could use a whole lot of optimization */ 208 /* Do the ns -> cycle conversion first, using original mult */
205 tmp = length_nsec; 209 tmp = length_nsec;
206 tmp <<= c->shift; 210 tmp <<= c->shift;
207 tmp += c->mult/2; 211 tmp += c->mult_orig/2;
208 do_div(tmp, c->mult); 212 do_div(tmp, c->mult_orig);
209 213
210 c->cycle_interval = (cycle_t)tmp; 214 c->cycle_interval = (cycle_t)tmp;
211 if (c->cycle_interval == 0) 215 if (c->cycle_interval == 0)
212 c->cycle_interval = 1; 216 c->cycle_interval = 1;
213 217
218 /* Go back from cycles -> shifted ns, this time use ntp adjused mult */
214 c->xtime_interval = (u64)c->cycle_interval * c->mult; 219 c->xtime_interval = (u64)c->cycle_interval * c->mult;
220 c->raw_interval = ((u64)c->cycle_interval * c->mult_orig) >> c->shift;
215} 221}
216 222
217 223