linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arch/alpha/kernel/time.c - override bogus clock freq gues ses
@ 2003-06-05 21:32 Bailey, Scott
  0 siblings, 0 replies; only message in thread
From: Bailey, Scott @ 2003-06-05 21:32 UTC (permalink / raw)
  To: 'linux-kernel@vger.kernel.org'
  Cc: 'torvalds@transmeta.com',
	'marcelo@conectiva.com.br',
	Bailey, Scott

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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-06-05 21:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-05 21:32 [PATCH] arch/alpha/kernel/time.c - override bogus clock freq gues ses Bailey, Scott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).