LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-27-2012, 02:14 AM   #1
shabbirkhan
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Rep: Reputation: Disabled
HR timer support


I am working on ARM9 board whose clock is configured to operate at milliseconds resolution,but i wanted to enable the High resolution timer support in order the clock to operate in the order of microseconds,In make menuconfig i didnt have HR timer support option by default so i made changes to arch/arm/Kconfig to bring in support,then i have enabled HR timer support in make menuconfig and then recompiled the kernel and after that i checked cat /proc/timer_list in which the attribute .hres_active is still equals to 0,but it should be 1.Also resulotion is also not showing 1nsecs,instead it is showing 1000000nanosecs.can you please suggest me how to implement HIGH RESOLUTION timer support for my ARM hardware?I am using linux-2.6.28 kernel.

Thanks
Regards
Shabbir
 
Old 02-28-2012, 10:56 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
To have HRT support, there must be code under the /arch kernel directory to access the hardware, like a get_time call. What code is there for your ARM implementation?
 
Old 02-28-2012, 10:48 PM   #3
shabbirkhan
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for the reply.

The following is my board specific timer code for my ARM board:

static irqreturn_t mcs8142_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
//volatile TimerStruct_t *timer = (volatile TimerStruct_t *) _CONFADDR_TIMER;
//write_seqlock(&xtime_lock);
wr_d(_CONFADDR_TIMER+0x1C,0x01);
__clear_irq(IRQ_TIMER);
timer_tick();
//write_sequnlock(&xtime_lock);
return IRQ_HANDLED;
}


static struct irqaction timer_irq = {
.name = "MCS8142 Timer irq",
.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
.handler = mcs8142_timer_interrupt
};

static void mcs8142_timer_init(void)
{
volatile TimerStruct_t *timer = (volatile TimerStruct_t *)_CONFADDR_TIMER;

wr_d(_CONFADDR_TIMER+0x1C,0x01);
timer->__32BitTimerControl = 0x00; /* disable timer */
timer->__32BitTimerValue = TIMER_RELOAD_VAL;
LastReload = TIMER_RELOAD_VAL;
timer->__32BitTimerReload = TIMER_RELOAD_VAL;
setup_irq(IRQ_TIMER, &timer_irq);
timer->__32BitTimerControl = 0x07; /* enable timer, stop timer in debug mode */
}

struct sys_timer mcs8142_timer = {
.init = mcs8142_timer_init,
};
 
Old 02-29-2012, 06:56 PM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
I don't see anything in there that tells me the resolution or is reading a nanosecond clock. What's the output from:

Code:
cat /proc/timer_list
 
Old 02-29-2012, 09:19 PM   #5
shabbirkhan
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
The output of cat /proc/timer_list is as follows:
#cat /proc/timer_list

Timer List Version: v0.6
HRTIMER_MAX_CLOCK_BASES: 3
now at 13930000002 nsecs

cpu: 0
clock 0:
.base: c03079c0
.index: 0
.resolution: 10000000 nsecs
.get_time: ktime_get
.offset: 0 nsecs
active timers:
#0: <c39c3f30>, hrtimer_wakeup, S:01
# expires at 13960000002-13960050002 nsecs [in 30000000 to 30050000 nsecs]
#1: <c0317698>, sched_rt_period_timer, S:01
# expires at 14000000000-14000000000 nsecs [in 69999998 to 69999998 nsecs]
#2: <c39d5f30>, hrtimer_wakeup, S:01
# expires at 14150000002-14150050002 nsecs [in 220000000 to 220050000 nsecs]
#3: <c3bb9b68>, hrtimer_wakeup, S:01
# expires at 15040000002-15044990002 nsecs [in 1110000000 to 1114990000 nsecs]
#4: <c3871b08>, it_real_fn, S:01
# expires at 365030000002-365030000002 nsecs [in 351100000000 to 351100000000 nsecs]
clock 1:
.base: c03079f8
.index: 1
.resolution: 10000000 nsecs
.get_time: ktime_get_real
.offset: 0 nsecs
active timers:
clock 2:
.base: c0307a30
.index: 2
.resolution: 10000000 nsecs
.get_time: ktime_get_boottime
.offset: 0 nsecs
active timers:
.expires_next : 9223372036854775807 nsecs
.hres_active : 0
.nr_events : 0
.nr_retries : 0
.nr_hangs : 0
.max_hang_time : 0 nsecs
.nohz_mode : 0
.idle_tick : 0 nsecs
.tick_stopped : 0
.idle_jiffies : 0
.idle_calls : 0
.idle_sleeps : 0
.idle_entrytime : 13930000002 nsecs
.idle_waketime : 0 nsecs
.idle_exittime : 0 nsecs
.idle_sleeptime : 0 nsecs
.iowait_sleeptime: 0 nsecs
.last_jiffies : 0
.next_jiffies : 0
.idle_expires : 0 nsecs
jiffies: 4294938689


Tick Device: mode: 0
Per CPU device: 0
Clock Event Device: <NULL>
 
Old 03-01-2012, 10:54 AM   #6
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
None of your clocks have nanosecond resolution. Your hardware doesn't appear to support hi-res timers.
 
Old 03-01-2012, 10:19 PM   #7
shabbirkhan
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you very much.

Is there any possibility to upgrade such high resolution timers to hardware? Can you please give me the clarification on this,because i am very much confused on this.


Thanks
Regards
Shabbir
 
Old 03-02-2012, 09:30 AM   #8
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
The CPU in my Intel system has a clock like this:

cpu: 0
clock 0:
.base: ffff88003fc0e780
.index: 0
.resolution: 1 nsecs
.get_time: ktime_get
.offset: 0 nsecs

That means there is a CPU counter running at 1 GHz which can be read by the HRT software. Some ARM chips have high-res timers but not all. You need to find the hardware specs on your chip to know what is available. Even if the hardware is there, you still need to have the call to read it in your kernel. This is likely to be a single assembly-language instruction wrapped in the appropriate compiler glue to return a uint.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
High Resolution Timer Support???? Southpaw76 Linux - Kernel 2 11-20-2009 02:46 AM
How can I get LAPIC timer to run instead of the PIT timer? sixerjman Linux - Kernel 1 10-16-2007 09:59 PM
C timer ieatsplaydoh Programming 12 05-02-2007 06:36 PM
Multimedia timer (SMP friendly timer) bigqueso Linux - Kernel 0 03-15-2007 03:49 PM
timer in c?? AcidHell2 Programming 9 08-12-2004 01:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration