From: "Poosa, Karthik" <karthik.poosa@intel.com>
To: <sashiko-reviews@lists.linux.dev>, <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v7 08/10] drm/xe/hwmon: Restore fan user tables after resume
Date: Wed, 2 Dec 2026 20:03:02 +0530 [thread overview]
Message-ID: <08a64e38-6b4a-42b0-bdbd-eab9c26a3903@intel.com> (raw)
In-Reply-To: <sashiko-outbox-245851@kernel.org>
On 02-12-2026 18:49, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [Medium] drm/xe/hwmon: unsupported TjMax PCODE read in
> xe_hwmon_suspend()
> - [Low] drm/xe/hwmon: tjmax_fan_control_enable lost when !CONFIG_HWMON
> --
>
> commit 240231fa4007880cdb7d39faae47263adccfe2fa
> Author: Karthik Poosa <karthik.poosa@intel.com>
>
> drm/xe/hwmon: Restore fan user tables after resume
>
> This commit saves and restores active manual and full-speed fan user tables
> and the TjMax fan control state across system suspend, runtime D3cold, and
> FLR.
>
> [ ... ]
>
>> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
>> index 7cb7fefae1b8f..2fd6c2c50f2c1 100644
>> --- a/drivers/gpu/drm/xe/xe_hwmon.c
>> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> [ ... ]
>
>> @@ -2931,4 +2949,131 @@ void xe_hwmon_unregister(struct xe_device *xe)
>> hwmon_device_unregister(xe->hwmon->hwmon_dev);
>> xe->hwmon = NULL;
>> }
>> +
>> +/**
>> + * xe_hwmon_suspend - Save hwmon state before suspend
>> + * @xe: xe device instance
>> + * @runtime: true for runtime suspend, false for system suspend or FLR prepare
>> + *
>> + * Save any hwmon runtime state that must survive PM suspend transitions.
>> + */
>> +void xe_hwmon_suspend(struct xe_device *xe, bool runtime)
>> +{
>> + struct xe_hwmon *hwmon = READ_ONCE(xe->hwmon);
>> + int fan;
>> +
>> + if (!hwmon || !xe->info.has_fan_control)
>> + return;
>> +
>> + /* Runtime suspend keeps the fan tables unless the device enters d3cold. */
>> + if (runtime && !xe->d3cold.allowed) {
>> + xe_dbg(xe, "d3cold not allowed, skipping fan state snapshot\n");
>> + return;
>> + }
>> +
>> + guard(mutex)(&hwmon->hwmon_lock);
>> +
>> + if (!runtime || xe->d3cold.allowed) {
>> + u32 val = 0;
>> + int ret;
>> +
>> + hwmon->tjmax_fan_control_state = XE_TJMAX_FAN_CONTROL_UNKNOWN;
>> +
>> + ret = xe_pcode_read(xe_device_get_root_tile(xe),
>> + PCODE_MBOX(FAN_SPEED_CONTROL,
>> + FSC_READ_TJMAX_FAN_CONTROL_MODE, 0),
>> + &val, NULL);
>> + if (ret) {
>> + xe_warn(xe, "failed to save fan tjmax control, ret=%d\n", ret);
> [Severity: Medium]
> Does xe_hwmon_suspend() issue an unsupported FSC_READ_TJMAX_FAN_CONTROL_MODE
> PCODE read on XE_DG2 and on devices without late-bound TjMax fan-control
> firmware?
Yes, it will be reported as Illegal command on that.
We could add check for this.
FSC_READ_TJMAX_FAN_CONTROL_MODE is not supported in late binding firmware.
>
> dg2_desc sets has_fan_control = true for MMIO fan speed reads, while the
> other FAN_SPEED_CONTROL PCODE helpers in xe_hwmon.c
> (xe_hwmon_get_fan_enable_mask() and xe_hwmon_read_fan_control_info())
> explicitly skip XE_DG2. In addition, fan_control_attr_group in
> drivers/gpu/drm/xe/xe_device_sysfs.c notes that
> FSC_READ_TJMAX_FAN_CONTROL_MODE may only be supported after fan-control
> late binding. Issuing this command unconditionally on every system
> suspend, runtime D3cold suspend, and FLR logs a PCODE mailbox error and an
> xe_warn() whenever the platform or firmware does not support it.
>
> [ ... ]
>
>> diff --git a/drivers/gpu/drm/xe/xe_hwmon.h b/drivers/gpu/drm/xe/xe_hwmon.h
>> index e67e0134f02a5..50874b6b6527a 100644
>> --- a/drivers/gpu/drm/xe/xe_hwmon.h
>> +++ b/drivers/gpu/drm/xe/xe_hwmon.h
>> @@ -13,9 +13,13 @@ struct xe_device;
>> #if IS_REACHABLE(CONFIG_HWMON)
>> int xe_hwmon_register(struct xe_device *xe);
>> void xe_hwmon_unregister(struct xe_device *xe);
>> +void xe_hwmon_suspend(struct xe_device *xe, bool runtime);
>> +void xe_hwmon_resume(struct xe_device *xe, bool runtime);
>> #else
>> static inline int xe_hwmon_register(struct xe_device *xe) { return 0; };
>> static inline void xe_hwmon_unregister(struct xe_device *xe) { }
>> +static inline void xe_hwmon_suspend(struct xe_device *xe, bool runtime) {}
>> +static inline void xe_hwmon_resume(struct xe_device *xe, bool runtime) {}
>> #endif
> [Severity: Low]
> Will tjmax_fan_control_enable lose its state across suspend, runtime
> D3cold, and FLR when !IS_REACHABLE(CONFIG_HWMON)?
>
> xe_device_sysfs_init() registers fan_control_attr_group on the PCI device
> regardless of CONFIG_HWMON, but the save and restore logic for
> tjmax_fan_control_enable lives in xe_hwmon_suspend() and
> xe_hwmon_resume(), which compile to no-ops when CONFIG_HWMON is not
> reachable.
We can enable the attribute it only if IS_REACHABLE(CONFIG_HWMON)
>
next prev parent reply other threads:[~2026-12-02 14:33 UTC|newest]
Thread overview: 18+ 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 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
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 [this message]
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=08a64e38-6b4a-42b0-bdbd-eab9c26a3903@intel.com \
--to=karthik.poosa@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--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