daringer / asus-fan

Kernel module to get/set (both) fan speed(s) on ASUS Zenbooks
GNU General Public License v2.0
95 stars 26 forks source link

[UNSUPPORTED HARDWARE: ZenBook UX3410UA] module load fails #44

Open daringer opened 7 years ago

daringer commented 7 years ago

Hey, thanks and good tests, let's see if we can dig deeper, this is the second time I see the test_module.sh script does not recognize a non working fan control. Somehow fails on the main task it should do :disappointed:

So generally we should check the following points:

From here try the following way: 1) compile the module manually in debug-mode: see here how 2) please post what dmesg says, if you load the module using insmod asus_fan.ko from within the build dir---please post what happens with and without force-load=1. (I also added some more debug, just now, no linux box here, so it's untested, will check it later, but "looks good" :smile: ) (this will hopefully tell us what is happening under the hood) 3) next steps will then follow, once we know more, but under the line we either do some code changes to check, if this helps (based on the dmesg output we see) or should play with acpi_call using your link this at least will hopefully show which ACPI paths are existing/working, please check this comment here in the other issue, generally we only have to test:

\_SB.PCI0.LPCB.EC0.SFNV 
\_SB.PCI0.LPCB.EC0.TACH
\_SB.ATKD.QMOD
\_SB.PCI0.LPCB.EC0.ST98 
\_SB.PCI0.LPCB.EC0.SFNV 
\_SB.PCI0.LPCB.EC0.TH1R

It is very likely that if any of those is missing or so, loading the module might fail. If you find out which one this is, I could work around this in the init phase (and/or exclude it completely). Depending on which one this is, we then also have to find the replacement to get full functionality for asus_fan.

afilipovich commented 5 years ago

Thank you @dominiksalvet! I still remember the day when that annoying fan went quiet :)

klausenbusk commented 5 years ago

I found thermal tipping point table in embedded controller RAM. It is between addresses 0x537. 0x53e.

I can confirm it works on UX430UNR (54 58 62 66 72 78 88 96).

So what I did for now was adding acpi_call to /etc/modules and adding a systemd script fan_table.service to /etc/systemd/system/ that sets the lowest fan tipping point temperature:

FWIW: Using systemd-tmpfiles works perfectly:

$ cat /etc/tmpfiles.d/fan.conf
w /proc/acpi/call - - - - \\_SB.PCI0.LPCB.EC0.WRAM 0x537 0x3a # 58 degree

This is good. The bad news is that once the fan has spun up again, it never spins down completely, regardless of the CPU temperature, so I searched on.

On my laptop the fan spins up at 54° and spins down at ~40°, but if i change the first tipping point to 58° the fan spins down at ~45°. Does the controller use some kind of sliding offset for spin down? maybe?


A few test scripts, maybe they are useful for someone.

Read all tipping points (0x537-0x53e)

#!/bin/bash

