Skip to contentSkip to conversation

fix pit hz

PATCH New Dan Magenheimer 1 participant 1 message Jul 19, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix pit hz

I was wondering why dom0's dmesg reports slightly different Hz rates for Linux vs Xen.

Several years ago, Linux changed various PIT rate constants from 11931780 to 11931782. (The precise value should be 11931781.8181...) Xen apparently never caught up. (But interestingly many non-x86 arch's in Linux never did either!)

This briefly explains the difference and history.
http://groups.google.com/group/openwatcom.users.c_cpp/msg/db10671e6f8e711f
Since this constant is usually used in mul/div calculations, it may be possible to get even more precise: 105000000/88

Constant replacement patch attached. I may try to use the more precise calculation later as the exact value becomes more important for clocksource=tsc.

Dan

===================================
Thanks... for the memory
I really could use more / My throughput's on the floor The balloon is flat / My swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to the late great Bob Hope)

xen/arch/x86/i8259.c +1 -1
diff -r 092a15aa2430 xen/arch/x86/i8259.c
@@ -411,7 +411,7 @@ void __init init_IRQ(void)
     apic_intr_init();
 
     /* Set the clock to HZ Hz */
-#define CLOCK_TICK_RATE 1193180 /* crystal freq (Hz) */
+#define CLOCK_TICK_RATE 1193182 /* crystal freq (Hz) */
 #define LATCH (((CLOCK_TICK_RATE)+(HZ/2))/HZ)
     outb_p(0x34, PIT_MODE);        /* binary, mode 2, LSB/MSB, ch 0 */
     outb_p(LATCH & 0xff, PIT_CH0); /* LSB */
xen/arch/x86/time.c +1 -1
diff -r 092a15aa2430 xen/arch/x86/time.c
@@ -214,7 +214,7 @@ static struct irqaction irq0 = { timer_i
  * Return processor ticks per second / CALIBRATE_FRAC.
  */
 
-#define CLOCK_TICK_RATE 1193180 /* system crystal frequency (Hz) */
+#define CLOCK_TICK_RATE 1193182 /* system crystal frequency (Hz) */
 #define CALIBRATE_FRAC  20      /* calibrate over 50ms */
 #define CALIBRATE_LATCH ((CLOCK_TICK_RATE+(CALIBRATE_FRAC/2))/CALIBRATE_FRAC)
 
xen/include/asm-x86/hvm/vpt.h +1 -1
diff -r 092a15aa2430 xen/include/asm-x86/hvm/vpt.h
@@ -95,7 +95,7 @@ struct periodic_time {
 };
 
 
-#define PIT_FREQ 1193181
+#define PIT_FREQ 1193182
 #define PIT_BASE 0x40
 
 typedef struct PITState {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel