After suspending a machine with acpithinkpad(4) and resuming, the fan
senors report a value of 65535 (i.e. 0xffff) for a few seconds, and
then start reporting correct values.

The following diff marks the sensor as invalid when such a value is
read.

Index: acpithinkpad.c
===================================================================
RCS file: /OpenBSD/src/sys/dev/acpi/acpithinkpad.c,v
retrieving revision 1.71
diff -u -p -r1.71 acpithinkpad.c
--- acpithinkpad.c      9 Apr 2023 17:50:02 -0000       1.71
+++ acpithinkpad.c      24 Apr 2023 14:05:18 -0000
@@ -287,7 +287,12 @@ thinkpad_sensor_refresh(void *arg)
        /* Read fan RPM */
        acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANLO, 1, &lo);
        acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANHI, 1, &hi);
-       sc->sc_sens[THINKPAD_SENSOR_FANRPM].value = ((hi << 8L) + lo);
+       if (hi == 0xff && lo == 0xff) {
+               sc->sc_sens[THINKPAD_SENSOR_FANRPM].flags = SENSOR_FINVALID;
+       } else {
+               sc->sc_sens[THINKPAD_SENSOR_FANRPM].value = ((hi << 8L) + lo);
+               sc->sc_sens[THINKPAD_SENSOR_FANRPM].flags = 0;
+       }
 }
 
 void

Reply via email to