diff options
-rw-r--r-- | include/linux/timex.h | 41 | ||||
-rw-r--r-- | kernel/time.c | 59 | ||||
-rw-r--r-- | kernel/timer.c | 13 |
3 files changed, 18 insertions, 95 deletions
diff --git a/include/linux/timex.h b/include/linux/timex.h index b7ca1204e42a..82dc9ae79d37 100644 --- a/include/linux/timex.h +++ b/include/linux/timex.h | |||
@@ -97,38 +97,11 @@ | |||
97 | 97 | ||
98 | #define MAXPHASE 512000L /* max phase error (us) */ | 98 | #define MAXPHASE 512000L /* max phase error (us) */ |
99 | #define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */ | 99 | #define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */ |
100 | #define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */ | ||
101 | #define MINSEC 16L /* min interval between updates (s) */ | 100 | #define MINSEC 16L /* min interval between updates (s) */ |
102 | #define MAXSEC 1200L /* max interval between updates (s) */ | 101 | #define MAXSEC 1200L /* max interval between updates (s) */ |
103 | #define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */ | 102 | #define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */ |
104 | 103 | ||
105 | /* | 104 | /* |
106 | * The following defines are used only if a pulse-per-second (PPS) | ||
107 | * signal is available and connected via a modem control lead, such as | ||
108 | * produced by the optional ppsclock feature incorporated in the Sun | ||
109 | * asynch driver. They establish the design parameters of the frequency- | ||
110 | * lock loop used to discipline the CPU clock oscillator to the PPS | ||
111 | * signal. | ||
112 | * | ||
113 | * PPS_AVG is the averaging factor for the frequency loop, as well as | ||
114 | * the time and frequency dispersion. | ||
115 | * | ||
116 | * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum | ||
117 | * calibration intervals, respectively, in seconds as a power of two. | ||
118 | * | ||
119 | * PPS_VALID is the maximum interval before the PPS signal is considered | ||
120 | * invalid and protocol updates used directly instead. | ||
121 | * | ||
122 | * MAXGLITCH is the maximum interval before a time offset of more than | ||
123 | * MAXTIME is believed. | ||
124 | */ | ||
125 | #define PPS_AVG 2 /* pps averaging constant (shift) */ | ||
126 | #define PPS_SHIFT 2 /* min interval duration (s) (shift) */ | ||
127 | #define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */ | ||
128 | #define PPS_VALID 120 /* pps signal watchdog max (s) */ | ||
129 | #define MAXGLITCH 30 /* pps signal glitch max (s) */ | ||
130 | |||
131 | /* | ||
132 | * syscall interface - used (mainly by NTP daemon) | 105 | * syscall interface - used (mainly by NTP daemon) |
133 | * to discipline kernel clock oscillator | 106 | * to discipline kernel clock oscillator |
134 | */ | 107 | */ |
@@ -246,20 +219,6 @@ extern long time_reftime; /* time at last adjustment (s) */ | |||
246 | extern long time_adjust; /* The amount of adjtime left */ | 219 | extern long time_adjust; /* The amount of adjtime left */ |
247 | extern long time_next_adjust; /* Value for time_adjust at next tick */ | 220 | extern long time_next_adjust; /* Value for time_adjust at next tick */ |
248 | 221 | ||
249 | /* interface variables pps->timer interrupt */ | ||
250 | extern long pps_offset; /* pps time offset (us) */ | ||
251 | extern long pps_jitter; /* time dispersion (jitter) (us) */ | ||
252 | extern long pps_freq; /* frequency offset (scaled ppm) */ | ||
253 | extern long pps_stabil; /* frequency dispersion (scaled ppm) */ | ||
254 | extern long pps_valid; /* pps signal watchdog counter */ | ||
255 | |||
256 | /* interface variables pps->adjtimex */ | ||
257 | extern int pps_shift; /* interval duration (s) (shift) */ | ||
258 | extern long pps_jitcnt; /* jitter limit exceeded */ | ||
259 | extern long pps_calcnt; /* calibration intervals */ | ||
260 | extern long pps_errcnt; /* calibration errors */ | ||
261 | extern long pps_stbcnt; /* stability limit exceeded */ | ||
262 | |||
263 | /** | 222 | /** |
264 | * ntp_clear - Clears the NTP state variables | 223 | * ntp_clear - Clears the NTP state variables |
265 | * | 224 | * |
diff --git a/kernel/time.c b/kernel/time.c index 804539165d8b..e00a97b77241 100644 --- a/kernel/time.c +++ b/kernel/time.c | |||
@@ -202,24 +202,6 @@ asmlinkage long sys_settimeofday(struct timeval __user *tv, | |||
202 | return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL); | 202 | return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL); |
203 | } | 203 | } |
204 | 204 | ||
205 | long pps_offset; /* pps time offset (us) */ | ||
206 | long pps_jitter = MAXTIME; /* time dispersion (jitter) (us) */ | ||
207 | |||
208 | long pps_freq; /* frequency offset (scaled ppm) */ | ||
209 | long pps_stabil = MAXFREQ; /* frequency dispersion (scaled ppm) */ | ||
210 | |||
211 | long pps_valid = PPS_VALID; /* pps signal watchdog counter */ | ||
212 | |||
213 | int pps_shift = PPS_SHIFT; /* interval duration (s) (shift) */ | ||
214 | |||
215 | long pps_jitcnt; /* jitter limit exceeded */ | ||
216 | long pps_calcnt; /* calibration intervals */ | ||
217 | long pps_errcnt; /* calibration errors */ | ||
218 | long pps_stbcnt; /* stability limit exceeded */ | ||
219 | |||
220 | /* hook for a loadable hardpps kernel module */ | ||
221 | void (*hardpps_ptr)(struct timeval *); | ||
222 | |||
223 | /* we call this to notify the arch when the clock is being | 205 | /* we call this to notify the arch when the clock is being |
224 | * controlled. If no such arch routine, do nothing. | 206 | * controlled. If no such arch routine, do nothing. |
225 | */ | 207 | */ |
@@ -279,7 +261,7 @@ int do_adjtimex(struct timex *txc) | |||
279 | result = -EINVAL; | 261 | result = -EINVAL; |
280 | goto leave; | 262 | goto leave; |
281 | } | 263 | } |
282 | time_freq = txc->freq - pps_freq; | 264 | time_freq = txc->freq; |
283 | } | 265 | } |
284 | 266 | ||
285 | if (txc->modes & ADJ_MAXERROR) { | 267 | if (txc->modes & ADJ_MAXERROR) { |
@@ -312,10 +294,8 @@ int do_adjtimex(struct timex *txc) | |||
312 | if ((time_next_adjust = txc->offset) == 0) | 294 | if ((time_next_adjust = txc->offset) == 0) |
313 | time_adjust = 0; | 295 | time_adjust = 0; |
314 | } | 296 | } |
315 | else if ( time_status & (STA_PLL | STA_PPSTIME) ) { | 297 | else if (time_status & STA_PLL) { |
316 | ltemp = (time_status & (STA_PPSTIME | STA_PPSSIGNAL)) == | 298 | ltemp = txc->offset; |
317 | (STA_PPSTIME | STA_PPSSIGNAL) ? | ||
318 | pps_offset : txc->offset; | ||
319 | 299 | ||
320 | /* | 300 | /* |
321 | * Scale the phase adjustment and | 301 | * Scale the phase adjustment and |
@@ -356,23 +336,14 @@ int do_adjtimex(struct timex *txc) | |||
356 | } | 336 | } |
357 | time_freq = min(time_freq, time_tolerance); | 337 | time_freq = min(time_freq, time_tolerance); |
358 | time_freq = max(time_freq, -time_tolerance); | 338 | time_freq = max(time_freq, -time_tolerance); |
359 | } /* STA_PLL || STA_PPSTIME */ | 339 | } /* STA_PLL */ |
360 | } /* txc->modes & ADJ_OFFSET */ | 340 | } /* txc->modes & ADJ_OFFSET */ |
361 | if (txc->modes & ADJ_TICK) { | 341 | if (txc->modes & ADJ_TICK) { |
362 | tick_usec = txc->tick; | 342 | tick_usec = txc->tick; |
363 | tick_nsec = TICK_USEC_TO_NSEC(tick_usec); | 343 | tick_nsec = TICK_USEC_TO_NSEC(tick_usec); |
364 | } | 344 | } |
365 | } /* txc->modes */ | 345 | } /* txc->modes */ |
366 | leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0 | 346 | leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0) |
367 | || ((time_status & (STA_PPSFREQ|STA_PPSTIME)) != 0 | ||
368 | && (time_status & STA_PPSSIGNAL) == 0) | ||
369 | /* p. 24, (b) */ | ||
370 | || ((time_status & (STA_PPSTIME|STA_PPSJITTER)) | ||
371 | == (STA_PPSTIME|STA_PPSJITTER)) | ||
372 | /* p. 24, (c) */ | ||
373 | || ((time_status & STA_PPSFREQ) != 0 | ||
374 | && (time_status & (STA_PPSWANDER|STA_PPSERROR)) != 0)) | ||
375 | /* p. 24, (d) */ | ||
376 | result = TIME_ERROR; | 347 | result = TIME_ERROR; |
377 | 348 | ||
378 | if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) | 349 | if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) |
@@ -380,7 +351,7 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0 | |||
380 | else { | 351 | else { |
381 | txc->offset = shift_right(time_offset, SHIFT_UPDATE); | 352 | txc->offset = shift_right(time_offset, SHIFT_UPDATE); |
382 | } | 353 | } |
383 | txc->freq = time_freq + pps_freq; | 354 | txc->freq = time_freq; |
384 | txc->maxerror = time_maxerror; | 355 | txc->maxerror = time_maxerror; |
385 | txc->esterror = time_esterror; | 356 | txc->esterror = time_esterror; |
386 | txc->status = time_status; | 357 | txc->status = time_status; |
@@ -388,14 +359,16 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0 | |||
388 | txc->precision = time_precision; | 359 | txc->precision = time_precision; |
389 | txc->tolerance = time_tolerance; | 360 | txc->tolerance = time_tolerance; |
390 | txc->tick = tick_usec; | 361 | txc->tick = tick_usec; |
391 | txc->ppsfreq = pps_freq; | 362 | |
392 | txc->jitter = pps_jitter >> PPS_AVG; | 363 | /* PPS is not implemented, so these are zero */ |
393 | txc->shift = pps_shift; | 364 | txc->ppsfreq = 0; |
394 | txc->stabil = pps_stabil; | 365 | txc->jitter = 0; |
395 | txc->jitcnt = pps_jitcnt; | 366 | txc->shift = 0; |
396 | txc->calcnt = pps_calcnt; | 367 | txc->stabil = 0; |
397 | txc->errcnt = pps_errcnt; | 368 | txc->jitcnt = 0; |
398 | txc->stbcnt = pps_stbcnt; | 369 | txc->calcnt = 0; |
370 | txc->errcnt = 0; | ||
371 | txc->stbcnt = 0; | ||
399 | write_sequnlock_irq(&xtime_lock); | 372 | write_sequnlock_irq(&xtime_lock); |
400 | do_gettimeofday(&txc->time); | 373 | do_gettimeofday(&txc->time); |
401 | notify_arch_cmos_timer(); | 374 | notify_arch_cmos_timer(); |
diff --git a/kernel/timer.c b/kernel/timer.c index 13fa72cac7d8..ab189dd187cb 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -697,18 +697,9 @@ static void second_overflow(void) | |||
697 | 697 | ||
698 | /* | 698 | /* |
699 | * Compute the frequency estimate and additional phase adjustment due | 699 | * Compute the frequency estimate and additional phase adjustment due |
700 | * to frequency error for the next second. When the PPS signal is | 700 | * to frequency error for the next second. |
701 | * engaged, gnaw on the watchdog counter and update the frequency | ||
702 | * computed by the pll and the PPS signal. | ||
703 | */ | 701 | */ |
704 | pps_valid++; | 702 | ltemp = time_freq; |
705 | if (pps_valid == PPS_VALID) { /* PPS signal lost */ | ||
706 | pps_jitter = MAXTIME; | ||
707 | pps_stabil = MAXFREQ; | ||
708 | time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER | | ||
709 | STA_PPSWANDER | STA_PPSERROR); | ||
710 | } | ||
711 | ltemp = time_freq + pps_freq; | ||
712 | time_adj += shift_right(ltemp,(SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE)); | 703 | time_adj += shift_right(ltemp,(SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE)); |
713 | 704 | ||
714 | #if HZ == 100 | 705 | #if HZ == 100 |