#!/bin/bash # Copyright (c) 2017-2018, NVIDIA CORPORATION. All Rights Reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. set -e SCRIPT_NAME=$(basename ${0}) # add $HOME to path for test binary PATH="${PATH}:${HOME}" # check if run as root if [[ $(id -u) -ne 0 ]]; then echo "${SCRIPT_NAME}: FAIL: must be run as root" exit 1 fi if [ -e "/proc/device-tree/compatible" ]; then if [ -e "/proc/device-tree/model" ]; then machine="$(tr -d '\0' < /proc/device-tree/model)" fi CHIP="$(tr -d '\0' < /proc/device-tree/compatible)" if [[ "${CHIP}" =~ "tegra186" ]]; then SOCFAMILY="tegra186" elif [[ "${CHIP}" =~ "tegra210" ]]; then SOCFAMILY="tegra210" elif [[ "${CHIP}" =~ "tegra194" ]]; then SOCFAMILY="tegra194" else echo "${SCRIPT_NAME}: FAIL: Platform not supported" exit 1 fi fi echo $SOCFAMILY # set clocks / DVFS features for running RT test if [[ -e /sys/module/qos/parameters/enable ]]; then echo "${SCRIPT_NAME}: disabling qos" echo 0 > /sys/module/qos/parameters/enable fi if [[ -e /sys/kernel/debug/tegra_cpufreq/cc3/enable ]]; then echo "${SCRIPT_NAME}: disabling CC3" echo 0 > /sys/kernel/debug/tegra_cpufreq/cc3/enable fi for i in /sys/kernel/debug/tegra_cpufreq/*/cc3/enable; do case "${SOCFAMILY}" in tegra186) if [ "${i}" == "/sys/kernel/debug/tegra_cpufreq/M_CLUSTER/cc3/enable" ]; then cpustat1=$(cat /sys/devices/system/cpu/cpu1/online) cpustat2=$(cat /sys/devices/system/cpu/cpu2/online) cpustat=${cpustat1} || ${cpustat2} fi if [ "${i}" == "/sys/kernel/debug/tegra_cpufreq/B_CLUSTER/cc3/enable" ]; then cpustat1=$(cat /sys/devices/system/cpu/cpu0/online) cpustat2=$(cat /sys/devices/system/cpu/cpu3/online) cpustat3=$(cat /sys/devices/system/cpu/cpu4/online) cpustat4=$(cat /sys/devices/system/cpu/cpu5/online) cpustat=${cpustat1} || ${cpustat2} || ${cpustat3} || ${cpustat4} fi if [ "${cpustat}" == "1" ]; then echo "${SCRIPT_NAME}: disabling CC3 on $i" echo 0 > $i fi ;; tegra194) if [ "${i}" == "/sys/kernel/debug/tegra_cpufreq/CLUSTER0/cc3/enable" ]; then cpustat1=$(cat /sys/devices/system/cpu/cpu0/online) cpustat2=$(cat /sys/devices/system/cpu/cpu1/online) cpustat=${cpustat1} || ${cpustat2} fi if [ "${i}" == "/sys/kernel/debug/tegra_cpufreq/CLUSTER1/cc3/enable" ]; then cpustat1=$(cat /sys/devices/system/cpu/cpu2/online) cpustat2=$(cat /sys/devices/system/cpu/cpu3/online) cpustat=${cpustat1} || ${cpustat2} fi if [ "${i}" == "/sys/kernel/debug/tegra_cpufreq/CLUSTER2/cc3/enable" ]; then cpustat1=$(cat /sys/devices/system/cpu/cpu4/online) cpustat2=$(cat /sys/devices/system/cpu/cpu5/online) cpustat=${cpustat1} || ${cpustat2} fi if [ "${i}" == "/sys/kernel/debug/tegra_cpufreq/CLUSTER3/cc3/enable" ]; then cpustat1=$(cat /sys/devices/system/cpu/cpu6/online) cpustat2=$(cat /sys/devices/system/cpu/cpu7/online) cpustat=${cpustat1} || ${cpustat2} fi if [ "${cpustat}" == "1" ]; then echo "${SCRIPT_NAME}: disabling CC3 on $i" echo 0 > $i fi ;; *) echo "${SCRIPT_NAME}: disabling CC3 on $i" echo 0 > $i ;; esac done if [[ -e /sys/kernel/debug/tegra_cpufreq/freq_compute_delay ]]; then echo "${SCRIPT_NAME}: setting freq_compute_delay to 2000" echo 2000 > /sys/kernel/debug/tegra_cpufreq/freq_compute_delay fi CPUS=$(grep processor /proc/cpuinfo | awk '{print $3}') for cpu in ${CPUS}; do echo "userspace" | \ tee /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_governor > /dev/null echo -n "${SCRIPT_NAME}: CPU$cpu: setting frequency to " cat /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_max_freq cat /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_max_freq > \ /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_setspeed done # set regulators for i in core sram cpu aon; do if [[ -e /sys/kernel/debug/bpmp/debug/regulator/vdd_$i/max_uv ]] ; then echo -n "${SCRIPT_NAME}: setting vdd_$i regulator to: " cat /sys/kernel/debug/bpmp/debug/regulator/vdd_$i/max_uv cat /sys/kernel/debug/bpmp/debug/regulator/vdd_$i/max_uv > /sys/kernel/debug/bpmp/debug/regulator/vdd_$i/override fi done if [[ -e /sys/kernel/debug/tegra_cpufreq/auto_cc3 ]] ; then echo "${SCRIPT_NAME}: disabling auto cc3" echo 0 > /sys/kernel/debug/tegra_cpufreq/auto_cc3 fi # GPU power/clock gating controls for i in aelpg elpg blcg slcg elcg; do echo "${SCRIPT_NAME}: disabling GPU $i" echo 0 > /sys/devices/gpu.0/${i}_enable done exit 0