vitorafsr / i8kutils

Fan control for some Dell laptops
https://launchpad.net/i8kutils
GNU General Public License v3.0
219 stars 28 forks source link

Stop using deprecated /proc/i8k interface #34

Open Wer-Wolf opened 3 years ago

Wer-Wolf commented 3 years ago

The /proc/i8k interface is marked as deprecated since a long time. Also the new sysfs interface of dell_smm_hwmon offers multiple temperature sensors, multiple fan controls and the ability to disable automatic bios fan control. Maybe i8kctl/i8kmon can be rewritten to support this interface?

I would gladly help with this.

ThomasChevalier commented 2 years ago

The default kernel build options in Arch Linux stopped to set CONFIG_I8K as of version 5.18. This means it's not possible to use the old /proc/i8k interface anymore with the default kernel shipped by the distribution.

It would be great if i8kutils supported the sysfs interface. @Wer-Wolf do you still have interest in this?

I would be glad to help too

Wer-Wolf commented 2 years ago

I am currently working on it. Some features (ac status, fn status, machine id and bios version) are not exposed thru the sysfs interface. But since those features are either unused or can be retrieved from elsewhere, i think dropping them would be ok.

Wer-Wolf commented 2 years ago

However i8kutils cannot control the fans in form of fans states over the hwmon sysfs interface. For that i8kutils needs the thermal interface of the dell_smm_hwmon driver, which is available with kernel 5.19.

shawnk0723 commented 2 years ago

The default kernel build options in Arch Linux stopped to set CONFIG_I8K as of version 5.18. This means it's not possible to use the old /proc/i8k interface anymore with the default kernel shipped by the distribution.

It would be great if i8kutils supported the sysfs interface. @Wer-Wolf do you still have interest in this?

I would be glad to help too

My fan is running like crazy all of sudden. It started this afternoon. I'm keep getting this error whenever I manually try to restart the service: "i8kmon.service - Dell laptop thermal monitoring Loaded: loaded (/usr/lib/systemd/system/i8kmon.service; enabled; vendor preset: disabled) Active: inactive (dead) Condition: start condition failed at Sun 2022-05-29 23:59:23 PDT; 16min ago └─ ConditionPathExists=/proc/i8k was not met"

I know I can manually reset it and restart after every boot but how can i keep the service enabled permanently again. if this can't be fixed soon, is there any temp workaround for this? it's driving me nuts. :(

shawnk0723 commented 2 years ago

However i8kutils cannot control the fans in form of fans states over the hwmon sysfs interface. For that i8kutils needs the thermal interface of the dell_smm_hwmon driver, which is available with kernel 5.19.

My fan is running like crazy all of sudden. It started this afternoon. I'm keep getting this error whenever I manually try to restart the service: "i8kmon.service - Dell laptop thermal monitoring Loaded: loaded (/usr/lib/systemd/system/i8kmon.service; enabled; vendor preset: disabled) Active: inactive (dead) Condition: start condition failed at Sun 2022-05-29 23:59:23 PDT; 16min ago └─ ConditionPathExists=/proc/i8k was not met"

I know I can manually reset it and restart after every boot but how can i keep the service enabled permanently again. if this can't be fixed soon, is there any temp workaround for this? it's driving me nuts. :(

Wer-Wolf commented 2 years ago

Try fancontrol from the lm-sensors package. If that does not work, revert to an older kernel.

shawnk0723 commented 2 years ago

Try fancontrol from the lm-sensors package. If that does not work, revert to an older kernel.

Not sure how good lm-sensors is but I was really happy with i8kutils. I'll rather wait until it's fixed and revert to older kernel for now. Thank you.

b-fg commented 2 years ago

Hi, is there a plan to fix this any time soon or will it be something to be done in the long term? Thanks for this great package anyhow :)

Wer-Wolf commented 2 years ago

I am currently working on it, but i got little time. Also fan control without /proc/i8k will only be possible with kernel 5.19 and beyond.

b-fg commented 2 years ago

Noted, thank you very much!

Wer-Wolf commented 2 years ago

I got a prototype ready here. Maybe someone can test it?

Subbeh commented 2 years ago

@Wer-Wolf I installed the prototype and it seems to work at first glance, but the fan starts and stops every second. I might have to tweak the thresholds a bit, but I also noticed that having less than 5 threshold configs in the i8kmon.conf file causes additional (unwanted) thresholds to be added.

~ ≻ i8kmon -v
i8kmon
config(0)           = {0 0} -1 50 -1 50
config(1)           = {0 1} 45 55 45 55
config(2)           = {1 1} 50 65 50 65
config(3)           = {1 2} 60 70 60 70
config(4)           = {2 2} 65 128 65 128
config(acpi)        = acpi
config(num_configs) = 5
config(sysconfig)   = /etc/i8kmon.conf
config(timeout)     = 2
config(verbose)     = 1
status(ac)         = 0
status(acpi_timer) = 0
status(leftspeed)  = 0 2500 5000 5000
status(lspeed)     = 0
status(lstate)     = -2
status(lstuck)     = 0
status(nfans)      = 2
status(rightspeed) = 0 2500 5000 5000
status(rspeed)     = 0
status(rstate)     = -2
status(rstuck)     = 0
status(state)      = 0
status(t_high)     = 0
status(t_low)      = 0
status(temp)       = 0
1654819646 acpi: Battery 0: Full, 100%
Battery 1: Discharging, 0%, rate information unavailable
temp, left fan state, right fan state, ac state: 49 0 1 0
i8kfan - 0
temp, left fan state, right fan state, ac state: 49 0 0 0
temp, left fan state, right fan state, ac state: 49 0 1 0
i8kfan - 0
temp, left fan state, right fan state, ac state: 49 0 0 0
temp, left fan state, right fan state, ac state: 49 0 1 0
i8kfan - 0
temp, left fan state, right fan state, ac state: 49 0 0 0
temp, left fan state, right fan state, ac state: 49 0 1 0
i8kfan - 0
...
Wer-Wolf commented 2 years ago

Did you set config(num_configs)?

Wer-Wolf commented 2 years ago

I found the reason for this behaviour. Please pull the changes and try again with the testing branch.

Subbeh commented 2 years ago

Thanks, but I can't see any changes in your repo? Also didn't see the num_configs param before, will change that.

Wer-Wolf commented 2 years ago

Try the testing branch, i edited the first commit.

Wer-Wolf commented 2 years ago

I would love to introduce a more stable config format, but thats the only thing which needs to be backwards-compatible.

Subbeh commented 2 years ago

Thanks for the quick turnaround. I got the testing branch version, but the problem still remains.

i8kmon output:

≻ i8kmon -v                                                                                                                                                                                                                                                                         
i8kmon
config(0)           = {0 0} -1 70 -1 70
config(1)           = {1 1} 65 80 65 80
config(2)           = {2 2} 75 128 75 128
config(3)           = {2 1}  65  85  70  90
config(4)           = {2 2}  70 128  75 128
config(num_configs) = 3
...
temp, left fan state, right fan state, ac state: 51 0 1 0
i8kfan - 0
temp, left fan state, right fan state, ac state: 51 0 1 0
i8kfan - 0

Tried with both the original config and the custom thresholds above, but the fans keep restarting every second and the num_configs param doesn't seem to have effect.

Wer-Wolf commented 2 years ago

Nevermind, i made a mistake. Please pull again.

Subbeh commented 2 years ago

No luck yet

Wer-Wolf commented 2 years ago

Strange, i tested i8kmon on my notebook, and it worked. What happens if you set the fan speed with i8kctl: sudo i8kctl -s fan -n 1 <state>

Wer-Wolf commented 2 years ago

And could you show me the contents of your /etc/i8kmon.conf?

andrei-korshikov commented 2 years ago

@Wer-Wolf Armin, thank you very much, indeed. I've installed your version 1.44, and it works:) Kernel 5.19.12-zen1-1-zen, laptop Dell Inspiron 13 5378 just in case.

andrei-korshikov commented 2 years ago

fan starts and stops every second

@Subbeh I've seen this behavior when dell-bios-fan-control.service is stopped, so i8kmon stops (or spins down) the fan, then BIOS almost immediately restarts (spins up) it, and so on indefinitely. In such case I would recommend to create /etc/systemd/system/i8kmon@.service.d/override.conf file (notice @ sing, it's important for Wer-Wolf's variant of systemd service):

[Unit]
BindsTo=dell-bios-fan-control.service
After=dell-bios-fan-control.service
TobiasReich commented 1 year ago

Sorry for highjacking this thread. I get the error message

can't open /proc/i8k: No such file or directory
    while executing
"exec $config(i8kfan) $left $right"
    (procedure "set_fan" line 29)
    invoked from within
"set_fan $status(state)"
    (procedure "main" line 8)
    invoked from within
"main"
    invoked from within
"if {$tcl_interactive == 0} {
    main
    vwait forever
}"
    (file "/usr/bin/i8kmon" line 373)

and noticed some where talking about i8k being deprecated. So what would be the "new" way of using it. I suspect, my system does not support this any more.

(Arch Linux (MANJARO), Kernel 6.1)

Wer-Wolf commented 1 year ago

Is the kernel module dell-smm-hwmon loaded? If yes, then you might need to use this patched version on newer kernels.

mohsin-786 commented 1 year ago

When running i8kmon: can't find package i8k::thermal while executing "package require i8k::thermal" (file "/usr/bin/i8kmon" line 27)

Can u help?

Wer-Wolf commented 1 year ago

Which distro are you using?

mohsin-786 commented 1 year ago

Which distro are you using?

Arch linux

Wer-Wolf commented 1 year ago

