Re: [PATCH v12] hwmon: (yogafan) Add support for Lenovo Yoga/Legion fan monitoring

[email protected] Mon, 03 Aug 2026 19:04:50 +0000
Newsgroups org.kernel.vger.linux-hwmon
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(=
s) to consider:
- [High] The MIN_SAMPLING rate limit fails to prevent excessive ACPI querie=
s to the EC because the check occurs after the ACPI evaluation.
--

--- Patch [1]: [PATCH v12] hwmon: (yogafan) Add support for Lenovo Yoga/Leg=
ion fan monitoring ---
commit c15f7b338b1cdd81a16c2f92f8d5807ac9a0b7da
Author: Sergio Melas <[email protected]>

hwmon: (yogafan) Add support for Lenovo Yoga/Legion fan monitoring
   =20
This driver provides fan speed monitoring for modern Lenovo consumer
laptops by interfacing with the Embedded Controller (EC) via ACPI.
To address low-resolution sampling in Lenovo EC firmware, a Rate-Limited
Lag (RLLag) filter is implemented. The filter ensures a consistent physical
curve regardless of userspace polling frequency.

> diff --git a/drivers/hwmon/yogafan.c b/drivers/hwmon/yogafan.c
> index 0a41b8672b56e..371e35895f584 100644
> --- a/drivers/hwmon/yogafan.c
> +++ b/drivers/hwmon/yogafan.c

[ ... ]

> @@ -77,6 +78,18 @@ static const struct yogafan_config loq_15iax9_8bit_dua=
l_cfg =3D {
>  	.paths =3D { "\\_SB.PC00.LPCB.EC0.FA1S", "\\_SB.PC00.LPCB.EC0.FA2S" }
>  };
> =20
> +static const struct yogafan_config xiaoxin_8bit_dual_cfg =3D {
> +	.multiplier =3D 100,
> +	.fan_count =3D 2,
> +	.paths =3D { "\\_SB.PCI0.LPC0.EC0.FANS", "\\_SB.PCI0.LPC0.EC0.FA2S" }
> +};
> +
> +static const struct yogafan_config yoga_pro_7_14iah10_cfg =3D {
> +	.multiplier =3D 100,
> +	.fan_count =3D 1,
> +	.paths =3D { "\\_SB.PC00.LPCB.EC0.FANS", NULL }
> +};
> +
>  static void apply_rllag_filter(struct yoga_fan_data *data, int idx, long=
 raw_rpm)
>  {

[Severity: High]
Does the MIN_SAMPLING rate limit effectively prevent excessive ACPI queries?

Looking at yoga_fan_read(), it appears the expensive ACPI evaluation happens
unconditionally before the filter is applied:

drivers/hwmon/yogafan.c:yoga_fan_read() {
    ...
	status =3D acpi_evaluate_integer(data->active_handles[channel], NULL, NULL=
, &raw_acpi);
	if (ACPI_FAILURE(status))
		return -EIO;

	apply_rllag_filter(data, channel, (long)raw_acpi * data->multiplier);
    ...
}

Even though apply_rllag_filter() skips math updates when dt_ms < MIN_SAMPLI=
NG,
the hardware ACPI query has already been executed.

Since the sysfs fanX_input file has 0444 permissions, could an unprivileged
local user continuously read it in a tight loop and cause an EC saturation,
leading to system stalls and keyboard/mouse lag?

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260803184206.1846=
[email protected]?part=3D1