项目作者: nmtitov

项目描述 :
Disable PWM for AMD card0 device
高级语言: Shell
项目地址: git://github.com/nmtitov/redfan.git
创建时间: 2021-01-02T17:03:35Z
项目社区:https://github.com/nmtitov/redfan

开源协议:The Unlicense

下载


Installation instructions

  1. Download zip archive of the main branch

    1. wget -c https://github.com/nmtitov/redfan/archive/main.zip -O redfan-main.zip && sudo apt install unzip -y && unzip redfan-main.zip && cd redfan-main
  2. Copy script to /usr/bin/

    1. cp redfan /usr/bin/
  3. Copy systemd service definition

    1. cp redfan.service /etc/systemd/system/
  4. Run script

    1. sudo systemctl start redfan
  5. Enable autostart of the script

    1. sudo systemctl enable redfan
  6. Check if everything is ok

    1. sudo systemctl status redfan

Description

I’m trying to lock RPM of my AMD Radeon videocard fans at the full speed:

  1. echo 1 > /sys/class/hwmon/hwmon1/pwm1_enable
  2. echo 255 > /sys/class/hwmon/hwmon1/pwm1

What I have tried so far

Obviously, it doesn’t work due to missing permissions (even with sudo/root) because it is /sys:

  1. $ sudo su
  2. $ echo 255 > /sys/class/drm/card1/device/hwmon/hwmon1/pwm1
  3. bash: echo: write error: Invalid argument

I have also tried sysfs config to edit these params but it didn’t work:

  1. $ cat /etc/sysfs.conf
  2. class/drm/card1/device/hwmon/hwmon1/pwm1 = 255
  3. class/drm/card1/device/hwmon/hwmon1/pwm1_enable = 1

echo 5 | sudo tee ... also doesn’t work.

Neither does sudo sh -c:

  1. sudo sh -c 'echo 225 > /sys/class/drm/card1/device/hwmon/hwmon1/pwm1'
  2. sh: 1: echo: echo: I/O error

Archilinux Wiki states it should be possible though https://wiki.archlinux.org/index.php/fan_speed_control#Configuration_of_manual_control They edit values directly with echo and looks like it works for them.

Another guide also recommends configuring fans this way https://linuxconfig.org/overclock-your-radeon-gpu-with-amdgpu

Python amdgpu-fan package also doesn’t work for me.

sudo fancontrol doesn’t work as well:

  1. $ sudo fancontrol
  2. Loading configuration from /etc/fancontrol ...
  3. Common settings:
  4. INTERVAL=10
  5. Settings for hwmon1/pwm1:
  6. Depends on hwmon1/temp1_input
  7. Controls
  8. MINTEMP=10
  9. MAXTEMP=60
  10. MINSTART=50
  11. MINSTOP=0
  12. MINPWM=0
  13. MAXPWM=255
  14. AVERAGE=1
  15. Enabling PWM on fans...
  16. Starting automatic fan control...
  17. /usr/sbin/fancontrol: line 649: echo: write error: Invalid argument
  18. Error writing PWM value to /sys/class/hwmon/hwmon1/pwm1
  19. Aborting, restoring fans...
  20. Verify fans have returned to full speed

Daemon (service) also doesn’t work:

  1. fancontrol[1877]: MAXPWM=255
  2. fancontrol[1877]: AVERAGE=1
  3. fancontrol[1877]: Enabling PWM on fans...
  4. fancontrol[1877]: Starting automatic fan control...
  5. fancontrol[1877]: /usr/sbin/fancontrol: line 649: echo: write error: Invalid argument
  6. fancontrol[1877]: Error writing PWM value to /sys/class/hwmon/hwmon1/pwm1
  7. fancontrol[1877]: Aborting, restoring fans...
  8. fancontrol[1877]: Verify fans have returned to full speed
  9. systemd[1]: fancontrol.service: Main process exited, code=exited, status=1/FAILURE
  10. systemd[1]: fancontrol.service: Failed with result 'exit-code'.

To sum up: seems that I can’t edit /sys/ amdgpu-related entries at all

Part 2

It seems that there has to be another way around, like some amdgpu config or something like that. Maybe override kernel-defined values during boot?

In Windows, it’s possible to tune fans directly from the AMD Radeon driver GUI app.

I don’t want fancy curves, I’m simply trying to force lock static RPM (full-on mode). I’m using amdgpu-pro drivers, Ubuntu 20.04. I’d like to avoid using scripts like fancontrol

The question itself

I wonder if that’s possible just to set pwm1_enable to 1 and pwm1 to 255? Looks like the suggested method should be working, but Ubuntu 20.04 security limitations are more restrictive than other distros’ ones.

update
This thing works! But only for 1-2 seconds, after that, fans go back to system-defined speed https://github.com/DominiLux/amdgpu-pro-fans/blob/master/amdgpu-pro-fans.sh

update 2

Disabling pwm works for about 1-2 seconds.
echo 0 > /sys/class/hwmon/hwmon1/pwm1_enable

But after that, some daemon reverts this value back to 2. How could I prevent it from changing by other users except me? E.g. prevent it from changing by the system?

https://unix.stackexchange.com/questions/627182/how-to-lock-fan-speed-for-amd-gpu-in-ubuntu-20-04