I am not familiar with all the fan hack specifics so please keep that in mind
if my questions and comments seem trivial.
> This is an attempt to solve the problem slightly differently.
> - Hook into acpitz and only speed the fan up when it is requesting active
> cooling
> - Never set the fan to a mode that would endanger the hardware should we
> crash
Your diff applies to all Thinkpad models. Is that okay?
>
> PS: It would be nice if there was a function to add cooling methods to
> acpitz eg: acpitz_add(void (*fn)(struct acpitz_softc *, void *), void *arg)
> I tried but getting struct acpitz_softc into a header is a bit messy.
If needed you can move the softc in the acpivar.h header file.
Nothing messy about it. What other model drivers would need this though?
thinkpad_hotkey, sc, ACPIDEV_POLL);
> +
> + /* Make sure fan is in auto mode, otherwise we're not sure of support */
> + acpiec_read(acpi_softc->sc_ec, THINKPAD_ECOFFSET_FANLEVEL, 1, &level);
> + if (level == THINKPAD_ECFANLEVEL_AUTO)
> + acpitz_activecool = thinkpad_activecool;
Why is there no support if the fan is not in auto mode?
> + else if (tmp > psv-50)
> + /* EC firmware fan control is too slow in some models. When
> + * we're getting within 5C of active cooling mode, turn the
> + * fan to MAX. Helps with oscillation between blast and auto */
This comment does not follow KNF :-)
> + nlevel = THINKPAD_ECFANLEVEL_MAX;
> + else
> + nlevel = THINKPAD_ECFANLEVEL_AUTO;
> +
> + if (nlevel != level) {
> + acpiec_write(acpi_softc->sc_ec, THINKPAD_ECOFFSET_FANLEVEL, 1,
> + &nlevel);
> + level = nlevel;
> + }
> }
> Index: acpitz.c
> ===================================================================
> RCS file: /home/vcs/cvs/openbsd/src/sys/dev/acpi/acpitz.c,v
> retrieving revision 1.49
> diff -u -p -r1.49 acpitz.c
> --- acpitz.c 6 May 2015 01:41:55 -0000 1.49
> +++ acpitz.c 14 Jul 2015 23:52:14 -0000
> @@ -86,6 +86,7 @@ int acpitz_setfan(struct acpitz_softc *,
> void acpitz_init(struct acpitz_softc *, int);
>
> void (*acpitz_cpu_setperf)(int);
> +void (*acpitz_activecool)(int, int) = NULL;
> int acpitz_perflevel = -1;
> extern void (*cpu_setperf)(int);
> extern int perflevel;
> @@ -427,6 +428,11 @@ acpitz_refresh(void *arg)
> acpitz_setfan(sc, i, "_OFF");
> }
> }
> +
> + /* active cooling hook */
> + if (acpitz_activecool)
> + acpitz_activecool(sc->sc_tmp, sc->sc_psv);
> +
I'm not sure, but is it ever possible for acpitz to attach BEFORE
acpithinkpad and render this check false?
Would you need to somehow tie the two together?