R-Car/Tests:timers

From eLinux.org
Jump to: navigation, search

This document describes how to test the CMT and TMU devices on Renesas R-Car Gen2 and Gen3 SoCs. There are other SoCs that have CMT and TMU devices but as the test procedures are not verified on such devices they are not listed here.

Configuration

  • The kernel configuration options CONFIG_SH_TIMER_CMT and CONFIG_SH_TIMER_TMU need to be set.
  • The cmt and/or tmu nodes to be tested need to be enabled in DT. The nodes are already recorded in most upstream DT source files but they are marked as disabled.

Selection

It is possible to switch source at runtime. As a first step examine the available sources and which one is currently in use.

# cat /sys/devices/system/clocksource/clocksource0/available_clocksource
arch_sys_counter e61e0000.timer e6fc0000.timer e6fd0000.timer e6fe0000.timer ffc00000.timer e60f0000.timer e6130000.timer e6140000.timer e6148000.timer

# cat /sys/devices/system/clocksource/clocksource0/current_clocksource 
arch_sys_counter

Select the source to test,

# echo e60f0000.timer > /sys/devices/system/clocksource/clocksource0/current_clocksource
# cat /sys/devices/system/clocksource/clocksource0/current_clocksource 
e60f0000.timer

Kernel selftests

The kernel provides a few selftests for timers in tools/testing/selftests/timers. Particular interesting are clocksource-switch.c, inconsistency-check.c and nanosleep.c.

The inconsistency-check and nanosleep tests verifies the currently selected clock source while clocksource-switch test all sources in the system. It does so by utilizing the other two tests for each source and also once while rapidly changing the source over all available ones.

A PASS test run on a M3-N with all CMT and TMU nodes enabled

# ./clocksource-switch 
Validating clocksource arch_sys_counter
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e61e0000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e6fc0000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e6fd0000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e6fe0000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource ffc00000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e60f0000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e6130000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e6140000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e6148000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Running Asynchronous Switching Tests...
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0

A FAIL test run on a M3-N with two CMT nodes enabled

The test run is a FAIL as it hits a deadlock. The issue is fixed in a yet to accepted upstream patch [PATCH 0/2] timekeeping: Fix change_clocksource() for PM and sh_cmt.

# ./clocksource-switch 
Validating clocksource arch_sys_counter
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e60f0000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Validating clocksource e6130000.timer
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 [OK]
Consistent CLOCK_TAI                      [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Nanosleep CLOCK_REALTIME                  [OK]
Nanosleep CLOCK_MONOTONIC                 [OK]
Nanosleep CLOCK_MONOTONIC_RAW             [UNSUPPORTED]
Nanosleep CLOCK_REALTIME_COARSE           [UNSUPPORTED]
Nanosleep CLOCK_MONOTONIC_COARSE          [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME                  [OK]
Nanosleep CLOCK_REALTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_BOOTTIME_ALARM            [UNSUPPORTED]
Nanosleep CLOCK_TAI                       [OK]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
Running Asynchronous Switching Tests...
Consistent CLOCK_REALTIME                 [OK]
Consistent CLOCK_MONOTONIC                [OK]
Consistent CLOCK_PROCESS_CPUTIME_ID       [OK]
Consistent CLOCK_THREAD_CPUTIME_ID        [OK]
Consistent CLOCK_MONOTONIC_RAW            [OK]
Consistent CLOCK_REALTIME_COARSE          [OK]
Consistent CLOCK_MONOTONIC_COARSE         [OK]
Consistent CLOCK_BOOTTIME                 

620:582799512
620:582799512
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
--------------------
620:583045696
620:582799512
--------------------
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:582799512
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583045696
620:583291880
620:583291880
620:583291880
620:583291880
620:583291880
620:583291880
620:583291880
620:583291880
620:583291880
Delta: 246184 ns

[FAILED]
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0