linux-mips
[Top] [All Lists]

Re: [patch] Generic time trailing clean-ups

To: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
Subject: Re: [patch] Generic time trailing clean-ups
From: Jun Sun <jsun@mvista.com>
Date: Mon, 11 Aug 2003 11:34:28 -0700
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org, jsun@mvista.com
In-reply-to: <Pine.GSO.3.96.1030811144812.19197C-100000@delta.ds2.pg.gda.pl>; from macro@ds2.pg.gda.pl on Mon, Aug 11, 2003 at 03:02:16PM +0200
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <Pine.GSO.3.96.1030811144812.19197C-100000@delta.ds2.pg.gda.pl>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.2.5i
On Mon, Aug 11, 2003 at 03:02:16PM +0200, Maciej W. Rozycki wrote:
> Hello,
> 
>  Here is hopefully the final part (for now) of the generic time changes.
> It addresses the following problems:
> 
> -      */
> -     if (!jiffies) {
> -             timerhi = timerlo = 0;
> -             mips_hpt_init(count);
> +      *
> +      * The first timer interrupt comes late as interrupts are
> +      * enabled long after timers are initialized.  Therefore the
> +      * high precision timer is fast, leading to wrong gettimeoffset()
> +      * calculations.  We deal with it by setting it based on the
> +      * number of its ticks between the second and the third interrupt.
> +      * That is still somewhat imprecise, but it's a good estimate.
> +      * --macro
> +      */
> +     j = jiffies;
> +     if (j < 4) {
> +             static unsigned int prev_count;
> +             static int hpt_initialized;
> +
> +             switch (j) {
> +             case 0:
> +                     timerhi = timerlo = 0;
> +                     mips_hpt_init(count);
> +                     break;
> +             case 2:
> +                     prev_count = count;
> +                     break;
> +             case 3:
> +                     if (!hpt_initialized) {
> +                             unsigned int c3 = 3 * (count - prev_count);
> +
> +                             timerhi = 0;
> +                             timerlo = c3;
> +                             mips_hpt_init(count - c3);
> +                             hpt_initialized = 1;
> +                     }
> +                     break;
> +             default:
> +                     break;
> +             }
>       }
> 

The first gettimeoffset() call is way after many jiffies (~50 normally?).  Such
an estimate is not necessary.

Also note jiffies can wrap around.  

Jun

<Prev in Thread] Current Thread [Next in Thread>