From: sashiko-bot@kernel.org
To: "Karthik Poosa" <karthik.poosa@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v7 09/10] drm/xe/hwmon: Refresh fan data after late binding
Date: Wed, 02 Dec 2026 13:19:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-245852@kernel.org> (raw)
In-Reply-To: <20261202125637.1581881-10-karthik.poosa@intel.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] drm/xe/hwmon: fan_late_bind_work aborts on runtime resume in
xe_hwmon_resume()
- [Medium] drm/xe/hwmon: xe_hwmon_resume() fails to restart
fan_late_bind_work after D3hot
- [Medium] drm/xe/hwmon: missing cancel_delayed_work_sync() in
xe_hwmon_suspend()
- [Medium] drm/xe/hwmon: fan_late_bind_work runs on platforms without
fan late binding
- [Low] drm/xe/hwmon: stale comment in xe_hwmon_register() references
removed function
--
commit 0eda84b4dad26ab42bb697e17e7063f6bb7ab964
Author: Karthik Poosa <karthik.poosa@intel.com>
drm/xe/hwmon: Refresh fan data after late binding
This commit adds a delayed work item in hwmon to poll for fan-control
firmware late-binding provisioning after registration and resume, refreshing
cached stock fan tables and maximum RPM and re-programming active user fan
tables.
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 2fd6c2c50f2c1..a3ec319e857f2 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
[ ... ]
> @@ -2897,13 +2920,20 @@ int xe_hwmon_register(struct xe_device *xe)
> for (fan = 0; fan < FAN_MAX; fan++)
> hwmon->fi[fan].pwm_enable_mode = XE_FAN_PWM_UNINITIALIZED;
>
> - ret = devm_mutex_init(dev, &hwmon->hwmon_lock);
> + ret = drmm_mutex_init(&xe->drm, &hwmon->hwmon_lock);
> + if (ret)
> + return ret;
> +
> + ret = drmm_mutex_init(&xe->drm, &hwmon->registration_lock);
> if (ret)
> return ret;
>
> + guard(mutex)(&hwmon->registration_lock);
> +
> /* There's only one instance of hwmon per device */
> hwmon->xe = xe;
> - xe->hwmon = hwmon;
> + /* Pair with the acquire load in xe_hwmon_fan_late_binding_update(). */
> + smp_store_release(&xe->hwmon, hwmon);
[Severity: Low]
This isn't a bug, but the comment above smp_store_release() refers to
xe_hwmon_fan_late_binding_update(), which was removed in v6, and the remaining
loads of xe->hwmon use READ_ONCE() rather than smp_load_acquire().
> @@ -2926,11 +2956,15 @@ int xe_hwmon_register(struct xe_device *xe)
> xe_log_err(xe, HWMON, ret, "Failed to register xe hwmon\n");
> goto err_null_hwmon;
> }
> + if (xe->info.has_fan_control) {
> + hwmon->fan_late_bind_poll_count = 0;
> + mod_delayed_work(system_wq, &hwmon->fan_late_bind_work, 0);
> + }
[Severity: Medium]
Should this and xe_hwmon_resume() also check xe->info.late_bind_mask &
BIT(XE_LB_FW_FAN_CONTROL) before queuing fan_late_bind_work?
Platforms like DG2 set has_fan_control = true with late_bind_mask = 0. On
those platforms, PCODE_LATE_BINDING fails with an illegal command error in
xe_pcode_read(), and because ret is non-zero, xe_hwmon_fan_late_bind_work()
falls through and retries 30 times, logging 30 PCODE errors on probe and on
every resume.
[ ... ]
> @@ -3035,6 +3085,13 @@ void xe_hwmon_resume(struct xe_device *xe, bool runtime)
> return;
> }
>
> + mutex_lock(&hwmon->registration_lock);
> + if (READ_ONCE(xe->hwmon) == hwmon) {
> + hwmon->fan_late_bind_poll_count = 0;
> + mod_delayed_work(system_wq, &hwmon->fan_late_bind_work, 0);
> + }
> + mutex_unlock(&hwmon->registration_lock);
[Severity: Medium]
If the device enters D3hot runtime suspend (!xe->d3cold.allowed) during the
1-second polling window before V1_FAN_PROVISIONED is seen, will
fan_late_bind_work stop without ever being restarted?
When suspended in D3hot, xe_hwmon_fan_late_bind_work() sees
!xe_pm_runtime_get_if_active(xe) and returns without rescheduling. On the
subsequent runtime resume from D3hot, xe_hwmon_resume() returns early at the
if (runtime && !xe->d3cold.allowed) check right above this hunk, leaving the
stock fan tables and max_rps unrefreshed and active user fan tables
un-reprogrammed.
[ ... ]
> +static void xe_hwmon_fan_late_bind_work(struct work_struct *work)
> +{
> + struct xe_hwmon *hwmon = container_of(to_delayed_work(work),
> + struct xe_hwmon, fan_late_bind_work);
> + struct xe_device *xe = hwmon->xe;
> + u32 status = 0;
> + int ret;
> +
> + if (!xe_pm_runtime_get_if_active(xe))
> + return;
[Severity: Medium]
Can fan_late_bind_work abort permanently on runtime resume from D3cold?
xe_pm_runtime_resume() calls xe_hwmon_resume(xe, true) from inside the driver
runtime_resume callback while dev->power.runtime_status is still RPM_RESUMING.
xe_hwmon_resume() queues fan_late_bind_work with delay 0 and then performs
synchronous PCODE mailbox writes before returning to rpm_resume():
CPU0 CPU1 (system_wq)
rpm_resume()
runtime_status = RPM_RESUMING
xe_pci_runtime_resume()
xe_pm_runtime_resume()
xe_hwmon_resume()
mod_delayed_work(..., 0)
xe_hwmon_fan_late_bind_work()
xe_pm_runtime_get_if_active(xe)
/* runtime_status != RPM_ACTIVE */
return; <-- polling stops
xe_pcode_write(...)
runtime_status = RPM_ACTIVE
Because pm_runtime_get_if_active() requires runtime_status == RPM_ACTIVE, the
worker exits without polling or rescheduling, so the fan tables and max_rps
are not refreshed after the late-binding firmware reload finishes.
> +
> + ret = xe_pcode_read(xe_device_get_root_tile(xe),
> + PCODE_MBOX(PCODE_LATE_BINDING, GET_CAPABILITY_STATUS, 0),
> + &status, NULL);
> + if (!ret && !(status & V1_FAN_SUPPORTED))
> + goto out;
> +
> + if (!ret && (status & V1_FAN_PROVISIONED)) {
> + xe_hwmon_refresh_fan_data(hwmon);
> + goto out;
> + }
> +
> + mutex_lock(&hwmon->registration_lock);
> + if (READ_ONCE(xe->hwmon) == hwmon &&
> + ++hwmon->fan_late_bind_poll_count < XE_FAN_LATE_BIND_POLL_RETRIES)
> + mod_delayed_work(system_wq, &hwmon->fan_late_bind_work,
> + XE_FAN_LATE_BIND_POLL_INTERVAL);
> + else if (READ_ONCE(xe->hwmon) == hwmon)
> + xe_dbg(xe, "timed out waiting for fan firmware provisioning\n");
> + mutex_unlock(&hwmon->registration_lock);
> +out:
> + xe_pm_runtime_put(xe);
> +}
[Severity: Medium]
Should xe_hwmon_suspend() cancel fan_late_bind_work synchronously, the way
xe_late_bind_pm_suspend() flushes late-binding work?
During system suspend (throughout dpm_suspend, where __xe_pci_suspend()
disables the PCI device and puts it in PCI_D3cold before dpm_suspend_late
disables runtime PM) and during PCIe FLR (xe_pci_reset_prepare() ->
xe_device_suspend()), dev->power.runtime_status remains RPM_ACTIVE with
disable_depth == 0. If a pending fan_late_bind_work fires after
xe_hwmon_suspend(), xe_pm_runtime_get_if_active(xe) returns true and the
worker issues PCODE MMIO accesses to a disabled or resetting PCI device, and a
failed xe_hwmon_activate_user_fan_table() will fall back to
xe_hwmon_fan_set_auto() and overwrite the saved fi->pwm_enable_mode before
xe_hwmon_resume().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202125637.1581881-1-karthik.poosa@intel.com?part=9
next prev parent reply other threads:[~2026-12-02 13:19 UTC|newest]
Thread overview: 14+ 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 12:56 ` [PATCH v7 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable Karthik Poosa
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 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 12:56 ` [PATCH v7 09/10] drm/xe/hwmon: Refresh fan data after late binding Karthik Poosa
2026-12-02 13:19 ` sashiko-bot [this message]
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=sashiko-outbox-245852@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