Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pei Xiao" <xiaopei01@kylinos.cn>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v4 1/4] hwmon: (gpd-fan): drop global driver data and use per-device allocation
Date: Wed, 10 Jun 2026 02:02:54 +0000	[thread overview]
Message-ID: <20260610020255.3EC891F00893@smtp.kernel.org> (raw)
In-Reply-To: <1cd3e13033fdd3d0f9b59322f7c86e350d113b92.1781055639.git.xiaopei01@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Software state initialization in `probe()` is not synchronized with actual hardware state.
--

commit 072171983894d237c762c5fb521a8b93d2504d1f
Author: Pei Xiao <xiaopei01@kylinos.cn>

hwmon: (gpd-fan): drop global driver data and use per-device allocation

This patch replaces the global state gpd_driver_priv with per-device private
data (struct gpd_fan_data) allocated during probe. This allows the driver to
support multiple instances in the future and aligns with kernel best practices.

> diff --git a/drivers/hwmon/gpd-fan.c b/drivers/hwmon/gpd-fan.c
> index 80de5f20781eb..7284babd4f5c9 100644
> --- a/drivers/hwmon/gpd-fan.c
> +++ b/drivers/hwmon/gpd-fan.c

[ ... ]

> @@ -624,24 +629,42 @@ static int gpd_fan_probe(struct platform_device *pdev)
>  		return dev_err_probe(dev, -EBUSY,
>  				     "Failed to request region\n");
>  
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	match = dev_get_platdata(dev);
> +	if (!match)
> +		return -EINVAL;
> +
> +	data->drvdata = match;
> +	data->pwm_enable = AUTOMATIC;
> +	data->pwm_value = 255;
> +
> +	dev_set_drvdata(dev, data);
> +

[Severity: High]
This is a pre-existing issue, but I noticed that while the software state
for pwm_enable is initialized to AUTOMATIC here in gpd_fan_probe(), there
doesn't appear to be a corresponding write to the hardware EC to actually
set this mode.

If the fan was left in manual mode by a previous driver instance, a crash,
or the BIOS, won't it remain stuck at a fixed speed while the sysfs interface
reports automatic to userspace?

Could this mismatch cause OS thermal management daemons to falsely assume
the hardware is dynamically managing the fan, potentially leading to silent
thermal throttling or shutdowns under heavy load?

>  	hwdev = devm_hwmon_device_register_with_info(dev,
>  						     DRIVER_NAME,
> -						     NULL,
> +						     data,
>  						     &gpd_fan_chip_info,
>  						     NULL);
>  	if (IS_ERR(hwdev))
>  		return dev_err_probe(dev, PTR_ERR(hwdev),
>  				     "Failed to register hwmon device\n");
>  
> -	gpd_init_ec();
> +	gpd_init_ec(data);
>  
>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1781055639.git.xiaopei01@kylinos.cn?part=1

  reply	other threads:[~2026-06-10  2:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10  1:49 [PATCH v4 0/4] some cleanup and fix in gpd-fan Pei Xiao
2026-06-10  1:49 ` [PATCH v4 1/4] hwmon: (gpd-fan): drop global driver data and use per-device allocation Pei Xiao
2026-06-10  2:02   ` sashiko-bot [this message]
2026-06-10 13:13   ` Guenter Roeck
2026-06-10  1:49 ` [PATCH v4 2/4] hwmon: (gpd-fan): Initialize EC before registering hwmon device Pei Xiao
2026-06-10  2:02   ` sashiko-bot
2026-06-10 13:13   ` Guenter Roeck
2026-06-10  1:49 ` [PATCH v4 3/4] hwmon: (gpd-fan): upgrade log level from warn to err for platform device creation failure Pei Xiao
2026-06-10  1:54   ` sashiko-bot
2026-06-10 13:14   ` Guenter Roeck
2026-06-10  1:49 ` [PATCH v4 4/4] hwmon: (gpd-fan): fix race condition between device removal and sysfs access Pei Xiao
2026-06-10  1:59   ` sashiko-bot
2026-06-10 13:15   ` Guenter Roeck

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=20260610020255.3EC891F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xiaopei01@kylinos.cn \
    /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