# 0x537-0x53e
for i in {1335..1342}; do
    HEX="$(printf '%x\n' $i)"
    echo "\_SB.PCI0.LPCB.EC0.RRAM 0x${HEX}" > /proc/acpi/call
    VALUE="$(cat /proc/acpi/call | sed 's/\x0.*//g')"
    echo $((16#${VALUE#0x}))
done

Read all (?) EC memory

#!/bin/bash

# 0x0-0xfff
for i in {0..4095}; do
    HEX="$(printf '%x\n' $i)"
    echo "\_SB.PCI0.LPCB.EC0.RRAM 0x${HEX}" > /proc/acpi/call
    VALUE="$(cat /proc/acpi/call | sed 's/\x0.*//g')"
    echo -e "0x${HEX}\t$((16#${VALUE#0x}))"
done
klausenbusk commented 5 years ago

Not related to fan control at all, but I think some of you could find the information useful.

Most newer Zenbooks supports battery charge control (https://www.asus.com/us/support/FAQ/1032726/).

So I did some tinkering and found the relevant address (Zenbook UX430UNR, bios 308):

0x3af   100 # start charge threshold
0x3b0   95 # current battery percent

I use the following, to limit the battery to max 80%:

$ cat /etc/tmpfiles.d/battery.conf 
w /proc/acpi/call - - - - \\_SB.PCI0.LPCB.EC0.WRAM 0x3af 0x50 # 80%
klausenbusk commented 5 years ago

After much tinkering with decompiled DSDT I found ACPI calls which can replace missing ones:

Support for newer Zenbooks should be supported out-of-the-box when this patch gets merged (5.4 or maybe 5.3).

dominiksalvet commented 4 years ago

@daringer Oops, here we go again... but you already know the email address thing, don't you? Sorry for that... still could not help myself. :cry:

@klausenbusk Hey man! Do you know about asus-fan-control? It does basically the same as your script for setting temperature does but in a more sophisticated and consistent way - it sets all temperatures, performs various checks, it supports a decent amount of ASUS laptop models and much more. Thanks to @agura-lex we also have systemd integration and an AUR package for our dear Arch users. Your model name seems to be very similar to mine (UX430UA), so there is a decent chance it will work out of the box (but explicitly adding it as tested would be really great). Please, consider giving asus-fan-control a try. :smile:

@klausenbusk BTW thank you so much for the code snippets above. :heart: Some people have reported me that asus-fan-control did not work on their devices and I have been thinking a bit what to do with that. Once I had seen your snippets, I got an idea and I have created afc-scout, which you can basically use to find your base ACPI fan address by reading a given ACPI address range. Yep, you need to process it manually but it is certainly better than nothing! :rocket:

daringer commented 4 years ago

HAHA, this is pretty next level: direct-marketing at the competitor, at least you come over to visit asus-fan - but seriously: no worries, it's not like this is a competition for the highest number of hardware-specific adaptations within some piece of code :nerd_face:

Personally I believe hardware should not be controlled by bash scripts (too often) :D so it will be tough for you to get me to asus-fan-control and if your project gets better because of the discussions/investigations here, it's already win-win. Despite the fact that afc-scout will be helpful to support more models, so keep up the good work. At least until I have a zenbook again :+1: :weary: But this is already around the corner, will for sure use afc-scout^^

dominiksalvet commented 4 years ago

@daringer Glad to hear that! I have no interest to compete with asus-fan. We both develop software that does basically the same (except for two fans support) but we use different approaches.

I understand your skepticism about "bash scripts" but keep in mind that my scripts are almost without an exception POSIX shell scripts and so they run practically everywhere without any special dependencies (even on macOS and even these days). I also realize the fact that shell scripts may be very fragile and hence I really keen on mechanisms preventing those issues - AND/OR lists, no command substitution in another command's parameter, no pipes (except with echo), no non-POSIX command options, functions, which modify calling shell's environment, are strictly put into their own subshells, etc.

BTW, I really wouldn't post here if @klausenbusk had an email address on his GitHub profile. For the sake of completeness, @afilipovich really did not have an email address on his profile that time (in case you miss it)... He just reacted quickly and added it. :smile:

Hope you will be happy with a new ZenBook! :rocket:

klausenbusk commented 4 years ago

BTW, I really wouldn't post here if @klausenbusk had an email address on his GitHub profile. For the sake of completeness, @afilipovich really did not have an email address on his profile that time (in case you miss it)... He just reacted quickly and added it. smile

Finding a email address for a Github user isn't hard if they have some public activity :) foo

@klausenbusk Hey man! Do you know about asus-fan-control? It does basically the same as your script for setting temperature does but in a more sophisticated and consistent way - it sets all temperatures, performs various checks, it supports a decent amount of ASUS laptop models and much more. Thanks to @agura-lex we also have systemd integration and an AUR package for our dear Arch users.

It is hard to compete with w /proc/acpi/call - - - - \\_SB.PCI0.LPCB.EC0.WRAM 0x537 0x3a # 58 degree, I prefer to keep it simple and tmpfiles.d is just simpler. It is a cool tool though!

Your model name seems to be very similar to mine (UX430UA), so there is a decent chance it will work out of the box (but explicitly adding it as tested would be really great). Please, consider giving asus-fan-control a try. smile

The base fan control address is located at the same location (1335) so I assume it will work. BTW: I think you should move the fallback addr behind a --yes-i-know-what-im-doing flag, writing to "random" EC memory locations can be dangerous!

Out of curiosity: Are you experiencing throttling on your model? My CPU was capped at ~8w (IIRC) until I did: https://github.com/erpalma/throttled/tree/88216b119ad512d6d345e66dd304ba7b6b3e93c0#static-fix

dominiksalvet commented 4 years ago

@klausenbusk Thanks man! Didn't know about the email address. :+1: I would gladly add your model as tested but since you haven't tried it with asus-fan-control, I can't do so. :cry: But I completely understand your argument of simplicity and I respect it! :smile: Still, should you change your mind, make sure you will add your model, please.

Here is the thing with writing to "random" EC addresses... The fact that there is no such flag from the very beginning of asus-fan-control is probably the main reason why asus-fan-control is not called ux430ua-fan-control as was initially... BTW, I think that afc-scout brings at least something to the table in this matter... :smile:

I do not notice any symptoms of CPU throttling on my device. BTW, I have i5-7200U and default UX430UA asus-fan-control configuration... :rocket:


Ok, I am truly sorry @daringer for the spam and since now I know how to reach people even without public GitHub email, this is most likely my last post here. Also, feel free to remove my posts here (e.g., in a week) as their messages have been delivered and I must admit that they do not contribute to this issue very much. Nevertheless, thank you so much for the given space! :heart:

daringer commented 4 years ago

@dominiksalvet, absolutly ok, it drives things/projects forward, you have my full support :D

mirh commented 3 years ago

You should point out about asus-fan-control in the readme Also it's not the super-est clear if non-zenbook asus laptops are welcome or not. EDIT: also, I found a list of possible ECs here