make card# assignment dynamic, clean up linting
This commit is contained in:
parent
e535ea3ebc
commit
f18704dbfe
4 changed files with 94 additions and 59 deletions
|
@ -13,18 +13,23 @@
|
|||
# AMDGPU driver/sysfs references:
|
||||
# https://01.org/linuxgraphics/gfx-docs/drm/gpu/amdgpu.html
|
||||
# https://docs.kernel.org/gpu/amdgpu/thermal.html
|
||||
|
||||
{# done this way to avoid issues with the card number possibly shifting after playbook run #}
|
||||
# dynamically determine the connected GPU using the DRM subsystem
|
||||
CARD=$(/usr/bin/grep -ls ^connected /sys/class/drm/*/status | /usr/bin/grep -o 'card[0-9]' | /usr/bin/sort | /usr/bin/uniq | /usr/bin/tail -1)
|
||||
|
||||
{# begin the templated script for 'default' profiles to reset state #}
|
||||
{% if 'default' in item.0.key %}
|
||||
|
||||
# set power state transition heuristics to default
|
||||
echo '{{ item.0.value.pwrmode }}' | tee /sys/class/drm/{{ card }}/device/pp_power_profile_mode
|
||||
echo '{{ item.0.value.pwrmode }}' | tee /sys/class/drm/"${CARD}"/device/pp_power_profile_mode
|
||||
|
||||
# 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
|
||||
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
|
||||
echo 'r' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage
|
||||
|
||||
# give default profile {{ power_max_default_multi * 100.0 |int }}% of the max power capability
|
||||
# {{ power_cap_default|int/1000000 }} Watts of {{ power_max|int/1000000 }} total
|
||||
|
@ -36,34 +41,34 @@ echo '{{ power_cap_default }}' | tee {{ powercap_set.files.0.path }}
|
|||
# allows control via 'pp_dpm_mclk', 'pp_dpm_sclk', 'pp_dpm_pcie', 'pp_dpm_fclk', and 'pp_power_profile_mode' files
|
||||
# only interested in 'pp_power_profile_mode' for power and 'pp_dpm_mclk' for memory clock (flickering).
|
||||
# GPU clocks are dynamic based on (load) condition
|
||||
echo 'manual' | tee /sys/class/drm/{{ card }}/device/power_dpm_force_performance_level
|
||||
echo 'manual' | tee /sys/class/drm/"${CARD}"/device/power_dpm_force_performance_level
|
||||
|
||||
# set power state transition heuristics to '{{ item.0.key }}' profile
|
||||
echo '{{ item.0.value.pwrmode }}' | tee /sys/class/drm/{{ card }}/device/pp_power_profile_mode
|
||||
echo '{{ item.0.value.pwrmode }}' | tee /sys/class/drm/"${CARD}"/device/pp_power_profile_mode
|
||||
|
||||
# give this profile {{ power_max_custom_multi * 100.0 |int }}% of the max power capability
|
||||
# {{ power_cap_custom|int/1000000 }} Watts of {{ power_max|int/1000000 }} total
|
||||
echo '{{ power_cap_custom }}' | tee {{ powercap_set.files.0.path }}
|
||||
|
||||
# set the minimum GPU clock
|
||||
echo 's 0 {{ gpu_clock_min }}' | tee /sys/class/drm/{{ card }}/device/pp_od_clk_voltage
|
||||
echo 's 0 {{ gpu_clock_min }}' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage
|
||||
|
||||
# set the maximum GPU clock
|
||||
echo 's 1 {{ gpu_clock_max }}' | tee /sys/class/drm/{{ card }}/device/pp_od_clk_voltage
|
||||
echo 's 1 {{ gpu_clock_max }}' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage
|
||||
|
||||
# set the maximum GPU *memory* clock
|
||||
echo 'm 1 {{ gpumem_clock_max }}' | tee /sys/class/drm/{{ card }}/device/pp_od_clk_voltage
|
||||
echo 'm 1 {{ gpumem_clock_max }}' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage
|
||||
{% if gpu_mv_offset is defined %}
|
||||
|
||||
# offset GPU voltage {{ gpu_mv_offset }}mV
|
||||
echo 'vo {{ gpu_mv_offset }}' | tee /sys/class/drm/{{ card }}/device/pp_od_clk_voltage
|
||||
echo 'vo {{ gpu_mv_offset }}' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage
|
||||
{% endif %}
|
||||
|
||||
# commit the changes
|
||||
echo 'c' | tee /sys/class/drm/{{ card }}/device/pp_od_clk_voltage
|
||||
echo 'c' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage
|
||||
|
||||
# force GPU memory into highest clock (fix flickering)
|
||||
# pp_dpm_*clk settings are unintuitive, giving profiles that may be used
|
||||
# opt not to set the others (eg: sclk/fclk) - those should remain for benefits from the curve
|
||||
echo '3' | tee /sys/class/drm/{{ card }}/device/pp_dpm_mclk
|
||||
echo '3' | tee /sys/class/drm/"${CARD}"/device/pp_dpm_mclk
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue