All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] linux-2.5.65_clock-override_A0
@ 2003-03-19 22:54 john stultz
  2003-03-19 23:34 ` Stephen Hemminger
  2003-03-20  0:21 ` Jerry Cooperstein
  0 siblings, 2 replies; 3+ messages in thread
From: john stultz @ 2003-03-19 22:54 UTC (permalink / raw)
  To: lkml; +Cc: Stephen Hemminger, Andrew Morton, Martin J. Bligh, Jerry Cooperstein

[-- Attachment #1: Type: text/plain, Size: 5781 bytes --]

All,
	Inspired by Stephen Hemminger's "boot time parameter to turn of TSC
usage" patch, I implemented my own version that is a tad bit more
flexible. 

With this patch, one can manually specify on the boot cmdline which time
source should be used (if available) for calculating gettimeofday().
This will override the default probed selection. Should the requested
time-source not be available, the code defaults to using the PIT (and
prints a warning saying so). 

Please let me know if you have any comments or suggestions.

thanks
-john


diff -Nru a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
--- a/Documentation/kernel-parameters.txt	Wed Mar 19 14:50:33 2003
+++ b/Documentation/kernel-parameters.txt	Wed Mar 19 14:50:33 2003
@@ -207,6 +207,12 @@
 
 	chandev=	[HW,NET] Generic channel device initialisation
  
+ 	clock=		[BUGS=IA-32, HW] gettimeofday timesource override. 
+			Forces specified timesource (if avaliable) to be used
+			when calculating gettimeofday(). If specicified timesource
+			is not avalible, it defaults to PIT. 
+			Format: { pit | tsc | cyclone | ... }
+			
 	cm206=		[HW,CD]
 			Format: { auto | [<io>,][<irq>] }
 
diff -Nru a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
--- a/arch/i386/kernel/smpboot.c	Wed Mar 19 14:50:33 2003
+++ b/arch/i386/kernel/smpboot.c	Wed Mar 19 14:50:33 2003
@@ -422,7 +422,7 @@
 	/*
 	 *      Synchronize the TSC with the BP
 	 */
-	if (cpu_has_tsc)
+	if (cpu_has_tsc && cpu_khz)
 		synchronize_tsc_ap();
 }
 
@@ -1114,7 +1114,7 @@
 	/*
 	 * Synchronize the TSC with the AP
 	 */
-	if (cpu_has_tsc && cpucount)
+	if (cpu_has_tsc && cpucount && cpu_khz)
 		synchronize_tsc_bp();
 }
 
diff -Nru a/arch/i386/kernel/timers/timer.c b/arch/i386/kernel/timers/timer.c
--- a/arch/i386/kernel/timers/timer.c	Wed Mar 19 14:50:33 2003
+++ b/arch/i386/kernel/timers/timer.c	Wed Mar 19 14:50:33 2003
@@ -1,4 +1,6 @@
+#include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/string.h>
 #include <asm/timer.h>
 
 /* list of externed timers */
@@ -17,6 +19,17 @@
 	NULL,
 };
 
+static char clock_override[10];
+
+static int clock_setup(char* str)
+{
+	if(str){
+		strncpy(clock_override, str,10);
+		str[9] = '\0';
+	}
+	return 1;
+}
+__setup("clock=", clock_setup);
 
 /* iterates through the list of timers, returning the first 
  * one that initializes successfully.
@@ -28,7 +41,7 @@
 	/* find most preferred working timer */
 	while (timers[i]) {
 		if (timers[i]->init)
-			if (timers[i]->init() == 0)
+			if (timers[i]->init(clock_override) == 0)
 				return timers[i];
 		++i;
 	}
diff -Nru a/arch/i386/kernel/timers/timer_cyclone.c b/arch/i386/kernel/timers/timer_cyclone.c
--- a/arch/i386/kernel/timers/timer_cyclone.c	Wed Mar 19 14:50:33 2003
+++ b/arch/i386/kernel/timers/timer_cyclone.c	Wed Mar 19 14:50:33 2003
@@ -10,6 +10,7 @@
 #include <linux/init.h>
 #include <linux/timex.h>
 #include <linux/errno.h>
+#include <linux/string.h>
 
 #include <asm/timer.h>
 #include <asm/io.h>
@@ -73,7 +74,7 @@
 	return delay_at_last_interrupt + offset;
 }
 
