Jan Kiszka wrote:
> Gilles Chanteperdrix wrote:
>> Hi,
>>
>> I run clocktest on a system here, not running NTP, using
>> CONFIG_GENERIC_CLOCKEVENT, with a systematic drift of 3us/s. How can
>> this happen? Does it come from the error due to the multiply and shift
>> used for tsc to/from ns conversions ?
> 
> What clocksource is used by Linux? Also tsc?

It is an ARM, but yes, the timer used to emulate the tsc is also used by
Linux. Here is the relevant code:

notrace unsigned long long __ipipe_mach_get_tsc(void)
{
        if (likely(ixp4xx_timer_initialized)) {
                union tsc_reg *local_tsc, result;
                unsigned long stamp;

                local_tsc = &tsc[ipipe_processor_id()];

                __asm__ ("ldmia %1, %M0\n":
                         "=r"(result.full): "r"(local_tsc),
"m"(*local_tsc));
                barrier();
                stamp = *IXP4XX_OSTS;
                if (unlikely(stamp < result.low))
                        /* 32 bit counter wrapped, increment high word. */
                        result.high++;
                result.low = stamp;
                return result.full;
        }

        return 0;
}

cycle_t ixp4xx_get_cycles(void)
{
        return *IXP4XX_OSTS;
}

static struct clocksource clocksource_ixp4xx = {
        .name           = "OSTS",
        .rating         = 200,
        .read           = ixp4xx_get_cycles,
        .mask           = CLOCKSOURCE_MASK(32),
        .shift          = 20,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
};

unsigned long ixp4xx_timer_freq = FREQ;
static int __init ixp4xx_clocksource_init(void)
{
        clocksource_ixp4xx.mult =
                clocksource_hz2mult(ixp4xx_timer_freq,
                                    clocksource_ixp4xx.shift);
        clocksource_register(&clocksource_ixp4xx);

        return 0;
}


-- 
                                                 Gilles.

_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to