Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Allow setting fan speed by writing to sysfs #9

Open
MilesBHuff opened this issue Apr 10, 2021 · 9 comments
Open

[Feature Request] Allow setting fan speed by writing to sysfs #9

MilesBHuff opened this issue Apr 10, 2021 · 9 comments

Comments

@MilesBHuff
Copy link

MilesBHuff commented Apr 10, 2021

Distribution (run cat /etc/os-release):

NAME="Manjaro Linux"
ID=manjaro
ID_LIKE=arch
BUILD_ID=rolling
PRETTY_NAME="Manjaro Linux"
ANSI_COLOR="32;1;24;144;200"
HOME_URL="https://manjaro.org/"
DOCUMENTATION_URL="https://wiki.manjaro.org/"
SUPPORT_URL="https://manjaro.org/"
BUG_REPORT_URL="https://bugs.manjaro.org/"
LOGO=manjarolinux

Related Application and/or Package Version (run apt policy $PACKAGE NAME):
system76-acpi-dkms 1.0.2+1+g0bc966c-1

Issue/Bug Description:
I am unable to set my fan speeds via the settings files exposed by system76-acpi-dkms.

Steps to reproduce (if you know):

sudo pwmconfig
# You can also try `echo`ing to the fan settings directly;  in all cases, you get "permission denied".

Expected behavior:
The fan settings exposed by system76-acpi-dkms should be changeable.

Other Notes:
This is a complaint I have seen semi-commonly on the Internet in general, and Reddit in particular. It's definitely not just me wanting this functionality.

@MilesBHuff MilesBHuff changed the title Unable to set fan speeds in oryp7 Unable to set fan speeds on oryp7 Apr 10, 2021
@jacobgkau
Copy link
Member

The fan speed is controlled by the fan curve in the firmware: https://github.com/system76/ec/blob/16778e4a41477498eaf5791cae57ae404515973e/src/board/system76/oryp7/board.mk

You can change the fan curve by changing the values in that file before you build firmware-open.

Leaving this open as a feature request, but wanted to let you know in case you weren't aware.

@jacobgkau jacobgkau changed the title Unable to set fan speeds on oryp7 [Feature Request] Allow setting fan speed by writing to sysfs Apr 12, 2021
@Raikiri
Copy link

Raikiri commented Jun 8, 2021

I definitely agree that this is a much-needed feature. I'd love if there was a good API to change those curves in runtime or at least in bios.

Hopefully if/when merged, this one should be used : system76/ec#63

@MilesBHuff
Copy link
Author

MilesBHuff commented Jun 12, 2021

@Raikiri

I'd love if there was a good API to change those curves in runtime or at least in bios.

Providing a sysfs interface for setting fan speeds would inherently allow changing the curves in runtime. (Not literally, but close-enough, since you could pretty easily use a program like fancontrol to handle that for you.)
If you want the entire curve exposed in the OS, that's a whole other matter altogether, and should be raised as a separate issue, as it is outside the scope of this request. I see you have already raised that issue here: system76/firmware-open#570.

Hopefully if/when merged, this one should be used : system76/ec#63