-static int init_cyclone(void)
+static int init_cyclone(char* override)
 {
 	u32* reg;	
 	u32 base;		/* saved cyclone base address */
@@ -81,8 +82,11 @@
 	u32 offset;		/* offset from pageaddr to cyclone_timer register */
 	int i;
 	
+	/* check clock override */
+	if(override[0] && strncmp(override,"cyclone",7))
+			return -ENODEV;
+
 	/*make sure we're on a summit box*/
-	/*XXX need to use proper summit hooks! such as xapic -john*/
 	if(!use_cyclone) return -ENODEV; 
 	
 	printk(KERN_INFO "Summit chipset: Starting Cyclone Counter.\n");
diff -Nru a/arch/i386/kernel/timers/timer_none.c b/arch/i386/kernel/timers/timer_none.c
--- a/arch/i386/kernel/timers/timer_none.c	Wed Mar 19 14:50:33 2003
+++ b/arch/i386/kernel/timers/timer_none.c	Wed Mar 19 14:50:33 2003
@@ -1,6 +1,6 @@
 #include <asm/timer.h>
 
-static int init_none(void)
+static int init_none(char* override)
 {
 	return 0;
 }
diff -Nru a/arch/i386/kernel/timers/timer_pit.c b/arch/i386/kernel/timers/timer_pit.c
--- a/arch/i386/kernel/timers/timer_pit.c	Wed Mar 19 14:50:33 2003
+++ b/arch/i386/kernel/timers/timer_pit.c	Wed Mar 19 14:50:33 2003
@@ -17,8 +17,12 @@
 extern spinlock_t i8253_lock;
 #include "do_timer.h"
 
-static int init_pit(void)
+static int init_pit(char* override)
 {
+	/* check clock override */
+	if(override[0] && strncmp(override,"pit",3)){
+		printk(KERN_ERR "Warning: clock= override failed. Defaulting to PIT\n");
+	}
 	return 0;
 }
 
diff -Nru a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
--- a/arch/i386/kernel/timers/timer_tsc.c	Wed Mar 19 14:50:33 2003
+++ b/arch/i386/kernel/timers/timer_tsc.c	Wed Mar 19 14:50:33 2003
@@ -8,6 +8,7 @@
 #include <linux/timex.h>
 #include <linux/errno.h>
 #include <linux/cpufreq.h>
+#include <linux/string.h>
 
 #include <asm/timer.h>
 #include <asm/io.h>
@@ -242,8 +243,13 @@
 #endif
 
 
-static int init_tsc(void)
+static int init_tsc(char* override)
 {
+
+	/*check clock override*/
+	if(override[0] && strncmp(override,"tsc",3))
+			return -ENODEV;
+
 	/*
 	 * If we have APM enabled or the CPU clock speed is variable
 	 * (CPU stops clock on HLT or slows clock to save power)
diff -Nru a/include/asm-i386/timer.h b/include/asm-i386/timer.h
--- a/include/asm-i386/timer.h	Wed Mar 19 14:50:33 2003
+++ b/include/asm-i386/timer.h	Wed Mar 19 14:50:33 2003
@@ -11,7 +11,7 @@
  *	last timer intruupt.
  */
 struct timer_opts{
-	int (*init)(void);
+	int (*init)(char*);
 	void (*mark_offset)(void);
 	unsigned long (*get_offset)(void);
 	void (*delay)(unsigned long);




[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] linux-2.5.65_clock-override_A0
  2003-03-19 22:54 [RFC] linux-2.5.65_clock-override_A0 john stultz
@ 2003-03-19 23:34 ` Stephen Hemminger
  2003-03-20  0:21 ` Jerry Cooperstein
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2003-03-19 23:34 UTC (permalink / raw)
  To: john stultz; +Cc: lkml, Andrew Morton, Martin J. Bligh, Jerry Cooperstein

On Wed, 2003-03-19 at 14:54, john stultz wrote:
> All,
> 	Inspired by Stephen Hemminger's "boot time parameter to turn of TSC
> usage" patch, I implemented my own version that is a tad bit more
> flexible. 

This is cleaner and better (relatively speaking) and avoids the problem of
cpu_khz being zero.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] linux-2.5.65_clock-override_A0
  2003-03-19 22:54 [RFC] linux-2.5.65_clock-override_A0 john stultz
  2003-03-19 23:34 ` Stephen Hemminger
@ 2003-03-20  0:21 ` Jerry Cooperstein
  1 sibling, 0 replies; 3+ messages in thread
From: Jerry Cooperstein @ 2003-03-20  0:21 UTC (permalink / raw)
  To: john stultz; +Cc: lkml, Stephen Hemminger, Andrew Morton, Martin J. Bligh

On Wed, Mar 19, 2003 at 02:54:05PM -0800, john stultz wrote:
> All,
> 	Inspired by Stephen Hemminger's "boot time parameter to turn of TSC
> usage" patch, I implemented my own version that is a tad bit more
> flexible. 
> 
> With this patch, one can manually specify on the boot cmdline which time
> source should be used (if available) for calculating gettimeofday().
> This will override the default probed selection. Should the requested
> time-source not be available, the code defaults to using the PIT (and
> prints a warning saying so). 
> 
> Please let me know if you have any comments or suggestions.
> 
> thanks
> -john

Works fine on the hardware that started the whole thing.  This one requires
CONFIG_CPU_FREQ turned off (otherwise the keyboard freezes).  Stephen
Hemminger's required CONFIG_CPU_FREQ to be set (otherwise the keyboard
froze in this case as well, not being able to register interrupts), 
which made less sense.

good work.

======================================================================
 Jerry Cooperstein,  Senior Consultant,  <coop@axian.com>
 Axian, Inc., Software Consulting and Training
 4800 SW Griffith Dr., Ste. 202,  Beaverton, OR  97005 USA
 http://www.axian.com/               
======================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-03-20  0:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-19 22:54 [RFC] linux-2.5.65_clock-override_A0 john stultz
2003-03-19 23:34 ` Stephen Hemminger
2003-03-20  0:21 ` Jerry Cooperstein

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.