DRIVE 5.0 Linux Open Source Software

Development Guide Release

CPU Frequency Scaling
Note for Tegra Code-Name Parker CPU Cluster Cores
CPU Frequency Deviations
The CPU frequency governor “userspace” allows any userspace program running with UID root to set the CPU to a specific frequency by using a sysfs file named scaling_setspeed available in the CPU-device directory.
For more information on CPU frequency, see:
To view the current governor set
Enter the following command:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
To view the available frequencies
Enter the following command:
cat /sys/devices/system/cpu/cpu<X>/cpufreq/scaling_available_frequencies
Where X is the CPU core number.
To see the current CPU clock frequency
Enter the following commands:
cat /sys/devices/system/cpu/cpu<X>/cpufreq/cpuinfo_cur_freq
Where X is the CPU core number.
To change the CPU frequency in the userspace governor
Enter the following command:
echo <frequency_in_kHz> 1689600 > /sys/devices/system/cpu/cpu<X>/cpufreq/scaling_setspeed
Where X is the CPU core number.
For example, to set the CPU frequency to 1.53 gigahertz, enter:
echo 1530000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
Only governor “userspace” and “performance” are supported..
Note for Tegra Code-Name Parker CPU Cluster Cores
For CPU cluster cores, frequency is set to maximum frequency of CPU cores under that cluster.
For example, if CPU0, CPU3, CPU4 and CPU5 belong to a single cluster, performing the following step sets frequency 1689600 to all cpu cores (0, 3, 4, and 5) of this cluster. The maximum frequency 1689600 KHz is set to all cores CPU under that cluster.
echo 1536000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
echo 1497600 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_setspeed
echo 1689600 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_setspeed
echo 1536000 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_setspeed
CPU Frequency Deviations
CPU frequency is calculated by reading HW counters two times with a delay in between. Below is the pseudo code:
Read counters at Time t1
Read counters at Time t1+ freq_compute_delay
Derive the CPU frequency based on the counters increment done.
The code above runs only on the CPU for which the frequency reading is requested.
By default, the “freq_compute_delay” is 20 microseconds, but this delay is not enough to get CPU frequency readings correctly all the time.
To get the CPU frequency readings correctly, you must increase freq_compute_delay to 2000 microseconds by running the following command:
echo 2000 > /sys/kernel/debug/tegra_cpufreq/freq_compute_delay
Note that increasing freq_compute_delay makes the CPU busy for time equal to freq_compute_delay whenever reading of frequency is requested.
CPU frequencies reported may not match the requested frequencies, varying by as much as +/- 50 megahertz (MHz), when read with the following command:
cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq