Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Karthik Poosa <karthik.poosa@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <anshuman.gupta@intel.com>,
	<badal.nilawar@intel.com>, <raag.jadav@intel.com>,
	<riana.tauro@intel.com>, <sk.anirban@intel.com>,
	<mallesh.koujalagi@intel.com>, <soham.purkait@intel.com>,
	<ravi.kishore.koppuravuri@intel.com>
Subject: Re: [PATCH v7 07/10] drm/xe: Expose tjmax_fan_control_enable device sysfs
Date: Wed, 2 Dec 2026 09:23:06 -0500	[thread overview]
Message-ID: <axApyqoK-C0_RHkM@intel.com> (raw)
In-Reply-To: <20261202125637.1581881-8-karthik.poosa@intel.com>

On Wed, Dec 02, 2026 at 06:26:34PM +0530, Karthik Poosa wrote:
> Add a device attribute to read and configure firmware TjMax fan control,
> which forces maximum fan PWM as SoC temperature approaches TjMax or
> GDDR/VR temperature approaches its thermal maximum.
> 
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  .../ABI/testing/sysfs-driver-intel-xe-gpu     | 20 ++++++
>  drivers/gpu/drm/xe/xe_device_sysfs.c          | 62 +++++++++++++++++++
>  drivers/gpu/drm/xe/xe_pcode_api.h             |  3 +
>  3 files changed, 85 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-driver-intel-xe-gpu b/Documentation/ABI/testing/sysfs-driver-intel-xe-gpu
> index b563b7e8a9d9..85091d44df9b 100644
> --- a/Documentation/ABI/testing/sysfs-driver-intel-xe-gpu
> +++ b/Documentation/ABI/testing/sysfs-driver-intel-xe-gpu
> @@ -21,6 +21,26 @@ Description:
>  		This sysfs file is present only on Crescent Island devices.
>  		It is readable by all users.
>  
> +What:		/sys/bus/pci/drivers/xe/.../tjmax_fan_control_enable
> +Date:		November 2026
> +KernelVersion:	7.5
> +Contact:	intel-xe@lists.freedesktop.org
> +Description:
> +		RW. Firmware TjMax fan control.
> +
> +		Write 1 to enable or 0 to disable firmware TjMax fan control,
> +		which forces maximum fan PWM as SoC temperature approaches
> +		TjMax or GDDR/VR temperature approaches its thermal maximum.
> +		Reads return 1 if enabled and 0 otherwise.
> +
> +		This mode is applied by firmware on top of the hwmon
> +		pwm[1-3]_enable selection; hwmon pwm[1-3] and
> +		pwm[1-3]_enable do not reflect the override.
> +
> +		This sysfs file is present only on devices with fan control
> +		support, except SR-IOV VFs. Accesses fail with the firmware
> +		error if the command is not supported.
> +
>  What:		/sys/bus/pci/drivers/xe/.../tile<N>/memory/max_freq
>  Date:		October 2026
>  KernelVersion:	7.5
> diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c
> index 9b734aeefd33..87ee91f51977 100644
> --- a/drivers/gpu/drm/xe/xe_device_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_device_sysfs.c
> @@ -35,6 +35,11 @@
>   * lb_voltage_regulator_version - Voltage regulator version provisioned by late
>   * binding. Exposed only if supported by the device.
>   *
> + * tjmax_fan_control_enable - Report/change firmware TjMax fan control, which
> + * forces maximum fan PWM as SoC temperature approaches TjMax or GDDR/VR
> + * temperature approaches its thermal maximum. Exposed on devices with fan
> + * control support, except SR-IOV VFs.
> + *
>   * shrinker_non_purgeable_seeks - Report/change the cost, relative to
>   * purgeable buffer objects, of recreating non-purgeable buffer objects
>   * reclaimed by the shrinker. Higher values reduce reclaim pressure on
> @@ -209,6 +214,57 @@ static const struct attribute_group late_bind_attr_group = {
>  	.is_visible = late_bind_attr_is_visible,
>  };
>  
> +static ssize_t
> +tjmax_fan_control_enable_show(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> +	struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
> +	u32 val = 0;
> +	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);
> +	drm_dbg(&xe->drm, "pcode READ_TJMAX_FAN_CONTROL_MODE: val %#x, ret %d\n",
> +		ret ? 0 : val, ret);
> +
> +	return ret ?: sysfs_emit(buf, "%u\n", !!(val & TJMAX_FAN_CONTROL_ENABLE));
> +}
> +
> +static ssize_t
> +tjmax_fan_control_enable_store(struct device *dev, struct device_attribute *attr,
> +			       const char *buf, size_t count)
> +{
> +	struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
> +	u32 val;
> +	int ret;
> +
> +	ret = kstrtou32(buf, 0, &val);
> +	if (ret)
> +		return ret;
> +	if (val > 1)
> +		return -EINVAL;
> +
> +	guard(xe_pm_runtime)(xe);
> +	ret = xe_pcode_write(xe_device_get_root_tile(xe),
> +			     PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_TJMAX_FAN_CONTROL_MODE, 0),
> +			     val);
> +	drm_dbg(&xe->drm, "pcode WRITE_TJMAX_FAN_CONTROL_MODE: val %u, ret %d\n", val, ret);
> +
> +	return ret ?: count;
> +}
> +static DEVICE_ATTR_RW(tjmax_fan_control_enable);
> +
> +static struct attribute *fan_control_attrs[] = {
> +	&dev_attr_tjmax_fan_control_enable.attr,
> +	NULL
> +};
> +
> +/* Not probed: the command may only be supported after fan-control late binding. */
> +static const struct attribute_group fan_control_attr_group = {
> +	.attrs = fan_control_attrs,
> +};
> +
>  /**
>   * DOC: PCIe Gen5 Limitations
>   *
> @@ -463,5 +519,11 @@ int xe_device_sysfs_init(struct xe_device *xe)
>  			return ret;
>  	}
>  
> +	if (xe->info.has_fan_control && !IS_SRIOV_VF(xe)) {
> +		ret = devm_device_add_group(dev, &fan_control_attr_group);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/xe/xe_pcode_api.h b/drivers/gpu/drm/xe/xe_pcode_api.h
> index bf321ed19251..a217256f9e9d 100644
> --- a/drivers/gpu/drm/xe/xe_pcode_api.h
> +++ b/drivers/gpu/drm/xe/xe_pcode_api.h
> @@ -95,6 +95,9 @@
>  #define     FSC_READ_FAN_TABLE			0x7
>  #define     FAN_CONTROL_POINT_TEMP_MASK		REG_GENMASK(7, 0)
>  #define     FAN_CONTROL_POINT_SPEED_MASK	REG_GENMASK(15, 8)
> +#define     FSC_WRITE_TJMAX_FAN_CONTROL_MODE	0x8
> +#define     FSC_READ_TJMAX_FAN_CONTROL_MODE	0x9
> +#define       TJMAX_FAN_CONTROL_ENABLE		REG_BIT(0)
>  
>  #define PCODE_SCRATCH(x)		XE_REG(0x138320 + ((x) * 4))
>  /* PCODE_SCRATCH0 */
> -- 
> 2.34.1
> 

  reply	other threads:[~2026-12-02 14:23 UTC|newest]

Thread overview: 19+ 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
2026-12-02 15:47     ` Poosa, Karthik
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 14:22   ` Rodrigo Vivi
2026-12-02 12:56 ` [PATCH v7 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable Karthik Poosa
2026-12-02 14:22   ` Rodrigo Vivi
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 14:23   ` Rodrigo Vivi [this message]
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 14:33     ` Poosa, Karthik
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=axApyqoK-C0_RHkM@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=karthik.poosa@intel.com \
    --cc=mallesh.koujalagi@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=ravi.kishore.koppuravuri@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=sk.anirban@intel.com \
    --cc=soham.purkait@intel.com \
    /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