mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Ahmed Yaseen <yaseen@ghoul.dev>
Cc: Hans de Goede <hansg@kernel.org>,
	 Corentin Chary <corentin.chary@gmail.com>,
	 "Luke D . Jones" <luke@ljones.dev>,
	Denis Benato <denis.benato@linux.dev>,
	 Nir Yehoshua <nir@ciphersecuritylabs.com>,
	 platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: asus-wmi: validate custom fan curves on enable
Date: Mon, 31 Aug 2026 18:57:59 +0300 (EEST)	[thread overview]
Message-ID: <839e9e42-6793-731c-8785-16c1c95067ae@linux.intel.com> (raw)
In-Reply-To: <20260828160743.31957-1-yaseen@ghoul.dev>

On Fri, 28 Aug 2026, Ahmed Yaseen wrote:

> Custom fan curves reach firmware unchecked, so a curve whose temperature
> or PWM decreases from one point to the next is accepted. The firmware
> does not respect such a curve: a first point of 100% followed by 50%
> leaves every point running at 100%. The kernel keeps reporting the
> points that were written, so sysfs stops describing what the fans are
> actually doing.
> 
> Reject the curve when it is enabled. Validate on enable rather than on
> write because fan curves are written one point at a time and are
> inconsistent mid-write.

You should rephrase this sentence.

-- 
 i.

> Fixes: 0f0ac158d28f ("platform/x86: asus-wmi: Add support for custom fan curves")
> Reported-by: Nir Yehoshua <nir@ciphersecuritylabs.com>
> Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
> ---
>  drivers/platform/x86/asus-wmi.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index a65090429ca7..3b743fec5c64 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -3714,6 +3714,33 @@ static int fan_curve_write(struct asus_wmi *asus,
>  					 arg1, arg2, arg3, arg4, &ret);
>  }
>  
> +/*
> + * A fan curve is a set of points the firmware interpolates between, so it
> + * only makes sense if neither temperature nor PWM ever decreases along it.
> + */
> +static int fan_curve_validate(struct device *dev, struct fan_curve_data *data)
> +{
> +	u8 *percents = data->percents;
> +	u8 *temps = data->temps;
> +	int i;
> +
> +	for (i = 1; i < FAN_CURVE_POINTS; i++) {
> +		if (temps[i] < temps[i - 1]) {
> +			dev_warn(dev, "fan curve: temperature decreases at point %d (%u < %u)\n",
> +				 i, temps[i], temps[i - 1]);
> +			return -EINVAL;
> +		}
> +
> +		if (percents[i] < percents[i - 1]) {
> +			dev_warn(dev, "fan curve: pwm decreases at point %d (%u < %u)\n",
> +				 i, percents[i], percents[i - 1]);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static ssize_t fan_curve_store(struct device *dev,
>  			       struct device_attribute *attr, const char *buf,
>  			       size_t count)
> @@ -3798,6 +3825,11 @@ static ssize_t fan_curve_enable_store(struct device *dev,
>  	}
>  
>  	if (data->enabled) {
> +		err = fan_curve_validate(dev, data);
> +		if (err) {
> +			data->enabled = false;
> +			return err;
> +		}
>  		err = fan_curve_write(asus, data);
>  		if (err)
>  			return err;
> 
> base-commit: 6b8c8af514d739d0335f5579b585e02babe8a727
> 

      reply	other threads:[~2026-08-31 15:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 16:07 Ahmed Yaseen
2026-08-31 15:57 ` Ilpo Järvinen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=839e9e42-6793-731c-8785-16c1c95067ae@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=corentin.chary@gmail.com \
    --cc=denis.benato@linux.dev \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luke@ljones.dev \
    --cc=nir@ciphersecuritylabs.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=yaseen@ghoul.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®