36 lines
1.7 KiB
Django/Jinja
36 lines
1.7 KiB
Django/Jinja
#!/bin/bash
|
|
# script for tuned AMDGPU clock control
|
|
# configures GPU power/clock characteristics
|
|
# clocks/power in 3D are dynamic based on need/usage
|
|
#
|
|
# for 'amdgpu-default' tuned profiles, this will reset the characteristics to default
|
|
# for others this will apply overclocking settings -- leaving clock choices to the associated power profile (eg: VR)
|
|
#
|
|
# rendered by Ansible with environment-appropriate values:
|
|
# card #, eg: card0
|
|
# path to discovered sysfs device files (power/clock/voltage control)
|
|
#
|
|
# 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
|