mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* RE: clock skew on B/W G3
@ 2005-10-04 15:15 Rune Torgersen
  2005-10-04 19:14 ` George Anzinger
  0 siblings, 1 reply; 10+ messages in thread
From: Rune Torgersen @ 2005-10-04 15:15 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Marc, linuxppc-dev, linux-kernel

 

> -----Original Message-----
> From: Paul Mackerras [mailto:paulus@samba.org] 
> Sent: Tuesday, October 04, 2005 07:49
> Subject: RE: clock skew on B/W G3
>
> I do not believe CLOCK_TICK_RATE affects timekeeping at all on ppc or
> ppc64 machines, but I could be wrong.  Can you show us where and how
> CLOCK_TICK_RATE affects things?

I looked very closely at htis thing earlier this summer because of an
embedded board that drifted quite severly (15sec a day) with a very
accureate BITS clock as clock source.

Here goes:
In arch/ppc/kernel/time.c
timer_interrupt() gets called every decrementer timeout (about every
1/CONFIG_HZ seconds, accuracy depends on how easily your decrementer
cliock can be divided by CONFIG_HZ)
this calls do_timer() to do the timer increment.

do_timer is in kernel/timer.c and calls update_times().
update_times() calls update_wall_time() which in turns calls
update_wall_time_one_tick()

update_wall_time_one_tick()uses tick_nsec to increment xtime.

tick_nsec is defined as: (kernel/timer.c:561)
unsigned long tick_nsec = TICK_NSEC;

TICK_NSEC is defined as: (include/linux/jiffies.h:64)
#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))

ACTHZ is defined as: (include/linux/jiffies.h:61)
#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))

LATCH is defined as: (include/linux/jiffies.h:46)
#define LATCH  ((CLOCK_TICK_RATE + HZ/2) / HZ)

which means that tick_nsec depends on CLOCK_TICK_RATE to get its value.

defined as:
#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */

this clock is completely wrong for most/all ppc. 
It happens to generate a tick_nsec of 999848 which is close enough to
1000000 that most people does not notice.
(tick_nsec is number of nsec per timer tick)

When HZ is 250, TICK_NSEC becomes 4000250.
While this might not completely explain a 20% change in clock sped, it
it clearly not acurate either.

^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: clock skew on B/W G3
@ 2005-10-04 19:22 Rune Torgersen
  0 siblings, 0 replies; 10+ messages in thread
From: Rune Torgersen @ 2005-10-04 19:22 UTC (permalink / raw)
  To: george; +Cc: Paul Mackerras, Marc, linuxppc-dev, linux-kernel

 

> From: George Anzinger [mailto:george@mvista.com] 
> But this is defined in include/asm/???.h  so you should be 
> able to set something more to your liking 
> (or rather to your archs liking).  It is true that it SHOULD 
> be defined as it is used to define 
> TICK_NSEC which is used to define the 
> jiffies<-->timeval/timespec conversions which would be VERY 
> slow it it were a variable.

Just make them variables, and compute them ONCE during boot.
ppc calls calibrate_decr() before enabling the timer interrupt anyways.

time_nsec is easy. 
in a platfrom specific file do (very simplified):

extern unsigned long time_nsec;

void platform_specific_calibrate_decr()
{
	time_nsec = REAL_TIME_NSEC;
}

This (of course) will do nothing about LATCH and ACTHZ that might be
used other places.

^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: clock skew on B/W G3
@ 2005-10-03 14:18 Rune Torgersen
  2005-10-04  6:14 ` Marc
  2005-10-04 12:48 ` Paul Mackerras
  0 siblings, 2 replies; 10+ messages in thread
From: Rune Torgersen @ 2005-10-03 14:18 UTC (permalink / raw)
  To: Marc, linuxppc-dev, linux-kernel

> -----Original Message-----
> From:  Marc
> Sent: Sunday, October 02, 2005 11:46
> 
> Some additions to the previous mail: I was able to isolate 
> the problem to the 
> introduction of a user specificable value of HZ (in 
> include/asm-ppc/parm.h). 
> I used a value of 250 while the former default was 1000. 
> Setting it back to 
> 1000 makes the clock tick right again.
> 
> Is the CONFIG_HZ known to be broken on PPC ?
> 

CONFIG_HZ is not broken, but the whole clock configuration is.
(I poseded something about it for 8260 earlier this summer)

Basic problem is that CLOCK_TICK_RATE which is used for setting up the
variables used for advancing the clock, is hardcoded to a value that
only makes sence for an i386. (it is default set at 1193180Hz which
happens to be the timer clock for timer1 on an i386 machine)

Another problem here is that that value apparently hve to be #define'd
which means you cannot insert the decrementer frequency from the
boot-loader either.


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <200510011429.45698.marvin24@gmx.de>]

end of thread, other threads:[~2005-10-05  6:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-04 15:15 clock skew on B/W G3 Rune Torgersen
2005-10-04 19:14 ` George Anzinger
  -- strict thread matches above, loose matches on Subject: below --
2005-10-04 19:22 Rune Torgersen
2005-10-03 14:18 Rune Torgersen
2005-10-04  6:14 ` Marc
2005-10-04 22:10   ` Benjamin Herrenschmidt
2005-10-04 22:14   ` Benjamin Herrenschmidt
2005-10-05  6:34     ` Marc
2005-10-04 12:48 ` Paul Mackerras
     [not found] <200510011429.45698.marvin24@gmx.de>
2005-10-02 16:46 ` Marc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome