Messages in this thread Patch in this message | | | From | "Ulrich Windl" <> | Date | Fri, 12 Mar 1999 08:20:22 +0100 | Subject | patch (defect repair, 2.2.3): improved NTP conformance |
| |
Hello,
I'll announce PPSkit-0.5.1 in a moment, but I have extracted a short patch for the stable kernel that should go in without any problem.
The main fix is the return value of adjtimex(), and a few other things are simplyfied. I put questionable code in a
#if 1 /* yes, not "0" */ ... #endif
bracket, so maybe the maintainers of these architectures (Sparc, I think) should have a look...
Regards, Ulrich
Index: arch/alpha/kernel/time.c =================================================================== RCS file: /root/21REP/linux21/arch/alpha/kernel/time.c,v retrieving revision 1.1.1.3 diff -u -r1.1.1.3 time.c --- time.c 1999/01/22 18:45:37 1.1.1.3 +++ time.c 1999/03/11 19:05:41 @@ -357,7 +357,6 @@ xtime = *tv; time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; sti(); Index: arch/arm/kernel/time.c =================================================================== RCS file: /root/21REP/linux21/arch/arm/kernel/time.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 time.c --- time.c 1999/01/22 18:45:42 1.1.1.2 +++ time.c 1999/03/11 19:06:38 @@ -127,7 +127,6 @@ xtime = *tv; time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; sti (); Index: arch/i386/kernel/time.c =================================================================== RCS file: /root/21REP/linux21/arch/i386/kernel/time.c,v retrieving revision 1.1.1.5 diff -u -r1.1.1.5 time.c --- time.c 1999/03/09 18:47:34 1.1.1.5 +++ time.c 1999/03/11 19:06:59 @@ -279,7 +279,6 @@ xtime = *tv; time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; write_unlock_irq(&xtime_lock); Index: arch/m68k/kernel/time.c =================================================================== RCS file: /root/21REP/linux21/arch/m68k/kernel/time.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 time.c --- time.c 1999/01/22 18:46:28 1.1.1.2 +++ time.c 1999/03/11 19:07:30 @@ -198,7 +198,6 @@ xtime = *tv; time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; sti(); Index: arch/mips/kernel/sysirix.c =================================================================== RCS file: /root/21REP/linux21/arch/mips/kernel/sysirix.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 sysirix.c --- sysirix.c 1998/11/05 17:58:29 1.1.1.1 +++ sysirix.c 1999/03/11 19:07:55 @@ -627,7 +627,6 @@ cli(); xtime.tv_sec = value; xtime.tv_usec = 0; - time_state = TIME_ERROR; time_maxerror = MAXPHASE; time_esterror = MAXPHASE; sti(); Index: arch/mips/kernel/time.c =================================================================== RCS file: /root/21REP/linux21/arch/mips/kernel/time.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 time.c --- time.c 1999/01/22 18:46:40 1.1.1.2 +++ time.c 1999/03/11 19:08:12 @@ -260,7 +260,6 @@ xtime = *tv; time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; sti(); Index: arch/mips/sgi/kernel/indy_timer.c =================================================================== RCS file: /root/21REP/linux21/arch/mips/sgi/kernel/indy_timer.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 indy_timer.c --- indy_timer.c 1998/10/20 20:52:55 1.1.1.1 +++ indy_timer.c 1999/03/11 19:09:45 @@ -104,9 +104,10 @@ * absolutely sure we do this update within 500ms before the * next second starts, thus the following code. */ - if (time_state != TIME_BAD && xtime.tv_sec > last_rtc_update + 660 && - xtime.tv_usec > 500000 - (tick >> 1) && - xtime.tv_usec < 500000 + (tick >> 1)) + if ((time_status & STA_UNSYNC) == 0 && + xtime.tv_sec > last_rtc_update + 660 && + xtime.tv_usec >= 500000 - (tick >> 1) && + xtime.tv_usec <= 500000 + (tick >> 1)) if (set_rtc_mmss(xtime.tv_sec) == 0) last_rtc_update = xtime.tv_sec; else Index: arch/ppc/kernel/chrp_time.c =================================================================== RCS file: /root/21REP/linux21/arch/ppc/kernel/chrp_time.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 chrp_time.c --- chrp_time.c 1998/05/08 07:18:14 1.1.1.1 +++ chrp_time.c 1999/03/11 19:11:04 @@ -106,8 +106,10 @@ chrp_cmos_clock_write(save_control, RTC_CONTROL); chrp_cmos_clock_write(save_freq_select, RTC_FREQ_SELECT); +#if 1 /* I think we don't need this -- UW */ if ( (time_state == TIME_ERROR) || (time_state == TIME_BAD) ) time_state = TIME_OK; +#endif return 0; } Index: arch/ppc/kernel/prep_time.c =================================================================== RCS file: /root/21REP/linux21/arch/ppc/kernel/prep_time.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 prep_time.c --- prep_time.c 1998/08/04 23:06:36 1.1.1.1 +++ prep_time.c 1999/03/11 19:11:58 @@ -133,8 +133,10 @@ prep_cmos_clock_write(save_control, RTC_CONTROL); prep_cmos_clock_write(save_freq_select, RTC_FREQ_SELECT); +#if 1 /* I think we do not need this */ if ( (time_state == TIME_ERROR) || (time_state == TIME_BAD) ) time_state = TIME_OK; +#endif return 0; } Index: arch/ppc/kernel/time.c =================================================================== RCS file: /root/21REP/linux21/arch/ppc/kernel/time.c,v retrieving revision 1.1.1.4 diff -u -r1.1.1.4 time.c --- time.c 1999/01/22 18:46:48 1.1.1.4 +++ time.c 1999/03/11 19:12:15 @@ -200,7 +200,6 @@ set_dec(frac_tick * count_period_den / count_period_num); time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; restore_flags(flags); Index: arch/sparc/kernel/pcic.c =================================================================== RCS file: /root/21REP/linux21/arch/sparc/kernel/pcic.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 pcic.c --- pcic.c 1998/10/27 17:52:20 1.1.1.1 +++ pcic.c 1999/03/11 19:13:33 @@ -498,7 +498,8 @@ tv->tv_sec--; } xtime = *tv; - time_state = TIME_BAD; + time_status |= STA_UNSYNC; + time_adjust = 0; /* stop active adjtime() */ time_maxerror = 0x70000000; time_esterror = 0x70000000; sti(); Index: arch/sparc/kernel/time.c =================================================================== RCS file: /root/21REP/linux21/arch/sparc/kernel/time.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 time.c --- time.c 1999/01/22 18:46:53 1.1.1.2 +++ time.c 1999/03/11 19:13:51 @@ -501,7 +501,6 @@ xtime = *tv; time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; sti(); Index: arch/sparc64/kernel/time.c =================================================================== RCS file: /root/21REP/linux21/arch/sparc64/kernel/time.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 time.c --- time.c 1999/01/22 18:47:02 1.1.1.2 +++ time.c 1999/03/11 19:14:45 @@ -461,7 +461,6 @@ xtime = *tv; time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; sti(); Index: kernel/sched.c =================================================================== RCS file: /root/21REP/linux21/kernel/sched.c,v retrieving revision 1.1.1.4 diff -u -r1.1.1.4 sched.c --- sched.c 1999/02/23 18:21:08 1.1.1.4 +++ sched.c 1999/03/11 19:04:36 @@ -3,7 +3,6 @@ * * Copyright (C) 1991, 1992 Linus Torvalds * - * 1996-04-21 Modified by Ulrich Windl to make NTP work * 1996-12-23 Modified by Dave Grothe to fix bugs in semaphores and * make semaphores SMP safe * 1997-01-28 Modified by Finn Arne Gangstad to make timers scale better. @@ -15,6 +14,7 @@ * serialize accesses to xtime/lost_ticks). * Copyright (C) 1998 Andrea Arcangeli * 1998-12-28 Implemented better SMP scheduling by Ingo Molnar + * 1999-03-10 Improved NTP compatibility by Ulrich Windl */ /* @@ -62,7 +62,7 @@ * phase-lock loop variables */ /* TIME_ERROR prevents overwriting the CMOS clock */ -int time_state = TIME_ERROR; /* clock synchronization status */ +int time_state = TIME_OK; /* clock synchronization status */ int time_status = STA_UNSYNC; /* clock status bits */ long time_offset = 0; /* time adjustment (us) */ long time_constant = 2; /* pll time constant */ @@ -1138,7 +1138,6 @@ time_maxerror += time_tolerance >> SHIFT_USEC; if ( time_maxerror > NTP_PHASE_LIMIT ) { time_maxerror = NTP_PHASE_LIMIT; - time_state = TIME_ERROR; /* p. 17, sect. 4.3, (b) */ time_status |= STA_UNSYNC; } Index: kernel/time.c =================================================================== RCS file: /root/21REP/linux21/kernel/time.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 time.c --- time.c 1999/01/22 18:53:22 1.1.1.2 +++ time.c 1999/03/11 19:02:00 @@ -96,7 +96,6 @@ xtime.tv_usec = 0; time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; - time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; sti(); @@ -221,7 +220,7 @@ int do_adjtimex(struct timex *txc) { long ltemp, mtemp, save_adjust; - int error = 0; + int result = time_state; /* mostly `TIME_OK' */ /* In order to modify anything, you gotta be super-user! */ if (txc->modes && !capable(CAP_SYS_TIME)) @@ -250,16 +249,13 @@ /* If there are input parameters, then process them */ if (txc->modes) { - if (time_state == TIME_ERROR) - time_state = TIME_OK; /* reset error -- why? */ - if (txc->modes & ADJ_STATUS) /* only set allowed bits */ time_status = (txc->status & ~STA_RONLY) | (time_status & STA_RONLY); if (txc->modes & ADJ_FREQUENCY) { /* p. 22 */ if (txc->freq > MAXFREQ || txc->freq < -MAXFREQ) { - error = -EINVAL; + result = -EINVAL; goto leave; } time_freq = txc->freq - pps_freq; @@ -267,7 +263,7 @@ if (txc->modes & ADJ_MAXERROR) { if (txc->maxerror < 0 || txc->maxerror >= NTP_PHASE_LIMIT) { - error = -EINVAL; + result = -EINVAL; goto leave; } time_maxerror = txc->maxerror; @@ -275,7 +271,7 @@ if (txc->modes & ADJ_ESTERROR) { if (txc->esterror < 0 || txc->esterror >= NTP_PHASE_LIMIT) { - error = -EINVAL; + result = -EINVAL; goto leave; } time_esterror = txc->esterror; @@ -283,7 +279,7 @@ if (txc->modes & ADJ_TIMECONST) { /* p. 24 */ if (txc->constant < 0) { /* NTP v4 uses values > 6 */ - error = -EINVAL; + result = -EINVAL; goto leave; } time_constant = txc->constant; @@ -329,7 +325,7 @@ else time_freq += ltemp >> SHIFT_KH; } else /* calibration interval too short (p. 12) */ - time_state = TIME_ERROR; + result = TIME_ERROR; } else { /* PLL mode */ if (mtemp < MAXSEC) { ltemp *= mtemp; @@ -342,7 +338,7 @@ time_constant + SHIFT_KF - SHIFT_USEC); } else /* calibration interval too long (p. 12) */ - time_state = TIME_ERROR; + result = TIME_ERROR; } if (time_freq > time_tolerance) time_freq = time_tolerance; @@ -354,7 +350,7 @@ /* if the quartz is off by more than 10% something is VERY wrong ! */ if (txc->tick < 900000/HZ || txc->tick > 1100000/HZ) { - error = -EINVAL; + result = -EINVAL; goto leave; } tick = txc->tick; @@ -370,7 +366,7 @@ || ((time_status & STA_PPSFREQ) != 0 && (time_status & (STA_PPSWANDER|STA_PPSERROR)) != 0)) /* p. 24, (d) */ - time_state = TIME_ERROR; + result = TIME_ERROR; if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) txc->offset = save_adjust; @@ -399,7 +395,7 @@ txc->stbcnt = pps_stbcnt; sti(); - return(error < 0 ? error : time_state); + return(result); } asmlinkage int sys_adjtimex(struct timex *txc_p)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |