All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Poosa, Karthik" <karthik.poosa@intel.com>
To: "Purkait, Soham" <soham.purkait@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: <rodrigo.vivi@intel.com>, <anshuman.gupta@intel.com>,
	<badal.nilawar@intel.com>, <raag.jadav@intel.com>,
	<riana.tauro@intel.com>, <sk.anirban@intel.com>,
	<mallesh.koujalagi@intel.com>,
	<ravi.kishore.koppuravuri@intel.com>
Subject: Re: [PATCH v6 09/10] drm/xe: Expose tjmax_fan_control_enable device sysfs
Date: Tue, 1 Dec 2026 23:01:44 +0530	[thread overview]
Message-ID: <23e203ff-85e3-47af-be6b-ea35fd1b7f2b@intel.com> (raw)
In-Reply-To: <ca95ab3b-c945-4379-b603-133b822bc68e@intel.com>


On 01-12-2026 21:44, Purkait, Soham wrote:
>
> On 01-12-2026 00:20, 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>
>> ---
>>
>> v2:
>>   - Use one wording for TjMax fan control in the commit message, ABI and
>>     DOC comment. (Soham)
>>   - Report only the enable bit. (Soham)
>>   - Do not expose the attribute on SR-IOV VFs, where pcode access is
>>     skipped. (sashiko)
>>   - Drop the probe-time read used for visibility; the command may only
>>     be supported after fan-control late binding. This also removes the
>>     uninitialized value passed to xe_pcode_read(). (sashiko)
>>
>>   .../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);
> Is the TjMax fan control mode retained by firmware across D3cold and 
> reset? If not, should the setting be cached and restored on resume,
> as is done for the user fan table?
>
> Regards,
> Soham
It is lost on reset,
yes we shall save and restore it across suspend,resume.
>> +    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 */

  reply	other threads:[~2026-12-01 17:32 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 18:50 [PATCH v6 00/10] drm/xe/hwmon: Add fan control support Karthik Poosa
2026-11-30 18:50 ` [PATCH v6 01/10] drm/xe/hwmon: Initialize fan-control backend and table cache Karthik Poosa
2026-11-30 19:04   ` sashiko-bot
2026-12-01  5:10     ` Poosa, Karthik
2026-12-01  8:09   ` Purkait, Soham
2026-11-30 18:50 ` [PATCH v6 02/10] drm/xe/hwmon: Expose fanN_max Karthik Poosa
2026-12-01  8:10   ` Purkait, Soham
2026-11-30 18:50 ` [PATCH v6 03/10] drm/xe/pcode: Add ordered write batch helper Karthik Poosa
2026-11-30 20:59   ` Rodrigo Vivi
2026-11-30 18:50 ` [PATCH v6 04/10] drm/xe/hwmon: Expose pwm[1-3] Karthik Poosa
2026-12-01 13:04   ` Purkait, Soham
2026-11-30 18:50 ` [PATCH v6 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable Karthik Poosa
2026-12-01 13:38   ` Purkait, Soham
2026-11-30 18:50 ` [PATCH v6 06/10] drm/xe/hwmon: Enable fan curve control support Karthik Poosa
2026-11-30 21:00   ` Rodrigo Vivi
2026-12-01 12:06     ` Purkait, Soham
2026-11-30 18:50 ` [PATCH v6 07/10] drm/xe/hwmon: Restore fan user tables after resume Karthik Poosa
2026-11-30 21:03   ` Rodrigo Vivi
2026-12-01  4:55   ` Nilawar, Badal
2026-12-01  5:13     ` Poosa, Karthik
2026-11-30 18:50 ` [PATCH v6 08/10] drm/xe/hwmon: Refresh fan data after late binding Karthik Poosa
2026-12-01  5:32   ` Nilawar, Badal
2026-12-01 16:41     ` Poosa, Karthik
2026-12-02  6:24       ` Nilawar, Badal
2026-11-30 18:50 ` [PATCH v6 09/10] drm/xe: Expose tjmax_fan_control_enable device sysfs Karthik Poosa
2026-12-01 16:14   ` Purkait, Soham
2026-12-01 17:31     ` Poosa, Karthik [this message]
2026-11-30 18:50 ` [PATCH v6 10/10] drm/xe/hwmon: Add kernel-doc for fan control Karthik Poosa
2026-11-30 21:04   ` Rodrigo Vivi
2026-12-01  8:13   ` Purkait, Soham
2026-11-30 20:52 ` ✓ CI.KUnit: success for drm/xe/hwmon: Add fan control support (rev3) Patchwork
2026-11-30 21:32 ` ✓ Xe.CI.BAT: " Patchwork
2026-12-01  9:17 ` ✗ Xe.CI.FULL: failure " 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=23e203ff-85e3-47af-be6b-ea35fd1b7f2b@intel.com \
    --to=karthik.poosa@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mallesh.koujalagi@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=ravi.kishore.koppuravuri@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=rodrigo.vivi@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 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.