linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Override timer interrupt
@ 2007-10-12 20:43 Rune Torgersen
  2007-10-12 21:30 ` Mark A. Greer
  0 siblings, 1 reply; 12+ messages in thread
From: Rune Torgersen @ 2007-10-12 20:43 UTC (permalink / raw)
  To: linuxppc-embedded

Is there an easy way to use something other than the decrementer for the
timer interrupt?

Reason i'm asking is tha t on our board, the decrementer cannot be
divided to 1khz evenly, so we have rounding errors for time, but we do
have a 1KHz timer interrupt from an FPGA that is source of a T1 clock.

Right now I let the decrementer interrupt do nothing, and made my own
timer interrupt handler that calls the stuff the timer_interrupt usually
does.=20

This works, but there are some instability (ie unexplained hangs) that
showed up when I did this.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Override timer interrupt
@ 2007-10-12 20:49 Rune Torgersen
  2007-10-12 21:32 ` Mark A. Greer
  0 siblings, 1 reply; 12+ messages in thread
From: Rune Torgersen @ 2007-10-12 20:49 UTC (permalink / raw)
  To: linuxppc-dev

Is there an easy way to use something other than the decrementer for the
timer interrupt?

Reason i'm asking is tha t on our board, the decrementer cannot be
divided to 1khz evenly, so we have rounding errors for time, but we do
have a 1KHz timer interrupt from an FPGA that is source of a T1 clock.

Right now I let the decrementer interrupt do nothing, and made my own
timer interrupt handler that calls the stuff the timer_interrupt usually
does.=20

This works, but there are some instability (ie unexplained hangs) that
showed up when I did this.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Override timer interrupt
  2007-10-12 20:43 Override timer interrupt Rune Torgersen
@ 2007-10-12 21:30 ` Mark A. Greer
  2007-10-12 21:39   ` Rune Torgersen
  0 siblings, 1 reply; 12+ messages in thread
From: Mark A. Greer @ 2007-10-12 21:30 UTC (permalink / raw)
  To: Rune Torgersen; +Cc: linuxppc-embedded

On Fri, Oct 12, 2007 at 03:43:39PM -0500, Rune Torgersen wrote:
> Is there an easy way to use something other than the decrementer for the
> timer interrupt?
> 
> Reason i'm asking is tha t on our board, the decrementer cannot be
> divided to 1khz evenly, so we have rounding errors for time, but we do
> have a 1KHz timer interrupt from an FPGA that is source of a T1 clock.
> 
> Right now I let the decrementer interrupt do nothing, and made my own
> timer interrupt handler that calls the stuff the timer_interrupt usually
> does. 
> 
> This works, but there are some instability (ie unexplained hangs) that
> showed up when I did this.

Check out the clocksource stuff.  It let's you set up numerous clock
sources and set the rating of each one.  You can start looking in
arch/powerpc/kernel/time.c for example code.

Mark

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Override timer interrupt
  2007-10-12 20:49 Rune Torgersen
@ 2007-10-12 21:32 ` Mark A. Greer
  0 siblings, 0 replies; 12+ messages in thread
From: Mark A. Greer @ 2007-10-12 21:32 UTC (permalink / raw)
  To: Rune Torgersen; +Cc: linuxppc-dev

On Fri, Oct 12, 2007 at 03:49:02PM -0500, Rune Torgersen wrote:
> Is there an easy way to use something other than the decrementer for the
> timer interrupt?
> 
> Reason i'm asking is tha t on our board, the decrementer cannot be
> divided to 1khz evenly, so we have rounding errors for time, but we do
> have a 1KHz timer interrupt from an FPGA that is source of a T1 clock.
> 
> Right now I let the decrementer interrupt do nothing, and made my own
> timer interrupt handler that calls the stuff the timer_interrupt usually
> does. 
> 
> This works, but there are some instability (ie unexplained hangs) that
> showed up when I did this.

I just responded to you on -embedded with this:

"Check out the clocksource stuff.  It let's you set up numerous clock
 sources and set the rating of each one.  You can start looking in
 arch/powerpc/kernel/time.c for example code."

Mark

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Override timer interrupt
  2007-10-12 21:30 ` Mark A. Greer
@ 2007-10-12 21:39   ` Rune Torgersen
  2007-10-12 21:55     ` Mark A. Greer
  2007-10-12 22:58     ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 12+ messages in thread
From: Rune Torgersen @ 2007-10-12 21:39 UTC (permalink / raw)
  To: Mark A. Greer; +Cc: linuxppc-dev, linuxppc-embedded

> From: Mark A. Greer=20
> > Is there an easy way to use something other than the decrementer for
the
> > timer interrupt?