This issue (#9) is correct as-written, and in the correct place. Adding to sysfs is the domain of system76-acpi-dkms, not of ec. If and when any code is merged, it will be done separately for each issue. These issues may overlap, but they do not supercede each other, and each pertains to a somewhat vastly different scope.

@curiousercreative
Copy link
Contributor

@MilesBHuff so I've actually got this working for myself, it's spread across three repos, so not the easiest thing to pull and run for yourself. Unfortunately, after sinking my time into this I have to say that what pwmcontrol and fancontrol gave me were far less smooth fan speed transitions. So now I'm genuinely curious how folks are using these for themselves. What are the use cases and how do you manage it? I didn't try any GUI apps, though I think that's probably desirable. Until a couple years ago when I migrated to Pop! I had great experiences on macOS with iStat Menus (primarily with my 2009-2010 Mac Pro towers). It did a terrific job of allowing multiple profiles that you could have triggered by specific temperature sensor values and it always did a great job of smoothly transitioning. With pwmcontrol and fancontrol I only found an AVERAGE configuration setting and no sub second interval option. Contrast this with our EC fans that are on a <100ms interval with discrete averaging for declining fan speeds vs rising speeds.

@curiousercreative
Copy link
Contributor

curiousercreative commented Oct 18, 2022

@MilesBHuff No promises, but I think this will get your machine in a similar state as mine to verify the sysfs pwm interface

  1. Fetch, build and install system76-acpi-dkms (check for errors in last step)
    git clone [email protected]:pop-os/system76-acpi-dkms.git
    cd system76-acpi-dkms
    
    git remote add curiouser [email protected]:curiousercreative/system76-acpi-dkms.git
    git fetch curiouser
    git checkout curiouser/master
    
    sudo dpkg-buildpackage  -b -uc -us
    sudo dpkg -i ../system76-acpi-dkms_1.0.2_amd64.deb
  2. Get firmware codebase in the right state, omit the clone if you already have it
    git clone [email protected]:system76/firmware-open.git
    cd firmware-open
    
    git remote add curiouser [email protected]:curiousercreative/firmware-open.git
    git fetch curiouser acpi-fans
    git checkout curiouser/acpi-fans
    
    ./scripts/update.sh
  3. If you have previously flashed your EC with mods that you want to preserve (fan curve, etc) then you'll want to merge one of these two branches into your personal EC branch: EC smooths ACPI pwm values or EC doesn't smooth ACPI pwm values (good for pwmconfig detection, but your own your own for smoothing)
  4. Build and flash firmware (including EC)
    ./scripts/build.sh YOUR_MODEL_HERE
    ./scripts/flash.sh YOUR_MODEL_HERE
  5. After the computer shuts down, wait a few moments and boot back up. Log in and open a terminal. You need to determine which hwmon directory is "system76_acpi". Do the below until you determine it, let's say it's "hwmon3".
    sudo su
    cat /sys/class/hwmon/hwmon3/name # system76_acpi
    
    cat /sys/class/hwmon/hwmon3/pwm1 # 0
    echo 255 > /sys/class/hwmon/hwmon3/pwm1
    cat /sys/class/hwmon/hwmon3/pwm1 # 255

If you can't find "system76_acpi" hwmon, then we need to debug step 1. If you get a permission denied error when writing to pwm sysfs, then the install in step 1 probably failed. If you can write, but the value remains 0 in read back and the fans don't respond, then our firmware is to blame and requires debugging.

@MilesBHuff
Copy link
Author

MilesBHuff commented Oct 18, 2022

@curiousercreative Wow, thanks! I will plan to give that a try. I doubt I'll have time to look at it before this weekend, though.

@curiousercreative
Copy link
Contributor

curiousercreative commented Oct 27, 2022

@MilesBHuff have you previously used pwmconfig and fancontrol with satisfactory results? Is that what you were hoping to do with your Oryx? My first go while testing this feature was meh. I might tinker with thinkfan at some point, have you used that much? Ultimately, I think the system76-power package is probably the place to build support for custom fan curves defined/loaded at runtime and perhaps integrated into the power profiles so we can allow more aggressive fan curves in performance profiles and less aggressive in batter saving mode.

@curiousercreative
Copy link
Contributor

I found that system76-power is what manages fans for the Thelios, so why not extend that to the laptops. I started work towards this end here. I think it's an interesting direction because it opens up the possibility of our fan controller to react to power profile changes (performance vs balanced vs battery mode). With this mechanism, we'd be able to have profile specific fan curve defaults that should cover three points on the spectrum of fan curve needs/desires.

@MilesBHuff
Copy link
Author

MilesBHuff commented Jun 18, 2023

Sorry for disappearing.

@MilesBHuff have you previously used pwmconfig and fancontrol with satisfactory results? Is that what you were hoping to do with your Oryx? My first go while testing this feature was meh. I might tinker with thinkfan at some point, have you used that much? Ultimately, I think the system76-power package is probably the place to build support for custom fan curves defined/loaded at runtime and perhaps integrated into the power profiles so we can allow more aggressive fan curves in performance profiles and less aggressive in batter saving mode.

I have never used them before, actually! Or any other solution that wasn't built-in to a system before. But that's interesting. I guess it's unfortunate but not wholly surprising that the userspace solutions would not work as well as the builtin ones. That said, having any solution at all that doesn't require editing, compiling, and flashing custom firmware is great, and being able to try out specific speeds would still be nice. For example, I would like to see how low I can go without clicking on my oryp7; the default minimum for avoiding clicks is 25%, but I know mine can go a little lower without issue; I just don't know how much lower, and I don't want to have to reflash (and go through the requisite crash) for every test curve.

I found that system76-power is what manages fans for the Thelios, so why not extend that to the laptops. I started work towards this end here. I think it's an interesting direction because it opens up the possibility of our fan controller to react to power profile changes (performance vs balanced vs battery mode). With this mechanism, we'd be able to have profile specific fan curve defaults that should cover three points on the spectrum of fan curve needs/desires.

Now this is really promising! Great thinking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants