SAMA5D27 - High Resolution Timer support

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

KevinWysocki
Posts: 4
Joined: Wed Aug 22, 2018 5:20 pm

SAMA5D27 - High Resolution Timer support

Wed Aug 29, 2018 3:30 pm

Hi everybody,

I use SAMA5D2 Xplained demo board with Linux4SAM v5.8 (Linux Kernel v4.9.87), got "Preemptible Kernel" and "High Resolution Timer Support" checked.

I am writing a Kernel module which need to trigger a timer with a period between 1us and 200us so high res timer would be useful.

During Kernel starting :

Code: Select all

sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 21474836475000000ns
And a cat /proc/timer_list command returns :

Code: Select all

Timer List Version: v0.8
HRTIMER_MAX_CLOCK_BASES: 4
now at 133585208076 nsecs

cpu: 0
 clock 0:
  .base:       c080e540
  .index:      0
  .resolution: 10000000 nsecs
  .get_time:   <c0161418>
  .offset:     0 nsecs
active timers:
 #0: <c08456d8>, <c0169f84>, S:01
 # expires at 21474836475000000-21474836475000000 nsecs [in 21474702889791924 to 21474702889791924 nsecs]
 clock 1:
  .base:       c080e560
  .index:      1
  .resolution: 10000000 nsecs
  .get_time:   <c015b98c>
  .offset:     1325567565159780627 nsecs
active timers:
 clock 2:
  .base:       c080e580
  .index:      2
  .resolution: 10000000 nsecs
  .get_time:   <c015b9a4>
  .offset:     0 nsecs
active timers:
 clock 3:
  .base:       c080e5a0
  .index:      3
  .resolution: 10000000 nsecs
  .get_time:   <c015b9bc>
  .offset:     1325567565159780627 nsecs
active timers:
  .expires_next   : 9223372036854775807 nsecs
  .hres_active    : 0
  .nr_events      : 0
  .nr_retries     : 0
  .nr_hangs       : 0
  .max_hang_time  : 0
  .nohz_mode      : 0
  .last_tick      : 0 nsecs
  .tick_stopped   : 0
  .idle_jiffies   : 0
  .idle_calls     : 0
  .idle_sleeps    : 0
  .idle_entrytime : 133574060509 nsecs
  .idle_waketime  : 0 nsecs
  .idle_exittime  : 0 nsecs
  .idle_sleeptime : 129169628324 nsecs
  .iowait_sleeptime: 729213876 nsecs
  .last_jiffies   : 0
  .next_timer     : 0
  .idle_expires   : 0 nsecs
jiffies: 4294950651

Tick Device: mode:     0
Per CPU device: 0
Clock Event Device: pit
 max_delta_ns:   0
 min_delta_ns:   0
 mult:           22280142
 shift:          32
 mode:           2
 next_event:     9223372036854775807 nsecs
 set_next_event: <00000000>
 shutdown: <c049970c>
 periodic: <c0499728>
 event_handler:  <c0169940>
 retries:        0
Does SAMA5D27 support high resolution timers ? Anyway to get a resolution of 1ns ?

Regards,

Kevin
blue_z
Location: USA
Posts: 1716
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D27 - High Resolution Timer support

Fri Aug 31, 2018 1:31 am

KevinWysocki wrote: Does SAMA5D27 support high resolution timers ?
Yes.
KevinWysocki wrote: Anyway to get a resolution of 1ns ?
All you have to do is use the kernel configuration "sama5_defconfig", which will automatically configure both halves of this feature.
CONFIG_HIGH_RES_TIMERS only enables the upper-half of the framework. The bottom half is a driver for the timer hardware.

# uname -r
4.9.87-linux4sam_5.8
# cat /proc/timer_list
Timer List Version: v0.8
HRTIMER_MAX_CLOCK_BASES: 4
now at 58037114882 nsecs

cpu: 0
clock 0:
.base: c0d0e0c0
.index: 0
.resolution: 1 nsecs
.get_time: <c01534fc>
.offset: 0 nsecs
...

Regards
KevinWysocki
Posts: 4
Joined: Wed Aug 22, 2018 5:20 pm

Re: SAMA5D27 - High Resolution Timer support

Fri Aug 31, 2018 11:48 am

blue_z wrote:
Fri Aug 31, 2018 1:31 am
All you have to do is use the kernel configuration "sama5_defconfig", which will automatically configure both halves of this feature.
CONFIG_HIGH_RES_TIMERS only enables the upper-half of the framework. The bottom half is a driver for the timer hardware.
I didn't specify it but yes, my kernel is configured with "sama5_defconfig" (sama5d2_xplained_mmc_defconfig to be specific).

Here is an extract of my .config file :
#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
# CONFIG_NO_HZ is not set
CONFIG_HIGH_RES_TIMERS=y
blue_z wrote:
Fri Aug 31, 2018 1:31 am
# uname -r
4.9.87-linux4sam_5.8
# cat /proc/timer_list
Timer List Version: v0.8
HRTIMER_MAX_CLOCK_BASES: 4
now at 58037114882 nsecs

cpu: 0
clock 0:
.base: c0d0e0c0
.index: 0
.resolution: 1 nsecs
.get_time: <c01534fc>
.offset: 0 nsecs
...
On my board :
# uname -r
4.9.87-linux4sam_5.8
# cat /proc/timer_list
Timer List Version: v0.8
HRTIMER_MAX_CLOCK_BASES: 4
now at 25116337923 nsecs

cpu: 0
clock 0:
.base: c080e540
.index: 0
.resolution: 10000000 nsecs
.get_time: <c0161418>
.offset: 0 nsecs
active timers:
#0: <c08456d8>, <c0169f84>, S:01
# expires at 21474836475000000-21474836475000000 nsecs [in 21474811358662077 to 21474811358662077 nsecs]
clock 1:
.base: c080e560
.index: 1
.resolution: 10000000 nsecs
.get_time: <c015b98c>
.offset: 1325715972159718169 nsecs
active timers:
clock 2:
.base: c080e580
.index: 2
.resolution: 10000000 nsecs
.get_time: <c015b9a4>
.offset: 0 nsecs
active timers:
clock 3:
.base: c080e5a0
.index: 3
.resolution: 10000000 nsecs
.get_time: <c015b9bc>
.offset: 1325715972159718169 nsecs
active timers:
.expires_next : 9223372036854775807 nsecs
.hres_active : 0
.nr_events : 0
.nr_retries : 0
.nr_hangs : 0
.max_hang_time : 0
.nohz_mode : 0
.last_tick : 0 nsecs
.tick_stopped : 0
.idle_jiffies : 0
.idle_calls : 0
.idle_sleeps : 0
.idle_entrytime : 25105522309 nsecs
.idle_waketime : 0 nsecs
.idle_exittime : 0 nsecs
.idle_sleeptime : 20852948791 nsecs
.iowait_sleeptime: 738272787 nsecs
.last_jiffies : 0
.next_timer : 0
.idle_expires : 0 nsecs
jiffies: 4294939804

Tick Device: mode: 0
Per CPU device: 0
Clock Event Device: pit
max_delta_ns: 0
min_delta_ns: 0
mult: 22280142
shift: 32
mode: 2
next_event: 9223372036854775807 nsecs
set_next_event: <00000000>
shutdown: <c049970c>
periodic: <c0499728>
event_handler: <c0169940>
retries: 0
I also tried to modify the Kernel tick to 1kHz (just to give a try) and it has not been modified (still at 100Hz).

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 5 guests