> Check out the clocksource stuff.  It let's you set up numerous clock
> sources and set the rating of each one.  You can start looking in
> arch/powerpc/kernel/time.c for example code.

Thanks I will.=20
Currently our board port lives in /arch/ppc (2.6.18) but I will take a
look in powerpc.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Override timer interrupt
  2007-10-12 21:39   ` Rune Torgersen
@ 2007-10-12 21:55     ` Mark A. Greer
  2007-10-12 22:58     ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 12+ messages in thread
From: Mark A. Greer @ 2007-10-12 21:55 UTC (permalink / raw)
  To: Rune Torgersen; +Cc: linuxppc-dev, linuxppc-embedded

On Fri, Oct 12, 2007 at 04:39:53PM -0500, Rune Torgersen wrote:
> > From: Mark A. Greer 
> > > Is there an easy way to use something other than the decrementer for
> the
> > > timer interrupt?
> 
> > Check out the clocksource stuff.  It let's you set up numerous clock
> > sources and set the rating of each one.  You can start looking in
> > arch/powerpc/kernel/time.c for example code.
> 
> Thanks I will. 
> Currently our board port lives in /arch/ppc (2.6.18) but I will take a
> look in powerpc.

Okay.  Just an FYI, arch/ppc will evaporate next summer.

Mark

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Override timer interrupt
  2007-10-12 21:39   ` Rune Torgersen
  2007-10-12 21:55     ` Mark A. Greer
@ 2007-10-12 22:58     ` Benjamin Herrenschmidt
  2007-10-15 16:49       ` Rune Torgersen
  1 sibling, 1 reply; 12+ messages in thread
From: Benjamin Herrenschmidt @ 2007-10-12 22:58 UTC (permalink / raw)
  To: Rune Torgersen; +Cc: linuxppc-dev, linuxppc-embedded


On Fri, 2007-10-12 at 16:39 -0500, Rune Torgersen wrote:
> > From: Mark A. Greer 
> > > Is there an easy way to use something other than the decrementer for
> the
> > > timer interrupt?
> 
> > Check out the clocksource stuff.  It let's you set up numerous clock
> > sources and set the rating of each one.  You can start looking in
> > arch/powerpc/kernel/time.c for example code.
> 
> Thanks I will. 
> Currently our board port lives in /arch/ppc (2.6.18) but I will take a
> look in powerpc.

Beware though... there a quite a few bits in there that assume the
timebase is being used as the main timekeeping source, like the vdso.

In fact, I'm not sure what is your problem with the DEC proper as the TB
will be used ultimately and thus it shouldn't drift more than the TB
does. Can your part use an externally clocked TB ?

If not, and you still have a drift despite calibration, you can always
use NTP services to adjust timekeeping.

Ben.
 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Override timer interrupt
  2007-10-12 22:58     ` Benjamin Herrenschmidt
@ 2007-10-15 16:49       ` Rune Torgersen
  2007-10-15 20:55         ` Benjamin Herrenschmidt
  2007-10-15 23:30         ` Paul Mackerras
  0 siblings, 2 replies; 12+ messages in thread
From: Rune Torgersen @ 2007-10-15 16:49 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, linuxppc-embedded

> From: Benjamin Herrenschmidt
> In fact, I'm not sure what is your problem with the DEC=20
> proper as the TB
> will be used ultimately and thus it shouldn't drift more than the TB
> does. Can your part use an externally clocked TB ?
>=20
> If not, and you still have a drift despite calibration, you can always
> use NTP services to adjust timekeeping.

We use NTP, which is why I didn't see it until recently. (Happened to
have a board without NTP configured

The main couse is that our main bus frequency cannort be divided into
1kHz evently by the decrementer.
Main bus freq =3D 99532800 Hz.
Decrementer then becomes 24883, which gives us 999991.9624485600nsec per
jiffy.
That is not a number easilly converted into time without drift.

Changing HZ to 100 fixes it, but is for varous reasons not an option
right now.

What I did do is change the timer interrupt to be called by an ecxternal
1kHz interrupt source instead of the decrementer.

The TB register is only ued for offsets from the last jiffie, not as a
continous offset, so then it works out pretty good.
There is a discontinuity in the sub ms resolution of the clock that I
can live with. msec and up are dead accurate.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Override timer interrupt
  2007-10-15 16:49       ` Rune Torgersen
@ 2007-10-15 20:55         ` Benjamin Herrenschmidt
  2007-10-15 21:50           ` Rune Torgersen
  2007-10-15 23:30         ` Paul Mackerras
  1 sibling, 1 reply; 12+ messages in thread
From: Benjamin Herrenschmidt @ 2007-10-15 20:55 UTC (permalink / raw)
  To: Rune Torgersen; +Cc: linuxppc-dev, linuxppc-embedded


On Mon, 2007-10-15 at 11:49 -0500, Rune Torgersen wrote:
> 
> The main couse is that our main bus frequency cannort be divided into
> 1kHz evently by the decrementer.
> Main bus freq = 99532800 Hz.
> Decrementer then becomes 24883, which gives us 999991.9624485600nsec
> per
> jiffy.
> That is not a number easilly converted into time without drift.
> 
> Changing HZ to 100 fixes it, but is for varous reasons not an option
> right now.
> 
> What I did do is change the timer interrupt to be called by an
> ecxternal
> 1kHz interrupt source instead of the decrementer.
> 
> The TB register is only ued for offsets from the last jiffie, not as a
> continous offset, so then it works out pretty good.
> There is a discontinuity in the sub ms resolution of the clock that I
> can live with. msec and up are dead accurate.

The date is derived from the absolute TB value though...

Ben.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Override timer interrupt
  2007-10-15 20:55         ` Benjamin Herrenschmidt
@ 2007-10-15 21:50           ` Rune Torgersen
  2007-10-15 21:58             ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 12+ messages in thread
From: Rune Torgersen @ 2007-10-15 21:50 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, linuxppc-embedded

> From: Benjamin Herrenschmidt>=20
> > The TB register is only ued for offsets from the last=20
> jiffie, not as a
> > continous offset, so then it works out pretty good.
>
> The date is derived from the absolute TB value though...

Huh? Not in 2.6.18/arch/ppc at least, unless I'm completely
misundrstanding the code.
ppc/powerpc seems to be using clocksource_jiffies as the clock source,
and teh gettimeofday gets xtime + a offset from last jiffie, and xtime
is updated with a fixed amount per tick.

Things have changed a lot since I last delved deep into this to try to
ge an accurate freerunning clock (2.6.12).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Override timer interrupt
  2007-10-15 21:50           ` Rune Torgersen
@ 2007-10-15 21:58             ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 12+ messages in thread
From: Benjamin Herrenschmidt @ 2007-10-15 21:58 UTC (permalink / raw)
  To: Rune Torgersen; +Cc: linuxppc-dev, linuxppc-embedded


On Mon, 2007-10-15 at 16:50 -0500, Rune Torgersen wrote:
> Huh? Not in 2.6.18/arch/ppc at least, unless I'm completely
> misundrstanding the code.
> ppc/powerpc seems to be using clocksource_jiffies as the clock source,
> and teh gettimeofday gets xtime + a offset from last jiffie, and xtime
> is updated with a fixed amount per tick.
> 
> Things have changed a lot since I last delved deep into this to try to
> ge an accurate freerunning clock (2.6.12).

Hrm... 2.6.18 doesn't have clock sources in the first place, what kernel
are you using ?

Ben.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Override timer interrupt
  2007-10-15 16:49       ` Rune Torgersen
  2007-10-15 20:55         ` Benjamin Herrenschmidt
@ 2007-10-15 23:30         ` Paul Mackerras
  1 sibling, 0 replies; 12+ messages in thread
From: Paul Mackerras @ 2007-10-15 23:30 UTC (permalink / raw)
  To: Rune Torgersen; +Cc: linuxppc-embedded, linuxppc-dev

Rune Torgersen writes:

> The main couse is that our main bus frequency cannort be divided into
> 1kHz evently by the decrementer.
> Main bus freq = 99532800 Hz.
> Decrementer then becomes 24883, which gives us 999991.9624485600nsec per
> jiffy.
> That is not a number easilly converted into time without drift.

That shouldn't be a problem any more with the CONFIG_GENERIC_TIME
stuff.  What happens is that update_wall_time will accumulate
clock->xtime_interval to xtime for every clock->cycle_interval
timebase ticks.  The clock->xtime_interval is in units of 2^-22
nanoseconds, so it is very accurate.  It is computed from
clock->cycle_interval and clock->mult in
clocksource_calculate_interval() (in include/linux/clocksource.h).

Paul.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-10-15 23:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-12 20:43 Override timer interrupt Rune Torgersen
2007-10-12 21:30 ` Mark A. Greer
2007-10-12 21:39   ` Rune Torgersen
2007-10-12 21:55     ` Mark A. Greer
2007-10-12 22:58     ` Benjamin Herrenschmidt
2007-10-15 16:49       ` Rune Torgersen
2007-10-15 20:55         ` Benjamin Herrenschmidt
2007-10-15 21:50           ` Rune Torgersen
2007-10-15 21:58             ` Benjamin Herrenschmidt
2007-10-15 23:30         ` Paul Mackerras
  -- strict thread matches above, loose matches on Subject: below --
2007-10-12 20:49 Rune Torgersen
2007-10-12 21:32 ` Mark A. Greer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).