Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Karthik Poosa" <karthik.poosa@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v7 01/10] drm/xe/hwmon: Initialize fan-control backend and table cache
Date: Wed, 02 Dec 2026 13:05:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-245840@kernel.org> (raw)
In-Reply-To: <20261202125637.1581881-2-karthik.poosa@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/xe/hwmon: spurious warning on DG2 in
  xe_hwmon_get_preregistration_info()
--

commit 038329fd7e943a8ca271fe720ffbfae8ffd4a54f
Author: Karthik Poosa <karthik.poosa@intel.com>

drm/xe/hwmon: Initialize fan-control backend and table cache

This commit initializes Xe hwmon fan-control support by detecting enabled
fans through a bitmask and caching firmware stock fan control points.

> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 171990602f537..af74f96ade517 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c

[ ... ]

> @@ -1082,17 +1123,112 @@ static int xe_hwmon_pcode_write_i1(const struct xe_hwmon *hwmon, u32 uval)
>  			      (uval & POWER_SETUP_I1_DATA_MASK));
>  }
>  
> -static int xe_hwmon_pcode_read_fan_control(const struct xe_hwmon *hwmon, u32 subcmd, u32 *uval)
> +static int xe_hwmon_pcode_read_fan_control(const struct xe_hwmon *hwmon, u32 subcmd, u8 fan_num,
> +					   u32 *uval)
>  {
>  	struct xe_tile *root_tile = xe_device_get_root_tile(hwmon->xe);
>  
> +	return xe_pcode_read(root_tile, PCODE_MBOX(FAN_SPEED_CONTROL, subcmd, fan_num), uval, NULL);
> +}
> +
> +static int xe_hwmon_get_fan_enable_mask(struct xe_hwmon *hwmon)
> +{
> +	int ret;
> +
>  	/* Platforms that don't return correct value */
> -	if (hwmon->xe->info.platform == XE_DG2 && subcmd == FSC_READ_NUM_FANS) {
> -		*uval = 2;
> +	if (hwmon->xe->info.platform == XE_DG2) {
> +		hwmon->fan_enable_mask = GENMASK(1, 0);
>  		return 0;
>  	}
>  
> -	return xe_pcode_read(root_tile, PCODE_MBOX(FAN_SPEED_CONTROL, subcmd, 0), uval, NULL);
> +	ret = xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_NUM_FANS, 0,
> +					      &hwmon->fan_enable_mask);
> +	if (ret) {
> +		hwmon->fan_enable_mask = 0;
> +		xe_warn(hwmon->xe, "failed to read number of fans, ret=%d\n", ret);
> +		return ret;
> +	}
> +
> +	/* Check if fan mask exceeds FAN_MAX and log a warning if it does */
> +	if (hwmon->fan_enable_mask & ~GENMASK(FAN_MAX - 1, 0)) {
> +		xe_warn(hwmon->xe, "Fan enable mask exceeds %d supported fans, clamping\n",
> +			FAN_MAX);
> +		hwmon->fan_enable_mask &= GENMASK(FAN_MAX - 1, 0);
> +	}
> +
> +	xe_info(hwmon->xe, "Number of fans detected: %u\n", hweight32(hwmon->fan_enable_mask));
> +
> +	return 0;
> +}
> +
> +static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon)
> +{
> +	bool found = false;
> +	int point;
> +	int ret;
> +	int fan;
> +
> +	if (hwmon->xe->info.platform == XE_DG2)
> +		return -ENODATA;

[ ... ]

> @@ -1865,11 +1996,18 @@ xe_hwmon_get_preregistration_info(struct xe_hwmon *hwmon)
>  		if (xe_hwmon_is_visible(hwmon, hwmon_energy, hwmon_energy_input, channel))
>  			xe_hwmon_energy_get(hwmon, channel, &energy);
>  
> -	/* Initialize 'struct xe_hwmon_fan_info' with initial fan register reading. */
> -	for (channel = 0; channel < FAN_MAX; channel++)
> -		if (xe_hwmon_is_visible(hwmon, hwmon_fan, hwmon_fan_input, channel))
> -			xe_hwmon_fan_input_read(hwmon, channel, &fan_speed);
> +	if (hwmon->xe->info.has_fan_control) {
> +		xe_hwmon_get_fan_enable_mask(hwmon);
> +
> +		/* Initialize 'struct xe_hwmon_fan_info' with initial fan register reading. */
> +		for (channel = 0; channel < FAN_MAX; channel++)
> +			if (IS_FAN_ENABLED(hwmon, channel))
> +				xe_hwmon_fan_input_read(hwmon, channel, &fan_speed);
>  
> +		/* Fan control tables initialization */
> +		if (xe_hwmon_read_fan_control_info(hwmon))
> +			xe_warn(hwmon->xe, "Fan control tables are not available\n");
> +	}

[Severity: Low]
Will xe_hwmon_get_preregistration_info() emit a spurious xe_warn() on
every XE_DG2 probe?

dg2_desc in drivers/gpu/drm/xe/xe_pci.c sets has_fan_control = true, and
xe_hwmon_read_fan_control_info() returns -ENODATA on XE_DG2, causing
every probe on DG2 to log "Fan control tables are not available".

The same warning is also logged when xe_hwmon_get_fan_enable_mask() fails
or reports 0 enabled fans, because its return value and fan_enable_mask
are not checked before calling xe_hwmon_read_fan_control_info().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202125637.1581881-1-karthik.poosa@intel.com?part=1

  reply	other threads:[~2026-12-02 13:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 12:56 [PATCH v7 00/10] drm/xe/hwmon: Add fan control support Karthik Poosa
2026-12-02 12:56 ` [PATCH v7 01/10] drm/xe/hwmon: Initialize fan-control backend and table cache Karthik Poosa
2026-12-02 13:05   ` sashiko-bot [this message]
2026-12-02 12:56 ` [PATCH v7 02/10] drm/xe/hwmon: Expose fanN_max Karthik Poosa
2026-12-02 12:56 ` [PATCH v7 03/10] drm/xe/pcode: Add ordered write batch helper Karthik Poosa
2026-12-02 12:56 ` [PATCH v7 04/10] drm/xe/hwmon: Expose pwm[1-3] Karthik Poosa
2026-12-02 12:56 ` [PATCH v7 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable Karthik Poosa
2026-12-02 12:56 ` [PATCH v7 06/10] drm/xe/hwmon: Enable fan curve control support Karthik Poosa
2026-12-02 12:56 ` [PATCH v7 07/10] drm/xe: Expose tjmax_fan_control_enable device sysfs Karthik Poosa
2026-12-02 12:56 ` [PATCH v7 08/10] drm/xe/hwmon: Restore fan user tables after resume Karthik Poosa
2026-12-02 13:19   ` sashiko-bot
2026-12-02 12:56 ` [PATCH v7 09/10] drm/xe/hwmon: Refresh fan data after late binding Karthik Poosa
2026-12-02 13:19   ` sashiko-bot
2026-12-02 12:56 ` [PATCH v7 10/10] drm/xe/hwmon: Add kernel-doc for fan control Karthik Poosa

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=sashiko-outbox-245840@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=karthik.poosa@intel.com \
    --cc=sashiko-reviews@lists.linux.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