vmatare / thinkfan

The minimalist fan control program
GNU General Public License v3.0
534 stars 61 forks source link

Error after boot: /proc/acpi/ibm/fan: No such file or directory #189

Closed binarious closed 2 years ago

binarious commented 2 years ago

Steps to reproduce

Expected behavior Thinkfan service is running without errors.

Actual behavior Thinkfan fails with the following error:

systemd[1]: Starting simple and lightweight fan control program...
thinkfan[552]: ERROR: ~TpFanDriver: Resetting fan control in /proc/acpi/ibm/fan: No such file or directory
thinkfan[552]: ERROR: ~TpFanDriver: Resetting fan control in /proc/acpi/ibm/fan: No such file or directory
thinkfan[552]: ERROR: init: Initializing fan control in /proc/acpi/ibm/fan: No such file or directory
systemd[1]: thinkfan.service: Control process exited, code=exited, status=1/FAILURE

After sudo systemctl restart thinkfan.service it starts working again:

systemd[1]: Starting simple and lightweight fan control program...
thinkfan[15446]: Daemon PID: 15447
systemd[1]: Started simple and lightweight fan control program.

thinkfan.yaml

sensors:
  - hwmon: /sys/class/hwmon
    name: thinkpad
    indices: [1]

fans:
  - tpacpi: /proc/acpi/ibm/fan

levels:
  - [0, 0, 50]
  - [1, 45, 65]
  - ["level auto", 60, 85]
  - ["level disengaged", 80, 255]

Additional details

koutheir commented 2 years ago

It looks like thinkfan is started too early, before /proc/acpi/ibm/fan is available.

binarious commented 2 years ago

I guess so. Maybe the After=lm_sensors.service in the service file of the AUR is wrong/incomplete, but I'm not sure. What service does provide /proc/acpi/ibm/fan so that it should be waited for?

koutheir commented 2 years ago

/proc/acpi/ibm/fan is provided by thinkpad_acpi, which is a module, not a service.

I'm not sure what service would make sense for After=. Maybe delaying the start up of thinkfan by a few seconds would make sense in this situation?

vmatare commented 2 years ago

Hi @binarious, the latest master version supports a new config setting max_errors: NUM that will let thinkfan retry the initialization of a given fan or sensor NUM times. Alternatively, you can mark a fan/sensor with optional: true to allow retrying indefinitely. So if you want to help testing this new feature (which is slated for the 2.0 release), you can try something like this:

sensors:
  - hwmon: /sys/class/hwmon
    name: thinkpad
    indices: [1]
    max_errors: 10 # <<< New config option

fans:
  - tpacpi: /proc/acpi/ibm/fan
    max_errors: 10 # <<< New config option

levels:
  - [0, 0, 50]
  - [1, 45, 65]
  - ["level auto", 60, 85]
  - ["level disengaged", 80, 255]

If a fan or sensor is unavailable, it is retried every loop, so if your're using the default sleep time of 5 seconds, that should give you ~50 seconds of retries before thinkfan fails to start.

binarious commented 2 years ago

Hi @vmatare, confirmed fixed. Thank you!

jeandestouches commented 1 year ago

I faced the same issue with thinkfan 1.3.1 on Debian bookworm and kernel 6.1.10. /proc/acpi/ibm/fan was not available so I added a thinkfan.timer until the new thinkfan version is available.

/etc/systemd/system/thinkfan.timer

[Unit]
Description=Delaying thinkfan start

[Timer]
OnStartupSec=20
AccuracySec=5
sudo systemctl disable thinkfan.service
sudo systemctl add-wants multi-user.target thinkfan.timer
sudo systemctl daemon-reload

Now it is starting correctly.