Subject: Re: Need help with timecounters/todr
To: None <port-alpha@NetBSD.org>
From: Pavel Cahyna <pavel@NetBSD.org>
List: port-alpha
Date: 07/11/2007 00:54:54
On Sun, Jul 08, 2007 at 05:19:21PM +0900, Izumi Tsutsui wrote:
> In article <070708114059.M0116464@mirage.ceres.dti.ne.jp>
> I wrote:
>
> > In article <45E03427.5080304@netbsd.org>
> > kardel@NetBSD.org wrote:
> >
> > > Izumi Tsutsui wrote:
> >
> > > > I'm not sure what is the best way to switch alpha to timecounter,
> > > > but I just take functions from x86/x86/tsc.c and adapt it to
> > > > alpha's PCC counter.
> > > >
> > > > Could anyone review the attached patch?
> > > > (which also includes generic todr(9) changes)
> > :
> > > In general I agree with the strategy but I think we
> > > should try to avoid a copy if tsc.c here. I include an
> > > old patch here that attempts to split tsc.c into a
> > > MD part (tsc.c) and an MI part kern_cctr.c. Maybe you can
> > > use that for the cycle counter part of the part - note on
> > > alpha this patch lacks the cc_init() call. Also note
> > > that the patch assumes that the counter is read by
> > > cpu_counter32() - same headfile magic as was used
> > > for kern_microtime.c.
> >
> > I've updated my todr(9) and timecounter(9) patch for alpha
> > based on your MI kern_cctr.c patch (attached):
> >
> > - use todr(9) API with MI mc146818(4) driver and remove homegrown
> > todr stuff from MD alpha/clock.c and alpha/mcclock.c
> > - also remove cc_microtime stuff from MD code
> > - add ci_pcc_freq member in struct cpu_info for cpu_frequency(), and
> > calibrate it with mc146818 interval clock in mcclock attachment
> > - tsc.c is split into MI kern_cctr.c and MD tsc.c as kardel's patch
> > (with some cosmetics)
> > - call cc_init() in cpu_initclocks(9) because all alpha cpus have
> > a pcc counter
> > - prepare new <sys/ctrr.h> which is just copied from
> > __HAVE_TIMECOUNTER part of <sys/cc_microtime.h> so that
> > we can migrate alpha and x86 to kern_cctr.c independently
> > (the attached patch also contains changes for i386 and amd64)
> >
> > Tested on AlphaPC164 366MHz and at least todr(9) and ntpd(8)
> > work fine. I'll also test it on DEC3000/300 and Duron PC,
> > but I don't have any SMP machines.
> >
> >
> > Any comments and tests are appreciated.
> > ---
> > Izumi Tsutsui
>
> Hmm, maybe my patch is so large and seems caught by a filter.
> I've also put it here:
> http://www.ceres.dti.ne.jp/~tsutsui/netbsd/alpha-cctr-todr-20070707.diff
I notice it periodically synces the local cycle counters. Is it really
needed? I think Alpha motherboard have a central clock which drives the
CPUs, so they are always precisely syncronized and this shouldn't be
needed.
Pavel