Hello,

The attached patch is an attempt to work around the buggy timestamp
counter on the NatSemi SC1100 CPU by using the on-board 27MHz
high-resolution timer as an alternative time source.  It should,
in theory, work with any of the SCx200 CPUs as well, though I have
been unable to test this.  I have tested it fairly thoroughly with NTP
on an SC1100 and it seems to behave sanely.

That said, there are three things about it that I'm not entirely
comfortable with:

(1) The high-resolution timer is driven by a separate crystal than the
    CPU's timer interrupt, and on the SC1100 I have access to, it's
    consistently slower.  I've found that it is necessary to
    periodically *decrement* the jiffies_64 counter in mark_offset in
    order to make gettimeofday produce anything reasonable.  In
    practice jiffies_64 is incremented again in do_timer before
    anything else reads it, so the net effect is minimal.

(2) The 27MHz timer is accessed via the PCI bus, which is not
    available when the system clock is initialized.  To work around
    this, I've written the init function to always fail so that
    loops_per_jiffy is computed using another timer (the TSC in my
    case).  Once the high-resolution timer is accessible, the kernel
    will switch to using it to compute gettimeofday and the monotonic
    clock, but still use the original timer's delay function.  This
    is somewhat kludgy, but I can't see a cleaner way.

(3) The timer depends on CONFIG_SCx200, which appears later in the
    configuration hierarchy to the timers, and in an entirely
    different part.  For now I've kept its Kconfig with the other
    timers, but I'm not entirely happy with this choice.
    
The patch is against linux-2.6.11-mm2 as it relies on the
'determine-scx200-cb-address-at-run-time.patch' patch which has not
made it into in the mainline.

Please CC me if you reply as I'm not subscribed to LKML.

Cheers,
-Ted

Attachment: scx200-hr-timer-2.6.11-mm2-5.diff.gz
Description: GNU Zip compressed data

Reply via email to