Skip to contentSkip to conversation

high resolution timer

RFC Lukasz Majewski 2 participants 2 messages May 15, 2011 – Aug 5, 2012 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 6 lines · On Fri, 13 May 2011 10:08:03 -0400 Andy O'Brien <[email protected]> wrote:

Lukasz,

Have you made any headway on supporting the Vortex86's high resolution timer? I'm in the same boat and would very much like to support it.

Quoted 6 lines

Are you still planning on implementing support for the other counter? Perhaps we could work together?

Best,
Andy

Hi Andy,

The support for the High Resolution Timers on the Vortex86DX shall be considered as work in progress.

Firstly, I've looked into the "struct clocksource" and try to understand Vortex's internals:

1. One i8254 timer (0x40 - 0x43) is used by PIT. It has a hardcoded frequency of 1.19MHz. It is NOT suitable for any "real-time" control control application (rounding problem and relatively low frequency).

2. Another i8254 timer is the PWM timer (0x44 - 0x48). A programmer can change the frequency of this timer (IO pins are muxed with COM2). So it is possible to connect e.g. 20MHz external oscillator and provide very stable clock source.

3. TSC - Time Stamp Counter (one of vortex86 features - as seen on the cat /proc/cpuinfo) allows for reading the internal chip counter via an assembler instruction - RDTSC (rdtscll). It works on vortex86DX and it seems, that this timer value is incremented with each clock tick provided to CPU (e.g. 500MHz). Therefore it is a preferred clock source for Vortex86 board.

It would be desirable to use this as clocksource with the "struct hrtimer_cpu_base.clock_base".

I was studying the presentation:
http://www.kernel.org/pub/linux/kernel/people/tglx/hrtimers/ols2006-hrtimers.pdf

And try to "link" the slide 22 with the kernel source (I'm using 2.6.33.7.2-rt30).

In my opinion it is better to use the TSC counter as a clock base (kernel/hrtimer.c).

To do that I guess, that I need to:
1. Define my own hrtimer_cpu_base with TSC .get_time =get_time() function, .resolution=1.25 ns and .index = CLOCK_MONOTONIC
2. Define hrtimer struct (with .restart callback function) and use hrtimer_init function for initialization.

3. .... I don't know if it is sufficient. Hints? Ideas?

Anyway I will investigate this issue in the following days (since HRtimer subsystem is quite large) and poke for solution at other architectures.

Best regards,
Lukasz

#2 lore raw

Hi all,

I use the kernel parameter tsc=reliable for my vortex86. This somehow activate the high resolution timer.

Cheers,
Ben