tuned-amdgpu/roles/tuned_amdgpu/templates/amdgpu-profile-default.sh.j2

29 lines
1.3 KiB
Text
Raw Normal View History

#!/bin/bash
2024-03-25 00:17:05 +00:00
{{ ansible_managed | comment }}
# This is the 'default' script; resetting amdgpu clock/power/voltage tunables
#
# AMDGPU driver/sysfs references:
# https://01.org/linuxgraphics/gfx-docs/drm/gpu/amdgpu.html
# https://docs.kernel.org/gpu/amdgpu/thermal.html
#
# start by including the 'common' script; determines card/hwmon dir/power profiles/power capability
. $(dirname "${BASH_SOURCE[0]}")/amdgpu-common.sh
{# begin the templated script for 'default' profiles to reset state #}
# set control mode back to auto
# attempts to dynamically set optimal power profile for (load) conditions
echo 'auto' | tee /sys/class/drm/"${CARD}"/device/power_dpm_force_performance_level
# reset any existing profile clock changes
echo 'r' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage
# adjust power limit using multiplier against board capability
POWER_LIM_DEFAULT=$(/usr/bin/awk -v m="$POWER_CAP" -v n={{ gpu_power_multi.default }} 'BEGIN {printf "%.0f", (m*n)}')
echo "$POWER_LIM_DEFAULT" | tee "${HWMON_DIR}/power1_cap"
# extract the power-saving profile ID number
PROF_DEFAULT_NUM=$(/usr/bin/awk '$0 ~ /BOOTUP_DEFAULT.*:/ {print $1}' <<< "$PROFILE_MODES")
# reset power/clock heuristics to power-saving
echo "${PROF_DEFAULT_NUM}" | tee /sys/class/drm/"${CARD}"/device/pp_power_profile_mode