R-Car/Tests:timers

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.

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

arch_sys_counter
 * 1) cat /sys/devices/system/clocksource/clocksource0/current_clocksource

Select the source to test,

e60f0000.timer
 * 1) echo e60f0000.timer > /sys/devices/system/clocksource/clocksource0/current_clocksource
 * 2) cat /sys/devices/system/clocksource/clocksource0/current_clocksource

= 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
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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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]
 * 1) ./clocksource-switch
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 2) 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.

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] 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] 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] 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] 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] 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] 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
 * 1) ./clocksource-switch
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0

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]
 * 1) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
 * 2) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0