-
-
Save adujardin/049c489ef48b4ed75603cd4e33c91c07 to your computer and use it in GitHub Desktop.
Nvidia's Max Performance Script for Tegra X1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
enable_fan(){ | |
# turn on fan for safety | |
echo "Enabling fan for safety..." | |
if [ ! -w /sys/kernel/debug/tegra_fan/target_pwm ] ; then | |
echo "Cannot set fan -- exiting..." | |
fi | |
echo 255 > /sys/kernel/debug/tegra_fan/target_pwm | |
} | |
tegra_x1_max_perf(){ | |
enable_fan | |
echo 0 > /sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/enable | |
echo 1 > /sys/kernel/cluster/immediate | |
echo 1 > /sys/kernel/cluster/force | |
echo G > /sys/kernel/cluster/active | |
echo "Cluster: $(cat /sys/kernel/cluster/active)" | |
# online all CPUs - ignore errors for already-online units | |
echo "onlining CPUs: ignore errors..." | |
for i in 0 1 2 3 ; do | |
echo 1 > /sys/devices/system/cpu/cpu${i}/online | |
done | |
echo "Online CPUs: $(cat /sys/devices/system/cpu/online)" | |
# set CPUs to max freq (perf governor not enabled on L4T yet) | |
echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor | |
cpumax=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies | awk '{print $NF}') | |
echo "${cpumax}" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed | |
for i in 0 1 2 3 ; do | |
echo "CPU${i}: $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)" | |
done | |
# max GPU clock (should read from debugfs) | |
cat /sys/kernel/debug/clock/gbus/max > /sys/kernel/debug/clock/override.gbus/rate | |
echo 1 > /sys/kernel/debug/clock/override.gbus/state | |
echo "GPU: $(cat /sys/kernel/debug/clock/gbus/rate)" | |
# max EMC clock (should read from debugfs) | |
cat /sys/kernel/debug/clock/emc/max > /sys/kernel/debug/clock/override.emc/rate | |
echo 1 > /sys/kernel/debug/clock/override.emc/state | |
echo "EMC: $(cat /sys/kernel/debug/clock/emc/rate)" | |
} | |
tegra_x2_max_perf(){ | |
enable_fan | |
nvpmodel -m 0 | |
} | |
tegra_detection=$( | |
case "$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id 2>/dev/null)" in | |
("64") echo "tegra_k1" ;; | |
("33") echo "tegra_x1" ;; | |
("24") echo "tegra_x2" ;; | |
(*) echo "unknown" ;; | |
esac) | |
echo "${tegra_detection} detected !" | |
case "${tegra_detection}" in | |
("tegra_x1") tegra_x1_max_perf ;; | |
("tegra_x2") tegra_x2_max_perf ;; | |
(*) echo "Unsupported target" ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment