sibradzic / amdgpu-clocks

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

Failed to restore when power cap is not available #54

Closed Cycatz closed 11 months ago

Cycatz commented 1 year ago

/sys/class/drm/card0/device/hwmon/hwmon5/power1_cap doesn't not exist on my system, and it showed the error when running amdgpu-clocks restore:

Restoring all states to the initial defaults from /tmp/amdgpu-custom-states.card0.initial
Detecting the state values at /sys/class/drm/card0/device/pp_od_clk_voltage:
  SCLK state 0: 1000Mhz
  SCLK state 1: 1000Mhz
  Maximum clocks & voltages:
    SCLK clock 2200Mhz
cat: /sys/class/drm/card0/device/hwmon/hwmon5/power1_cap: No such file or directory
  Curent power cap: W
Verifying user state values at /tmp/amdgpu-custom-states.card0.initial:
  SCLK state 0: 200Mhz
  SCLK state 1: 2200Mhz
  Maximum clocks & voltages:
    SCLK clock 2200Mhz
  Force performance level to auto
  Unexpected value in /tmp/amdgpu-custom-states.card0.initial:7

And the file it tried to restore:

$ cat /tmp/amdgpu-custom-states.card0.initial
OD_SCLK:
0:        200Mhz
1:       2200Mhz
OD_RANGE:
SCLK:     200Mhz       2200Mhz
FORCE_PERF_LEVEL: auto
FORCE_POWER_CAP: 

My current workaround is to check if the value is empty before setting:

@@ -105,10 +105,12 @@
         echo "  Force MCLK state to ${LINE#* }"
         FORCE_MCLK=${LINE#* }
         ;;
-      "FORCE_POWER_CAP: "[0-9]*)
+      "FORCE_POWER_CAP: "*)
         MICROWATTS=${LINE#* }
-        echo "  Force power cap to ${MICROWATTS%*000000}W"
-        FORCE_POWER_CAP=${LINE#* }
+       if [ ! -z "$MICROWATTS" ]; then
+         echo "  Force power cap to ${MICROWATTS%*000000}W"
+         FORCE_POWER_CAP=${LINE#* }
+       fi
         ;;
       "FORCE_PERF_LEVEL: "[a-z]*)
         echo "  Force performance level to ${LINE#* }"
sibradzic commented 1 year ago

hi @Cycatz , thanks for reporting.

cat: /sys/class/drm/card0/device/hwmon/hwmon5/power1_cap: No such file or directory

That is very strange indeed, the power1_cap normally does exist. Let's check some things:

sibradzic commented 1 year ago

@Cycatz ping?