sibradzic / amdgpu-clocks

Simple script to control power states of amdgpu driven GPUs
GNU General Public License v2.0
393 stars 44 forks source link

Add power profile management #7

Closed ittomsk closed 4 years ago

ittomsk commented 4 years ago

Add power profile management

--- /usr/bin/amdgpu-clocks.orig 2019-12-18 22:35:47.273610889 +0700
+++ /usr/bin/amdgpu-clocks  2019-12-18 22:41:27.778272025 +0700
@@ -80,6 +80,10 @@
         echo "  Force performance level to ${LINE#* }"
         FORCE_LEVEL=${LINE#* }
         ;;
+      "FORCE_POWER_PROFILE: "[0-6])
+        echo "  Force power profile to ${LINE#* }"
+        FORCE_PROFILE=${LINE#* }
+        ;;
       "#"*) ;;
       "") ;;
       *)
@@ -99,6 +103,9 @@
   if [ "${FORCE_LEVEL}" ]; then
     echo ${FORCE_LEVEL} > ${PWR_LEVEL}
   fi
+  if [ "${FORCE_PROFILE}" ]; then
+    echo ${FORCE_PROFILE} > ${PWR_PROFILE}
+  fi
   for CSTATE in "${SCLK[@]}"; do
     echo ${CSTATE} > ${SYS_PP_OD_CLK}
   done
@@ -125,6 +132,7 @@
 for USER_STATE_FILE in $(ls -1 ${USER_STATES_PATH}*.card*); do
   SYS_PP_OD_CLK=/sys/class/drm/${USER_STATE_FILE##*.}/device/pp_od_clk_voltage
   PWR_LEVEL=/sys/class/drm/${USER_STATE_FILE##*.}/device/power_dpm_force_performance_level
+  PWR_PROFILE=/sys/class/drm/${USER_STATE_FILE##*.}/device/pp_power_profile_mode
   SYS_DPM_SCLK=/sys/class/drm/${USER_STATE_FILE##*.}/device/pp_dpm_sclk
   SYS_DPM_MCLK=/sys/class/drm/${USER_STATE_FILE##*.}/device/pp_dpm_mclk
   HWMON_PATH=/sys/class/drm/${USER_STATE_FILE##*.}/device/hwmon
sibradzic commented 4 years ago

Hi @ittomsk This looks good, you want to submit it as PR?

ittomsk commented 4 years ago

@sibradzic yes. will be great

sibradzic commented 4 years ago

cool. BTW, I did little driver reading last night, there is a way to set custom power profile; https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c#L1230 So, something like this would work; echo "5 1 0 100 30 1 0 100 50" > /sys/class/drm/card0/device/pp_power_profile_mode I'd validate FORCE_POWER_PROFILE in a bit different manner if I was you...

ittomsk commented 4 years ago

Well, that was a quick and dirty "copy and modify" hack. So if you think there is a better way of doing it, just do it. May be you'll add custom profile as well. Than will be great too