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

fake RPM?! (4 small issues) #59

Closed RayOfLight1 closed 5 years ago

RayOfLight1 commented 6 years ago

Thank you for this project, I've gained control of both fans thanks to it, but when I check its fan speed, it is completely made up (I've read in your source code that you are kind of aware of this situation), I can set pwm2 to 100 and it reports some speed (about 2277 rpm), but in truth, my fan is not even spinning (not perfect bearings, eh?), such a let down (I'll replace it when I can).

Also, your max reported speed is 3910RPM, but with automatic mode, I have seen values higher than 6000 rpm!, damn

Then I discovered "calc_fan_relation.py": [ISSUE 1]

sudo ./calc_fan_relation.py 2 /sys/class/hwmon/hwmon5
-----------------------------------collecting fan info:
Traceback (most recent call last):
  File "./calc_fan_relation.py", line 88, in <module>
    rpms = get_rpm(vals[0][1], vals[1][1])
  File "./calc_fan_relation.py", line 71, in get_rpm
    ( (0x0041CDB4 / (fan2*2)) if fan2 is not None else 0) )
ZeroDivisionError: integer division or modulo by zero

It appears that you have not considered cases in where fan speed can be really zero.

Also, check hwmon5 !!, every time I reload the module (enabling and disabling debug, for example, it creates a new hwmon instance, making its settings unusable for fancontrol, forcing me to reboot the laptop. [ISSUE 2]

When I boot and my laptop is cold and I autoload asus_fan, all fan detection routines fail:

[    4.811292] asus-fan (init) - dmi product: 'UX32VD'
[    4.811618] asus-fan (init) - fan-id: 1 | failed to get rpm
[    4.811910] asus-fan (init) - fan-id: 2 | failed to get rpm
[    4.811910] asus-fan (init) - temp-id: 1 | success getting temp
[    4.825780] asus-fan (init) - created hwmon device: hwmon3
[    4.825782] asus-fan (init) - finished init, found 1 fan(s) to control

In this situation, I can't unload the module, wait for it to warm up and then load it again, because it will not reuse the same hwmon interface, making fancontrol useless. I must warm it up, then reboot, this is crazy [ISSUE 3]

Also, I get 7 warnings when compiling it, one: warning: ignoring return value of ‘sysfs_create_group’, declared with attribute warn_unused_result [-Wunused-result]

and 6 on: warning: ignoring return value of ‘kstrtouint’, declared with attribute warn_unused_result [-Wunused-result]

just saying that you are 7 lines away from a warning-less perfect code :) [ISSUE 4]

My main motivation for typing this out, though, is if there is any possibility of finding the real fan speed (my laptop is an UX32VD btw) [ISSUE 5]

Thank you again!

daringer commented 6 years ago

Hmm, ok I have (had) perfectly the same Zenbook model, so yes as what I could find out there is no proper way to calculate the fan speed so that it will be really true. OK but let's go through one after another:

(1) jup, totally, haven't thought that anyone will ever use this, had still no really useful values based on it (WONTFIX) :smile:

(2) yes this is known, at least on my side, looks like the module is not unloading correctly, or did you force unload? here also, likely not painful enough to invest time solving it :disappointed:

(3) uh, but this is a good point, this very much looks like a bug during the detection routines, likely a zero is not understood as "no rpm" but instead as an error. Like the opposite of what happens at (2)---still I have created #60 should be an easy bug to fix. In the meantime you might want to simple force load the module during boot-up, the probing or detection will then be skipped and all should work as expected also on cold days.

(4) uuuh, this is something you can lure me easily with, also easy bugfixing/codecleaning. Feel free to provide a PR, would be really happy to see contributions on those things, especially as I am right now without a zenbook to test with, but this will also change sooner or later...

Finally (5): No! :grin: I've also tried a lot during the early development of this, several others like @KastB @Tharre and/or @frederickjh have also investigated on this topic what's possible, but without luck.

RayOfLight1 commented 6 years ago

(2) I have solved [ISSUE 2] thanks to "close2" from archlinux forums and linuxquestions.org

I've changed my fancontrol script from static hwmon numbering to a wildcard one, my code is as follows:

INTERVAL=5

DEVPATH=hwmon1=devices/platform/coretemp.0      hwmon3=devices/platform/asus_fan
DEVNAME=hwmon1=coretemp                                         hwmon3=asus_fan

FCTEMPS=hwmon3/pwm2=hwmon1/temp1_input          hwmon3/pwm1=hwmon1/temp1_input
FCFANS=hwmon3/pwm2=hwmon3/fan2_input            hwmon3/pwm1=hwmon3/fan2_input

MINTEMP=hwmon3/pwm2=55                                          hwmon3/pwm1=55
MAXTEMP=hwmon3/pwm2=80                                          hwmon3/pwm1=80

MINSTART=hwmon3/pwm2=60                                         hwmon3/pwm1=60
MINSTOP=hwmon3/pwm2=50                                          hwmon3/pwm1=50

to the following: (remember to drop devpath and devname)

INTERVAL=5

FCTEMPS=/sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm2=/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input           /sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm1=/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input
FCFANS=/sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm2=/sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/fan2_input            /sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm1=/sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/fan2_input

MINTEMP=/sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm2=55                                          /sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm1=55
MAXTEMP=/sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm2=80                                          /sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm1=80

MINSTART=/sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm2=60                                         /sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm1=60
MINSTOP=/sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm2=50                                          /sys/devices/platform/asus_fan/hwmon/hwmon[[:print:]]*/pwm1=50

Now I can load and unload the module and restore proper fancontrol without having to reboot (I'm at hwmon10 right now...) :)

RayOfLight1 commented 6 years ago

Also, on [ISSUE 1], I recently had some problems with this software, as there would be no links (no pwm1_enable, no pwm1, etc., only basic module links (device power subsystem uevent).

I commented out part of its code and now it is partly working, when I get more info, I'll file a new bug report, but when I was looking for the cause I disassembled and tested the fans out of the zenbook, what I can say is the following from my UX32VD:

The (new) Delta fans at ~5V DC (no pwm signal in=max speed) output a tach signal about ~204 Hz (measured with a DSO), meaning that they make about 102*60=6120 rpm when running with unobstructed airflow. When obstructed, signal may increase to about ~240 Hz, but that's pointless.

What I'm trying to say is that when reporting fake RPMs, about pwm=30 should be 0 rpm, and pwm=255 should be ~6000 rpm to make it more realistic.

daringer commented 5 years ago

mmmh, 8months, at least the repository has changed a little, means especially the init-stuff and robustness has been improved, despite I can now see an own Zenbook again on the horizon, means new things will happen (tm) ... anyways, closing this issue, feel free to re-open or re-new depending on the issues