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

asus-fan has started to fail on my UX32VD #63

Closed RayOfLight1 closed 5 years ago

RayOfLight1 commented 6 years ago

I've lost fan control with this module, upon further research I've been able to restore partial functionality, here is what is going on:

% sudo insmod asus_fan.ko; dmesg | tail

asus-fan (init) - dmi sys info: 'ASUSTeK COMPUTER INC.'
asus-fan (init) - dmi product: 'UX32VD'
asus-fan (init) - fan-id: 1 | failed to get rpm
asus-fan (init) - fan-id: 2 | success getting rpm
asus-fan (init) - temp-id: 1 | success getting temp
asus-fan (init) - created hwmon device: hwmon12
asus-fan (init) - finished init, found 2 fan(s) to control

% ls /sys/class/hwmon/hwmon12 device name power subsystem uevent

:(

% sudo rmmod asus-fan

I then haphazardly modified asus-fan.c just out of desesperation, such as:

diff -c3  asus_fan.modified.c asus_fan.c
*** asus_fan.modified.c
--- asus_fan.c
***************
*** 918,929 ****
                size_t temp = AE_OK;
      // USE this for idx in hwmon_attrs size_t idx = 0;
      // try to get RPM for first fan
! //    rpm = __fan_rpm(0);
!     //if (rpm == -1) {
!     //  asus_data.has_fan = false;
!     //  err_msg("init", "fan-id: 1 | failed to get rpm");
!     //} else
! {
        asus_data.has_fan = true;
        info_msg("init", "fan-id: 1 | success getting rpm");
        hwmon_attrs[0] = &dev_attr_pwm1.attr;
--- 918,928 ----
                size_t temp = AE_OK;
      // USE this for idx in hwmon_attrs size_t idx = 0;
      // try to get RPM for first fan
!     rpm = __fan_rpm(0);
!     if (rpm == -1) {
!       asus_data.has_fan = false;
!       err_msg("init", "fan-id: 1 | failed to get rpm");
!     } else {
        asus_data.has_fan = true;
        info_msg("init", "fan-id: 1 | success getting rpm");
        hwmon_attrs[0] = &dev_attr_pwm1.attr;
***************
*** 935,945 ****
        hwmon_attrs[15] = &dev_attr_fan1_speed.attr;
      }
      // try to get RPM for second fan
!  /*   rpm = __fan_rpm(1);
      if (rpm == -1) {
        err_msg("init", "fan-id: 2 | failed to get rpm");
        asus_data.has_gfx_fan = false;
!     } else */{
        info_msg("init", "fan-id: 2 | success getting rpm");
        asus_data.has_gfx_fan = true;
        hwmon_attrs[6] = &dev_attr_pwm2.attr;
--- 934,944 ----
        hwmon_attrs[15] = &dev_attr_fan1_speed.attr;
      }
      // try to get RPM for second fan
!     rpm = __fan_rpm(1);
      if (rpm == -1) {
        err_msg("init", "fan-id: 2 | failed to get rpm");
        asus_data.has_gfx_fan = false;
!     } else {
        info_msg("init", "fan-id: 2 | success getting rpm");
        asus_data.has_gfx_fan = true;
        hwmon_attrs[6] = &dev_attr_pwm2.attr;

% sudo insmod asus_fan.ko; dmesg | tail

asus-fan (init) - dmi sys info: 'ASUSTeK COMPUTER INC.'
asus-fan (init) - dmi product: 'UX32VD'
asus-fan (init) - fan-id: 1 | success getting rpm
asus-fan (init) - fan-id: 2 | success getting rpm
asus-fan (init) - temp-id: 1 | success getting temp
asus-fan (init) - created hwmon device: hwmon13
asus-fan (init) - finished init, found 2 fan(s) to control

% ls /sys/class/hwmon/hwmon13

device      fan1_label  fan1_min   fan1_speed  fan2_label  fan2_min   fan2_speed  power  pwm1_enable  pwm2_enable  temp1_crit   temp1_label
fan1_input  fan1_max    fan1_mode  fan2_input  fan2_max    fan2_mode  name        pwm1   pwm2         subsystem    temp1_input  uevent

What have I done? No idea! I guess that dropping some "checks" allowed the loading to sucessfully go through!

Now why

cat /sys/class/hwmon/hwmon13/temp1_input | hexdump -C
00000000  00 00 00                                          |...|
00000003

echo '\_SB.PCI0.LPCB.EC0.TH1R' > /proc/acpi/call && cat /proc/acpi/call; echo -e "\n"
0x2ealled

why temp1_input returns nothing?, the nvidia card is enabled!!

optirun nvidia-smi -q -d temperature

==============NVSMI LOG==============

Timestamp                           : Mon Aug 13 15:44:22 2018
Driver Version                      : 390.77

Attached GPUs                       : 1
GPU 00000000:01:00.0
    Temperature
        GPU Current Temp            : 46 C
        GPU Shutdown Temp           : N/A
        GPU Slowdown Temp           : N/A
        GPU Max Operating Temp      : N/A
        Memory Current Temp         : N/A
        Memory Max Operating Temp   : N/A

0x2e = 46 ºC !!!

This "null" return of temp1_input makes psutil (and s-tui) fail, but @giampaolo has already commited a fix to "tolerate" this behaviour

daringer commented 5 years ago

seems fixed?! pls re-open if not...