Bug 32226

Summary: time of day clock runs fast (approx twice as fast)
Product: Base System Reporter: Alan Edmonds <kb5zuy>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Alan Edmonds 2001-11-23 14:30:01 UTC
the time of day clock runs fast.  For example:

$ date; sleep 5; date
Fri Nov 23 14:12:55 GMT 2001
Fri Nov 23 14:13:05 GMT 2001

$ sysctl kern.timecounter.hardware=TSC
$ date; sleep 5; date
Fri Nov 23 14:13:17 GMT 2001
Fri Nov 23 14:13:22 GMT 2001

In both cases, the subjective time was 5 seconds.

Here is a dmesg output.

$ dmesg
Copyright (c) 1992-2001 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD 5.0-CURRENT #5: Fri Nov 23 09:16:41 GMT 2001
    root@uk-demo-6:/usr/obj/usr/src/sys/TPAD
Preloaded elf kernel "/boot/kernel/kernel" at 0xc03af000.
Preloaded elf module "/boot/kernel/if_wi.ko" at 0xc03af0a8.
Preloaded elf module "/boot/kernel/snd_pcm.ko" at 0xc03af154.
Preloaded elf module "/boot/kernel/snd_solo.ko" at 0xc03af200.
Preloaded elf module "/boot/kernel/atspeaker.ko" at 0xc03af2b0.
Preloaded elf module "/boot/kernel/apm.ko" at 0xc03af360.
Preloaded elf module "/boot/kernel/acpi.ko" at 0xc03af408.
Timecounter "i8254"  frequency 1193182 Hz
Timecounter "TSC"  frequency 365809290 Hz
CPU: Pentium II/Pentium II Xeon/Celeron (365.81-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x66a  Stepping = 10
  Features=0x183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR>
real memory  = 67043328 (65472K bytes)
avail memory = 61493248 (60052K bytes)
Pentium Pro MTRR support enabled
pcibios: No call entry point
npx0: <math processor> on motherboard
npx0: INT 16 interface
acpi0: <IBM    Hammer  > on motherboard
acpi0: power button is handled as a fixed feature programming model.
Timecounter "ACPI"  frequency 3579545 Hz
acpi_timer0: <32-bit timer at 3.579545MHz> port 0xf108-0xf10b on acpi0
acpi_cpu0: <CPU> on acpi0
acpi_cpu: CLK_VAL field overflows P_CNT register
acpi_cpu: CLK_VAL field overlaps THT_EN bit
acpi_tz0: <thermal zone> on acpi0
acpi_tz1: <thermal zone> on acpi0
acpi_button0: <Sleep Button> on acpi0
acpi_pcib0: <Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <PCI bus> on acpi_pcib0
pcib1: <PCI-PCI bridge> at device 1.0 on pci0
pci1: <PCI bus> on pcib1
pci1: <display, VGA> at device 0.0 (no driver attached)
pci0: <simple comms> at device 6.0 (no driver attached)
isab0: <PCI-ISA bridge> at device 7.0 on pci0
isa0: <ISA bus> on isab0
pcm0: <ESS Solo-1 (unknown vendor)> port 0x78a4-0x78a7,0x7890-0x7893,0x7870-0x787f,0x7850-0x785f,0x7800-0x783f irq 5 at device 8.0 on pci0
atapci0: <AcerLabs Aladdin ATA33 controller> port 0x78c0-0x78cf irq 15 at device 15.0 on pci0
ata0: at 0x1f0 irq 14 on atapci0
ata1: at 0x170 irq 15 on atapci0
pci0: <bridge, PCI-unknown> at device 17.0 (no driver attached)
pcic0: <O2micro 6832/6833 PCI-Cardbus Bridge> irq 9 at device 19.0 on pci0
pcic0: PCI Memory allocated: 0x44000000
pcic0: Warning: O2micro OZ68xx chips may not work
pccard0: <PC Card bus (classic)> on pcic0
pcic1: <O2micro 6832/6833 PCI-Cardbus Bridge> irq 9 at device 19.1 on pci0
pcic1: PCI Memory allocated: 0x44001000
pcic1: Warning: O2micro OZ68xx chips may not work
pccard1: <PC Card bus (classic)> on pcic1
ohci0: <AcerLabs M5237 (Aladdin-V) USB controller> mem 0x82100000-0x82100fff irq 10 at device 20.0 on pci0
usb0: OHCI version 1.0, legacy support
usb0: <AcerLabs M5237 (Aladdin-V) USB controller> on ohci0
usb0: USB revision 1.0
uhub0: AcerLabs OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
acpi_lid0: <Control Method Lid Switch> on acpi0
acpi_acad0: <AC adapter> on acpi0
acpi_cmbat0: <Control method Battery> on acpi0
atspeaker0 port 0x61 on acpi0
atkbdc0: <Keyboard controller (i8042)> port 0x64,0x60 irq 1 on acpi0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: model Generic PS/2 mouse, device ID 0
fdc0: <NEC 72065B or clone> port 0x3f7,0x3f0-0x3f5 irq 6 on acpi0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
ppc0 port 0x3bc-0x3c3 irq 7 on acpi0
ppc0: Generic chipset (NIBBLE-only) in COMPATIBLE mode
ppi0: <Parallel I/O> on ppbus0
plip0: <PLIP network interface> on ppbus0
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port
sio0 port 0x3f8-0x3ff irq 4 on acpi0
sio0: type 16550A
acpi_ec0: <embedded controller> port 0x66,0x62 on acpi0
ata-: ata0 already exists, skipping it
ata-: ata1 already exists, skipping it
atkbdc-: atkbdc0 already exists, skipping it
fdc-: fdc0 already exists, skipping it
pcic-: pcic0 already exists, skipping it
pcic-: pcic1 already exists, skipping it
ppc-: ppc0 already exists, skipping it
sc-: sc0 already exists, skipping it
sio-: sio0 already exists, skipping it
vga-: vga0 already exists, skipping it
orm0: <Option ROM> at iomem 0xc0000-0xcbfff on isa0
sc0: <System console> on isa0
sc0: VGA <16 virtual consoles, flags=0x200>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
pmtimer0 on isa0
sio1: configured irq 3 not in bitmap of probed irqs 0
ad0: 4645MB <IBM-DBCA-204860> [10068/15/63] at ata0-master UDMA33
acd0: CDROM <CRN-8241B> at ata1-master PIO4
Mounting root from ufs:/dev/ad0s2a
pccard: card inserted, slot 0
pccard: card removed, slot 0
WARNING: / was not properly dismounted
pccard: card inserted, slot 0
WARNING: /usr was not properly dismounted
/usr: lost blocks 0 files 7
WARNING: /var was not properly dismounted
wi0 at port 0x280-0x2c7 iomem 0xd4000-0xd43ff irq 9 flags 0x10000 slot 0 on pccard0
wi0: Ethernet address: 00:02:b3:04:b8:b8
$

Fix: 

I can fix the problem by setting the kern.timecounter.hardware variable to TSC (instead of ACPI).
How-To-Repeat: See above.
Comment 1 dwmalone 2001-11-26 10:38:37 UTC
On Fri, Nov 23, 2001 at 06:22:37AM -0800, Alan Edmonds wrote:
> Timecounter "ACPI"  frequency 3579545 Hz
> acpi_timer0: <32-bit timer at 3.579545MHz> port 0xf108-0xf10b on acpi0

> >Fix:
> I can fix the problem by setting the kern.timecounter.hardware variable to TSC (instead of ACPI).

I'm fairly sure this is due to broken hardware for the ACPI timer.
Atleast I had the same problem with one machine running -current
and resorted to using the TSC as a timecounter again too.

I don't know if it is a common enought problem that there should
be a work around. It may well be worth it to avoid a deluge of
complaints when -current becomes -stable. (Mind you, people with
broken ACPI stuff will have enough problems when -current becomes
-stable anyway.)

	David.
Comment 2 Christopher Brian Jack 2003-02-10 00:37:25 UTC
I get this problem on my system board as well.
I've pasted the relevant dmesg output

I can also note that this problem is still prevalent in the kernel as of
FreeBSD 5.0-CURRENT-20030209-JPSNAP

------------ begin dmesg output ------------------------
Copyright (c) 1992-2003 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
=09The Regents of the University of California. All rights reserved.
FreeBSD 5.0-CURRENT-20030209-JPSNAP #0: Sat Feb  8 23:46:04 GMT 2003
    root@ushi.jp.freebsd.org:/usr/obj/usr/src/sys/GENERIC
Preloaded elf kernel "/boot/kernel/kernel" at 0xc06c3000.
Preloaded elf module "/boot/kernel/acpi.ko" at 0xc06c30a8.
Timecounter "i8254"  frequency 1193182 Hz
Timecounter "TSC"  frequency 300683203 Hz
CPU: AMD-K6(tm) 3D processor (300.68-MHz 586-class CPU)
  Origin =3D "AuthenticAMD"  Id =3D 0x58c  Stepping =3D 12
  Features=3D0x8021bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8,PGE,MMX>
  AMD Features=3D0x80000800<SYSCALL,3DNow!>
real memory  =3D 201310208 (191 MB)
avail memory =3D 188252160 (179 MB)
Initializing GEOMetry subsystem
K6-family MTRR support enabled (2 registers)
npx0: <math processor> on motherboard
npx0: INT 16 interface
acpi0: <ASUS   P5A     > on motherboard
    ACPI-0625: *** Info: GPE Block0 defined as GPE0 to GPE15
    ACPI-0625: *** Info: GPE Block1 defined as GPE16 to GPE31
Using $PIR table, 8 entries at 0xc00f0b40
acpi0: power button is handled as a fixed feature programming model.
Timecounter "ACPI-safe"  frequency 3579545 Hz
acpi_timer0: <24-bit timer at 3.579545MHz> port 0xec08-0xec0b on acpi0
acpi_cpu0: <CPU> on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
agp0: <Ali M1541 host to AGP bridge> mem 0xe0000000-0xe3ffffff at device =
0.0=20
on pci0
pcib1: <PCI-PCI bridge> at device 1.0 on pci0
pci1: <PCI bus> on pcib1
pci1: <display, VGA> at device 0.0 (no driver attached)
ohci0: <AcerLabs M5237 (Aladdin-V) USB controller> mem 0xdf000000-0xdf000=
fff=20
irq 5 at device 2.0 on pci0
usb0: OHCI version 1.0, legacy support
usb0: <AcerLabs M5237 (Aladdin-V) USB controller> on ohci0
usb0: USB revision 1.0
uhub0: AcerLabs OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
ulpt0: EPSON USB Printer, rev 1.00/1.00, addr 2, iclass 7/1
ulpt0: using bi-directional mode
pci0: <bridge, PCI-unknown> at device 3.0 (no driver attached)
isab0: <PCI-ISA bridge> at device 7.0 on pci0
isa0: <ISA bus> on isab0
pci0: <multimedia, video> at device 9.0 (no driver attached)
pci0: <multimedia> at device 9.1 (no driver attached)
fxp0: <Intel Pro 10/100B/100+ Ethernet> port 0xb800-0xb83f mem=20
0xde000000-0xde0fffff,0xde800000-0xde800fff irq 10 at device 10.0 on pci0
fxp0: Ethernet address 00:90:27:59:9a:e5
inphy0: <i82555 10/100 media interface> on miibus0
inphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
pci0: <multimedia, audio> at device 12.0 (no driver attached)
pci0: <input device> at device 12.1 (no driver attached)
atapci0: <AcerLabs Aladdin ATA33 controller> port 0xa800-0xa80f at device=
 15.0=20
on pci0
ata0: at 0x1f0 irq 14 on atapci0
ata1: at 0x170 irq 15 on atapci0
fdc0: <Enhanced floppy controller (i82077, NE72065 or clone)> port=20
0x3f7,0x3f2-0x3f5 irq 6 drq 2 on acpi0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
ppc0 port 0x378-0x37f irq 7 on acpi0
ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
plip0: <PLIP network interface> on ppbus0
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port
ppi0: <Parallel I/O> on ppbus0
sio0 port 0x3f8-0x3ff irq 4 on acpi0
sio0: type 16550A
sio1 port 0x2f8-0x2ff irq 3 on acpi0
sio1: type 16550A
atkbdc0: <Keyboard controller (i8042)> port 0x64,0x60 irq 1 on acpi0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
orm0: <Option ROMs> at iomem 0xc8000-0xc8fff,0xc0000-0xc7fff on isa0
pmtimer0 on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=3D0x300>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
Timecounters tick every 10.000 msec
allocate another stats-page 0xc1f36000
ad0: UDMA ICRC error cmd=3Dread fsbn 12594897 of 0-3
 retrying
ad0: UDMA ICRC error cmd=3Dread fsbn 12594897 of 0-3
 retrying
ad0: UDMA ICRC error cmd=3Dread fsbn 12594897 of 0-3
 retrying
ad0: UDMA ICRC error cmd=3Dread fsbn 12594897 of 0-3
 falling back to PIO mode
ad0: 6149MB <WDC AC36400L> [13328/15/63] at ata0-master PIO4
ad1: 19541MB <Maxtor 32049H2> [39704/16/63] at ata0-slave UDMA33
acd0: CDROM <ATAPI CD ROM DRIVE 50X MAX> at ata1-master PIO4
ad1: UDMA ICRC error cmd=3Dread fsbn 0
 retrying
ad1: UDMA ICRC error cmd=3Dread fsbn 0
 retrying
ad1: UDMA ICRC error cmd=3Dread fsbn 0
 retrying
ad1: UDMA ICRC error cmd=3Dread fsbn 0
 falling back to PIO mode
allocate another stats-page 0xc1f33000
Mounting root from ufs:/dev/ad0s2a
Be nice to each other, mmmkay?
lock order reversal
 1st 0xc200b5cc process lock (process lock) @=20
/usr/src/sys/kern/kern_descrip.c:2104
 2nd 0xc2014a34 filedesc structure (filedesc structure) @=20
/usr/src/sys/kern/kern_descrip.c:2111
pcm0: <Creative EMU10K1> port 0xb400-0xb41f irq 11 at device 12.0 on pci0
pcm0: <SigmaTel STAC9708/9711 ac97 codec>
acquiring duplicate lock of same type: "pcm channel"
 1st pcm0:record:0 @ /usr/src/sys/dev/sound/pcm/sound.c:191
 2nd pcm0:play:0 @ /usr/src/sys/dev/sound/pcm/sound.c:191
cd9660: Joliet Extension (Level 1)
cd9660: Joliet Extension (Level 1)
pid 742 (sysinstall), uid 0: exited on signal 11 (core dumped)
sio0: 112 more interrupt-level buffer overflows (total 112)
------------ end dmesg output ------------------------

I've left it all in in the event some of the later hardware issues (near =
the=20
end) is part of this problem.  Either that or this system board is a real=
=20
flawed design.
Comment 3 Jason Bacon 2003-09-13 18:10:47 UTC
FYI, I'm having the same problem on an ASUS P5A, BIOS 1011 BETA,
K6-2 500Mhz.

Setting kern.timecounter.hardware to TSC seems to have solved the problem.

Cheers,

	Jason
Comment 4 Jason Bacon 2003-09-13 18:13:57 UTC
One more thing:

I'm running 5.1R.  The problem did not occur under 4.6R, 4.3R, or 3.2R
on the same machine.  Don't know if it matters, but I did upgrade the BIOS
from 1007 ro 1011-BETA at the same time I upgraded to 5.1R.  ( Had to to get
my 80 gig IDE drive recognized )

Cheers,

	Jason
Comment 5 Kris Kennaway freebsd_committer freebsd_triage 2005-01-05 01:17:14 UTC
State Changed
From-To: open->closed

Using the TSC works around the problem, which is believed to be 
due to broken hardware