Subject: Re: Need help with timecounter/todr (MI cycle counters like x86 TSC
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: Frank Kardel <kardel@netbsd.org>
List: port-i386
Date: 07/08/2007 08:59:40
Hi,

I can check x86 again on AMD X2 most likely next WE.
Maybe we find the problem in the cctr code that leads to
backward time steps on MP systems detected by
regress/sys/kern/time.

Frank

Izumi Tsutsui 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.
>
>