Can you show me the output of meson install?

Wer-Wolf commented 1 year ago

And the output of tcl::tm::path list (executed inside tclsh)?

mohsin-786 commented 1 year ago

tcl::tm::path list

/usr/lib/tcl8/site-tcl /usr/lib/tcl8/8.0 /usr/lib/tcl8/8.1 /usr/lib/tcl8/8.2 /usr/lib/tcl8/8.3 /usr/lib/tcl8/8.4 /usr/lib/tcl8/8.5 /usr/lib/tcl8/8.6

mohsin-786 commented 1 year ago

Can you show me the output of meson install?

ropping privileges to 'sin' before running ninja... ninja: Entering directory/home/sin/i8kutils/build' ninja: no work to do. Installing subdir /home/sin/i8kutils/modules/i8k to /usr/share/tcltk/tcl8/8.6/i8k Installing /home/sin/i8kutils/modules/i8k/hwmon-1.0.tm to /usr/share/tcltk/tcl8/8.6/i8k Installing /home/sin/i8kutils/modules/i8k/thermal-1.0.tm to /usr/share/tcltk/tcl8/8.6/i8k Installing /home/sin/i8kutils/man/i8kctl.1 to /usr/share/man/man1 Installing /home/sin/i8kutils/man/i8kmon.1 to /usr/share/man/man1 Installing /home/sin/i8kutils/scripts/i8kctl to /usr/bin Installing /home/sin/i8kutils/scripts/i8kmon to /usr/bin Installing /home/sin/i8kutils/etc/i8kmon.conf to /etc Installing /home/sin/i8kutils/etc/i8kmon.service to /usr/lib/systemd/system Installing /home/sin/i8kutils/etc/50-i8kmon.rules to /usr/lib/udev/rules.d Installing /home/sin/i8kutils/etc/i8kmon to /etc/init.d`

Wer-Wolf commented 1 year ago

You have to change the moduledir option to /usr/lib/tcl8/8.6 when building i8kutils.

mohsin-786 commented 1 year ago

You have to change the moduledir option to /usr/lib/tcl8/8.6 when building i8kutils.

Can u help me how to do that? I mean how to change fan speeds with i8kctl

Wer-Wolf commented 1 year ago

After having executed meson build, execute meson configure -Dmoduledir=/usr/lib/tcl8/8.6 inside the build directory.

Wer-Wolf commented 1 year ago

For changing the fan speed, use sudo i8kctl fan<fan number> <fan state> (you have to install i8kutils first). Usually fan states 0, 1 and 2 are supported.

Wer-Wolf commented 1 year ago

To view all sensors inside your system, execute i8kctl.

mohsin-786 commented 1 year ago

To view all sensors inside your system, execute i8kctl.

cool thanks mate

mohsin-786 commented 1 year ago

Dependency failed for dell notebook fan control. Any idea how to fix it

Wer-Wolf commented 1 year ago

Which version are you using?

mohsin-786 commented 1 year ago

i8kmon.service dependency error

Wer-Wolf commented 1 year ago

Can you share the full error message and/or system log?

Wer-Wolf commented 1 year ago

And which version of i8kutils are you using?

uriesk commented 1 year ago

@Wer-Wolf thank you a lot for your work. Fedora now disabled /proc/i8k too, so i switched to your fork in my copr build.

I got one question: I use dell-bios-fan-control to disable automatic bios fan control. You said that dell_smm_hwmon can do that now. Are you doing that in your fork? So can i remove dell-bios-fan-control?

Wer-Wolf commented 1 year ago

Well, dell-smm-hwmon is able to enable/disable BIOS fan control, it however does only allow this on whitelisted models, as many models have issues when the SMM command to disable BIOS fan control is issued (suspend issues, keyboard issues, ...).

So dell-bios-fan-control is still necessary (for now).

Wer-Wolf commented 1 year ago

Also i8kmon does currently not support the hwmon attribute pwm1_enable used to switch to manual mode, since it is only present on very few machines. I am planning to add support for per-fan automatic mode control to the kernel driver sometime, this would solve most problems with the current implementation. This implementation would be compliant with the hwmon sysfs interface, so people could even use vanilla fancontrol to control the fans.

uriesk commented 1 year ago

got it, thank you again

tova-cup commented 3 months ago

Hi @Wer-Wolf ,

Any updates on the i8kmon evolution referenced here ?

Also i8kmon does currently not support the hwmon attribute pwm1_enable used to switch to manual mode, since it is only present on very few machines. I am planning to add support for per-fan automatic mode control to the kernel driver sometime, this would solve most problems with the current implementation. This implementation would be compliant with the hwmon sysfs interface, so people could even use vanilla fancontrol to control the fans.

Is there a way to contribute ?

Wer-Wolf commented 3 months ago

I added support for this attribute to my fork of i8kutils, it should work out-of-the-box when using the bundled systemd unit file.