[PATCH] arch/alpha/kernel/time.c - override bogus clock freq gues ses

From: Bailey, Scott (scott.bailey@eds.com)
Date: Thu Jun 05 2003 - 16:32:30 EST


This is targeted at 2.4.20, but should apply cleanly to any of the 2.5
kernels too.

The clock frequency found in the Alpha HWRPB may be significantly off from
the actual frequency. The existing test is not stringent enough to weed out
errors that will swamp ntp; this patch reduces the allowable error from 1%
(10,000 PPM) to 250 PPM.

Kudos to Hal Murray <hmurray@suespammers.org> for insightful guidance;
tested on
my 3-way Alphaserver 4100 5/466 with very happy results. :-)

--- kernel-source-2.4.20/arch/alpha/kernel/time.c 2002-02-27
05:12:19.000000000 -0500
+++ rsb-patch/arch/alpha/kernel/time.c 2003-06-05 12:51:10.000000000 -0400
@@ -24,6 +24,8 @@
  * 2000-08-13 Jan-Benedict Glaw <jbglaw@lug-owl.de>
  * Fixed time_init to be aware of epoches != 1900. This prevents
  * booting up in 2048 for me;) Code is stolen from rtc.c.
+ * 2003-06-03 R. Scott Bailey <scott.bailey@eds.com>
+ * Tighten sanity in time_init from 1% (10,000 PPM) to 250 PPM
  */
 #include <linux/config.h>
 #include <linux/errno.h>
@@ -288,7 +290,7 @@
 time_init(void)
 {
         unsigned int year, mon, day, hour, min, sec, cc1, cc2, epoch;
- unsigned long cycle_freq, one_percent;
+ unsigned long cycle_freq, tolerance;
         long diff;
 
         /* Calibrate CPU clock -- attempt #1. */
@@ -306,13 +308,13 @@
 
         cycle_freq = hwrpb->cycle_freq;
         if (est_cycle_freq) {
- /* If the given value is within 1% of what we calculated,
+ /* If the given value is within 250 PPM of what we
calculated,
                    accept it. Otherwise, use what we found. */
- one_percent = cycle_freq / 100;
+ tolerance = cycle_freq / 4000;
                 diff = cycle_freq - est_cycle_freq;
                 if (diff < 0)
                         diff = -diff;
- if (diff > one_percent) {
+ if (diff > tolerance) {
                         cycle_freq = est_cycle_freq;
                         printk("HWRPB cycle frequency bogus. "
                                "Estimated %lu Hz\n", cycle_freq);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jun 07 2003 - 22:00:28 EST