Subject: Timecounter on sun4c
To: None <current-users@NetBSD.org>
From: Fanch <fanch@kekpar.net>
List: current-users
Date: 08/23/2006 11:06:36
Hi,

I have to downgrade kern.timecounter.hardware (cool feature) to
clockinterrupt to get a correct clock, timer-counter seems to drift
over 800000 ppm (no typo !) with or without ntpd.

Maybe a too slow computer (SS1+, 25 MHz, no hardware multiply,
timer-counter freq = 1 MHz) ?

Tested with sources from 22 july and yesterday. Kernel includes
only sun4c devices/options, and is compiled with
DEFCOPTS+=-O2 -mcpu=v7

No problem on a sun4m (SS10), same tree, kernel with only sun4m
devices/options and DEFCOPTS+=-O2 -mcpu=supersparc

The two are cross-compiled from a i386-current host (no problem
on it either).

Relevant informations :

caillou# sysctl kern.timecounter
kern.timecounter.choice = clockinterrupt(q=0, f=100 Hz) 
timer-counter(q=100, f=1000000 Hz) dummy(q=-1000000, f=1000000 Hz)
kern.timecounter.hardware = clockinterrupt
kern.timecounter.timestepwarnings = 0

caillou# sysctl kern.clockrate
kern.clockrate: tick = 10000, tickadj = 40, hz = 100, profhz = 100, 
stathz = 100

caillou# dmesg
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 
2005, 2006
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 4.99.1 (SS1) #5: Tue Aug 22 17:36:47 CEST 2006
        root@ptitordi:/usr/tmp/src/usr/src/sys/arch/sparc/compile/SS1
total memory = 40912 KB
avail memory = 37128 KB
timecounter: Timecounters tick every 10.000 msec
bootpath: /sbus0/le0
mainbus0 (root): Sun 4/65: hostid 53c0ffee
cpu0 at mainbus0: MB86900/1A or L64801 @ 25 MHz, WTL3170/2 FPU
cpu0: 64K byte write-through, 16 bytes/line, sw flush: cache enabled
memreg0 at mainbus0 ioaddr 0xf4000000
clock0 at mainbus0 ioaddr 0xf2000000: mk48t02
timer0 at mainbus0 ioaddr 0xf3000000 ipl 10: delay constant 10, 
frequency = 1000000 Hz
timecounter: Timecounter "timer-counter" frequency 1000000 Hz quality 100
timecounter: selected timecounter "timer-counter" frequency 1000000 Hz 
quality 100
auxreg0 at mainbus0 ioaddr 0xf7400000
zs0 at mainbus0 ioaddr 0xf1000000 ipl 12 softpri 6
zstty0 at zs0 channel 0 (console i/o)
zstty1 at zs0 channel 1
zs1 at mainbus0 ioaddr 0xf0000000 ipl 12 softpri 6
kbd0 at zs1 channel 0: baud rate 1200
ms0 at zs1 channel 1: baud rate 1200
fdc0 at mainbus0 ioaddr 0xf7200000 ipl 11 softpri 4: chip 82072
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
audioamd0 at mainbus0 ioaddr 0xf7201000 ipl 13 softpri 4
audio0 at audioamd0: full duplex
sbus0 at mainbus0 ioaddr 0xf8000000: clock = 25 MHz
dma0 at sbus0 slot 0 offset 0x400000: DMA rev 1
esp0 at sbus0 slot 0 offset 0x800000 level 3: ESP100, 25MHz, SCSI ID 7
scsibus0 at esp0: 8 targets, 8 luns per target
le0 at sbus0 slot 0 offset 0xc00000 level 5: address 08:00:20:c0:ff:ee
le0: 8 receive buffers, 2 transmit buffers
dma at sbus0 slot 1 offset 0x81000 not configured
esp at sbus0 slot 1 offset 0x80000 level 3 not configured
lebuffer0 at sbus0 slot 1 offset 0x40000: 128K memory
le1 at sbus0 slot 1 offset 0x60000 level 4 (ipl 5): address 
08:00:20:c0:ff:ee
le1: 64 receive buffers, 16 transmit buffers
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
scsibus0: waiting 2 seconds for devices to settle...
root on le0
nfs_boot: trying DHCP/BOOTP
nfs_boot: DHCP next-server: 192.168.16.127
nfs_boot: my_domain=reso
nfs_boot: my_addr=192.168.16.101
nfs_boot: my_mask=255.255.255.0
nfs_boot: caillou=192.168.16.101
root on 192.168.16.127:/mnt/caillou/root
root file system type: nfs
WARNING: clock gained 162 days -- CHECK AND RESET THE DATE!
timecounter: selected timecounter "clockinterrupt" frequency 100 Hz 
quality 0


Note : the "precision" reported by ntpd has changed a lot since the
use of timecounters.

Before :
Apr  2 16:40:11 caillou ntpd[528]: precision = 45.000 usec
Aug  3 17:38:14 caillou ntpd[536]: precision = 46.000 usec

After, timer-counter :
Aug 20 09:11:31 caillou ntpd[541]: precision = 137.000 usec
Aug 22 18:01:19 caillou ntpd[657]: precision = 115.002 usec

After, clockinterrupt :
Aug 23 07:31:42 caillou ntpd[570]: precision = 10000.000 usec

Regards,

Fanch