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] drm/xe/xe_late_bind_fw: Correct fan count parsing
Date: Thu, 03 Dec 2026 16:58:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-248231@kernel.org> (raw)
In-Reply-To: <20261203163646.2672136-1-karthik.poosa@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/xe: inconsistent FSC_READ_NUM_FANS bitmask vs count
  parsing on Battlemage
--

commit 133e36e73163f5120eca6f3253d97ab200fe4b2e
Author: Karthik Poosa <karthik.poosa@intel.com>

drm/xe/xe_late_bind_fw: Correct fan count parsing

This commit updates xe_late_bind_fw_num_fans() to count the set bits returned
by the FSC_READ_NUM_FANS pcode mailbox command with hweight32(), and zeroes
*num_fans on read failure.

> diff --git a/drivers/gpu/drm/xe/xe_late_bind_fw.c b/drivers/gpu/drm/xe/xe_late_bind_fw.c
> index ad39383a7e41f..13516b3a1be34 100644
> --- a/drivers/gpu/drm/xe/xe_late_bind_fw.c
> +++ b/drivers/gpu/drm/xe/xe_late_bind_fw.c
> @@ -226,9 +226,17 @@ static int xe_late_bind_fw_num_fans(struct xe_late_bind *late_bind, u32 *num_fan
>  {
>  	struct xe_device *xe = late_bind_to_xe(late_bind);
>  	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
> +	int ret = 0;
>  
> -	return xe_pcode_read(root_tile,
> -			     PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0), num_fans, NULL);
> +	ret = xe_pcode_read(root_tile,
> +			    PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0), num_fans, NULL);
> +	if (ret) {
> +		*num_fans = 0;
> +		return ret;
> +	}
> +	*num_fans = hweight32(*num_fans);
> +
> +	return 0;
>  }

[Severity: Medium]
Does xe_hwmon_fan_is_visible() also need to parse FSC_READ_NUM_FANS as a
bitmask, or does Battlemage pcode still return a count?

bmg_desc in drivers/gpu/drm/xe/xe_pci.c enables both has_fan_control and
late_bind_mask = BIT(XE_LB_FW_FAN_CONTROL), so both functions issue
PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0) on the same hardware,
while xe_hwmon_fan_is_visible() still treats the reply as an integer count:

drivers/gpu/drm/xe/xe_hwmon.c:xe_hwmon_fan_is_visible() {
    ...
		if (xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_NUM_FANS, &uval))
			return 0;

		return channel < uval ? 0444 : 0;
    ...
}

If FSC_READ_NUM_FANS returns a bitmask on Battlemage, a 2-fan card returning
0x3 satisfies channel < 3 and exposes a bogus fan3_input sysfs attribute that
reads BMG_FAN_3_SPEED for a nonexistent fan.  If Battlemage returns a count
instead, unconditionally calling hweight32() here miscounts 2 fans as 1.

Either xe_hwmon_fan_is_visible() (and the XE_DG2 override in
xe_hwmon_pcode_read_fan_control()) should parse FSC_READ_NUM_FANS as a
bitmask, or the hweight32() conversion should be restricted to platforms where
pcode returns a bitmask.

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

      parent reply	other threads:[~2026-12-03 16:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 16:36 [PATCH] drm/xe/xe_late_bind_fw: Correct fan count parsing Karthik Poosa
2026-12-03 16:43 ` ✓ CI.KUnit: success for " Patchwork
2026-12-03 16:58 ` sashiko-bot [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=sashiko-outbox-248231@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