4

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

echo 1 > /sys/class/hwmon/hwmon1/pwm1_enable
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:

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

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

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

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

Neither does sudo sh -c:

sudo sh -c 'echo 225 > /sys/class/drm/card1/device/hwmon/hwmon1/pwm1'
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:

$ sudo fancontrol
Loading configuration from /etc/fancontrol ...

Common settings:
  INTERVAL=10

Settings for hwmon1/pwm1:
  Depends on hwmon1/temp1_input
  Controls 
  MINTEMP=10
  MAXTEMP=60
  MINSTART=50
  MINSTOP=0
  MINPWM=0
  MAXPWM=255
  AVERAGE=1

Enabling PWM on fans...
Starting automatic fan control...
/usr/sbin/fancontrol: line 649: echo: write error: Invalid argument
Error writing PWM value to /sys/class/hwmon/hwmon1/pwm1
Aborting, restoring fans...
Verify fans have returned to full speed

Daemon (service) also doesn't work:

fancontrol[1877]:   MAXPWM=255
fancontrol[1877]:   AVERAGE=1
fancontrol[1877]: Enabling PWM on fans...
fancontrol[1877]: Starting automatic fan control...
fancontrol[1877]: /usr/sbin/fancontrol: line 649: echo: write error: Invalid argument
fancontrol[1877]: Error writing PWM value to /sys/class/hwmon/hwmon1/pwm1
fancontrol[1877]: Aborting, restoring fans...
fancontrol[1877]: Verify fans have returned to full speed
systemd[1]: fancontrol.service: Main process exited, code=exited, status=1/FAILURE
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?

5
  • I am curious what GPU you have because I have been experiencing the exact same issue when writing to pwm1_enable (having it reset after a few seconds). I am using a XFX RX 580 and it seems to have some "zero noise" mode where if the GPU has no utilization then it turns off the fans. I think this is what conflicts because when I first give the GPU activity and then set pwm1_enable to 1 it stays, and the moment I take load off it reverts back to 2.
    – Lemon Drop
    Jan 31 at 8:05
  • @LemonDrop hey, I have Gigabyte RX 580. Please check the GitHub link from my answer to get an idea of the solution I use (works fine - edit scripts to enforce any mode you need).
    – Nik
    Jan 31 at 12:52
  • Well I'm sure it works fine but it seems kinda weird to have to set the enable thing every second like that. You shouldn't really be fighting with anything in normal operation, it's just something with the driver or bios I think like I mentioned with the card that is actually conflicting (in my case only under no load).
    – Lemon Drop
    Jan 31 at 15:30
  • @LemonDrop agree. Unfortunately, after spending a lot of time on research I gave up. Also, along the way, I have found similar problems reported by other users on the internet and nobody had a working fix AMD tech support replied to me: "Unlike windows, Within Linux OS, we only supply the drivers. If you are looking for instructions to control the GPU speeds, you may want to check with Ubuntu."
    – Nik
    Feb 1 at 11:46
  • @LemonDrop also my guess is that things got broken in Ubuntu 20 or maybe 18 (didn't test), before that people used to use PWM control successfully
    – Nik
    Feb 1 at 11:47
2

I wanted to lock fans at 80% but in a slightly different manner. I've changed nothing in /sys/class/drm/. Just

readlink -f /sys/class/drm/card1/device

, where card1 is my amd videocard.

Thus I know the path to the file I want to change.

And after that:

sudo sh -c "echo '1' > /sys/devices/pci0000:00/0000:00:03.0/0000:06:00.0/hwmon/hwmon1/pwm1_enable"
sudo sh -c "echo '200' > /sys/devices/pci0000:00/0000:00:03.0/0000:06:00.0/hwmon/hwmon1/pwm1"

Works! Ubuntu kernel 5.4

2
  • Sounds like a good option, unfortunately, I don't have an Ubuntu system anymore to test it.
    – Nik
    Aug 18 at 10:27
  • where can I find info about pwm1_enable and pwm1 and the available values options and their meaning? For example my current values in the correspondingly files are 2 and 43. I would guess that 1 for pwm1_enable is set to manual and 200 pwm1 is the fan speed? how 200 maps to 80% fan speed? Sep 4 at 15:30
1

In case anyone is interested the solution I made and the corresponding systemd service is here: redfan https://github.com/nmtitov/redfan

So far my best guess is to write the following script and keep it always running in the background:

while sleep 1; do echo 0 > /sys/class/drm/card1/device/hwmon/hwmon1/pwm1_enable; done

Every second I "disable" pwm and make fans running at max speed. The driver (or something else) restores the value, but the next second I immediately disable it again.

1

My config is

sinix@sinix-garage:~$ lspci -v | grep VGA
lspci: Unable to load libkmod resources: error -12
        Flags: bus master, VGA palette snoop, 66MHz, medium devsel, latency 64, NUMA node 0
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Hawaii XT / Grenada XT [Radeon R9 290X/390X] (prog-if 00 [VGA controller])
04:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] (rev e7) (prog-if 00 [VGA controller])
06:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Baffin [Radeon RX 550 640SP / RX 560/560X] (rev cf) (prog-if 00 [VGA controller])

I setup Hawai & Baffin to work with amdgpu-fan, and Ellesmere only work with redfan. That is not solution because I can't setup pwm on Ellesmere. So PC constantly frozen with this solution. I know that is problem on relation between amdgpu-20.45 and kernel 5.4.65.

So I decide to experiment with diferent kernels, and I find the right one.

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.180/

After install 4.19, Ellesmere boot with pwm1_enable=2 but finaly they listen "echo" to 1, and all other daemons work, like amdgpu-fan.

So "matrix" in /etc/amdgpu-fan-config.yaml work the job.

GPU0 t=66°C fan 67% power 134.09W, GPU1 t=54°C fan 56% power 104.09W, GPU2 t=51°C fan 53% power 47.23W. Total power: 285.41W

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.