All of 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 v5 09/10] drm/xe: Expose tjmax_fan_control_enable device sysfs
Date: Sat, 28 Nov 2026 06:12:19 +0000	[thread overview]
Message-ID: <sashiko-outbox-238487@kernel.org> (raw)
In-Reply-To: <20261128055923.3316956-10-karthik.poosa@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/xe: tjmax_fan_control_enable exposed as no-op on SR-IOV
  VFs
- [Medium] drm/xe: uninitialized val passed to xe_pcode_read() in
  fan_control_attr_is_visible()
--

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

drm/xe: Expose tjmax_fan_control_enable device sysfs

This commit adds a read-write tjmax_fan_control_enable sysfs attribute
to read and configure the firmware TjMax fan control mode via PCODE
mailbox commands.

> diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c
> index f6275e74eb317..3a4861b825485 100644
> --- a/drivers/gpu/drm/xe/xe_device_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_device_sysfs.c

[ ... ]

> @@ -203,6 +206,73 @@ static const struct attribute_group late_bind_attr_group = {

[ ... ]

> +static umode_t fan_control_attr_is_visible(struct kobject *kobj,
> +					   struct attribute *attr, int n)
> +{
> +	struct device *dev = kobj_to_dev(kobj);
> +	struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
> +	u32 val;
> +	int ret;
> +
> +	guard(xe_pm_runtime)(xe);
> +	ret = xe_pcode_read(xe_device_get_root_tile(xe),
> +			    PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_TJMAX_FAN_CONTROL_MODE, 0),
> +			    &val, NULL);
> +
> +	return ret ? 0 : attr->mode;
> +}

[Severity: Medium]
Should val be initialized to 0 before calling xe_pcode_read(), as in
tjmax_fan_control_enable_show()?

xe_pcode_read() -> pcode_mailbox_rw() -> __pcode_mailbox_rw() treats
val0 as an in/out argument and unconditionally writes *data0 to
PCODE_DATA0 before issuing the mailbox command:

drivers/gpu/drm/xe/xe_pcode.c:__pcode_mailbox_rw() {
	...
	xe_mmio_write32(mmio, PCODE_DATA0, *data0);
	xe_mmio_write32(mmio, PCODE_DATA1, data1 ? *data1 : 0);
	xe_mmio_write32(mmio, PCODE_MAILBOX, PCODE_READY | mbox);
	...
}

Leaving val uninitialized writes stack garbage into PCODE_DATA0 during
driver probe, triggering KMSAN uninit-value warnings and risking command
rejection if firmware checks the data register.

[ ... ]

> @@ -428,5 +498,11 @@ int xe_device_sysfs_init(struct xe_device *xe)
>  			return ret;
>  	}
>  
> +	if (xe->info.has_fan_control) {
> +		ret = devm_device_add_group(dev, &fan_control_attr_group);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	return 0;
>  }

[Severity: Medium]
Can fan_control_attr_group be exposed on SR-IOV VFs where PCODE access
is disabled?

On platforms with both has_fan_control and has_sriov (such as
Battlemage), vf_update_device_info() sets xe->info.skip_pcode = 1 but
leaves xe->info.has_fan_control enabled.  Because pcode_mailbox_rw()
immediately returns 0 when skip_pcode is set,
fan_control_attr_is_visible() sees ret == 0 and exposes
tjmax_fan_control_enable on VFs, where reads report a fabricated value
and writes silently succeed as no-ops.  Guarding registration with
!IS_SRIOV_VF(xe) (or !xe->info.skip_pcode), like
auto_link_downgrade_attr_group and late_bind_attr_group above, would
avoid registering it on VFs.

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

  reply	other threads:[~2026-11-28  6:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28  5:59 [PATCH v5 00/10] drm/xe/hwmon: Add fan control support Karthik Poosa
2026-11-28  5:59 ` [PATCH v5 01/10] drm/xe/hwmon: Initialize fan-control backend and table cache Karthik Poosa
2026-11-30  9:49   ` Purkait, Soham
2026-11-30 11:41     ` Poosa, Karthik
2026-11-28  5:59 ` [PATCH v5 02/10] drm/xe/hwmon: Expose fanN_max Karthik Poosa
2026-11-28  5:59 ` [PATCH v5 03/10] drm/xe/pcode: Add ordered write batch helper Karthik Poosa
2026-11-28  6:04   ` sashiko-bot
2026-11-30 10:33   ` Purkait, Soham
2026-11-28  5:59 ` [PATCH v5 04/10] drm/xe/hwmon: Expose pwm[1-3] Karthik Poosa
2026-11-30 11:51   ` Purkait, Soham
2026-11-30 12:47     ` Poosa, Karthik
2026-11-28  5:59 ` [PATCH v5 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable Karthik Poosa
2026-11-28  6:13   ` sashiko-bot
2026-11-30 11:27     ` Poosa, Karthik
2026-11-30 14:27       ` Poosa, Karthik
2026-11-30 14:29   ` Purkait, Soham
2026-11-28  5:59 ` [PATCH v5 06/10] drm/xe/hwmon: Enable fan curve control support Karthik Poosa
2026-11-28  6:10   ` sashiko-bot
2026-11-30 16:11     ` Poosa, Karthik
2026-11-28  5:59 ` [PATCH v5 07/10] drm/xe/hwmon: Restore fan user tables after resume Karthik Poosa
2026-11-28  6:15   ` sashiko-bot
2026-11-28  5:59 ` [PATCH v5 08/10] drm/xe/hwmon: Refresh fan data after late binding Karthik Poosa
2026-11-28  6:27   ` sashiko-bot
2026-11-30 15:55   ` Purkait, Soham
2026-11-28  5:59 ` [PATCH v5 09/10] drm/xe: Expose tjmax_fan_control_enable device sysfs Karthik Poosa
2026-11-28  6:12   ` sashiko-bot [this message]
2026-11-30 16:31   ` Purkait, Soham
2026-11-28  5:59 ` [PATCH v5 10/10] drm/xe/hwmon: Add kernel-doc for fan control Karthik Poosa
2026-11-30 16:44   ` Purkait, Soham
2026-11-28  6:14 ` ✗ CI.KUnit: failure for drm/xe/hwmon: Add fan control support (rev2) Patchwork

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-238487@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.