From: sashiko-bot@kernel.org
To: "Karthik Poosa" <karthik.poosa@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v5 08/10] drm/xe/hwmon: Refresh fan data after late binding
Date: Sat, 28 Nov 2026 06:27:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-238493@kernel.org> (raw)
In-Reply-To: <20261128055923.3316956-9-karthik.poosa@intel.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/xe/hwmon: refresh error in
xe_hwmon_read_fan_control_info() wipes state
- [Medium] drm/xe/hwmon: circular locking dependency in
xe_hwmon_unregister()
- [Low] drm/xe/hwmon: inaccurate kernel-doc on
xe_hwmon_fan_update_post_lb()
--
commit 66dd9f8eb5bcfd27c5213f0a2c07a58daa0c1bb3
Author: Karthik Poosa <karthik.poosa@intel.com>
drm/xe/hwmon: Refresh fan data after late binding
This commit refreshes cached stock fan tables and maximum RPM after
fan-control firmware loads via late binding, and serializes the refresh
with hwmon registration and teardown.
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 76c2b519a21f7..be80717054c18 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
[ ... ]
> @@ -1806,7 +1816,6 @@ static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon)
> if (!IS_FAN_ENABLED(hwmon, fan))
> continue;
>
> - fi->pwm_enable_mode = XE_FAN_PWM_UNINITIALIZED;
> fi->fan_table[STOCK_FAN_TABLE].point_count = 0;
[Severity: Medium]
When xe_hwmon_fan_update_post_lb() calls xe_hwmon_read_fan_control_info()
after hwmon registration, does a pcode failure wipe the previously cached
fi->fan_table[STOCK_FAN_TABLE].point_count and fi->max_rps?
Clearing point_count and overwriting fi->max_rps in place (which also
passes the old cached fi->max_rps as the PCODE_DATA0 input to
xe_pcode_read()) before verifying that the refresh succeeded leaves
fi->pwm_enable_mode at XE_FAN_PWM_AUTO_STOCK_TABLE and the sysfs
attributes visible, so subsequent reads of fanN_max return 0 and reads
of pwmN fail with -ENODATA.
[ ... ]
> @@ -2979,11 +3002,21 @@ int xe_hwmon_register(struct xe_device *xe)
> */
> void xe_hwmon_unregister(struct xe_device *xe)
> {
> - if (!xe->hwmon)
> + struct xe_hwmon *hwmon;
> +
> + /* Stop updates before unregistering hwmon or unplugging the device. */
> + xe_late_bind_pm_suspend(&xe->late_bind);
> +
> + hwmon = READ_ONCE(xe->hwmon);
> + if (!hwmon)
> return;
>
> - hwmon_device_unregister(xe->hwmon->hwmon_dev);
> - xe->hwmon = NULL;
> + mutex_lock(&hwmon->registration_lock);
> + if (READ_ONCE(xe->hwmon) == hwmon) {
> + hwmon_device_unregister(hwmon->hwmon_dev);
> + WRITE_ONCE(xe->hwmon, NULL);
> + }
> + mutex_unlock(&hwmon->registration_lock);
> }
[Severity: Medium]
Does holding hwmon->registration_lock across hwmon_device_unregister()
create a circular locking dependency in lockdep?
hwmon_device_unregister() drains active sysfs attributes under
kn->dep_map, while hwmon sysfs callbacks (such as xe_hwmon_read())
acquire xe_pm_runtime_d3cold_map via xe_pm_runtime_get(). On resume,
xe_pm_runtime_resume() holds xe_pm_runtime_d3cold_map while calling
xe_late_bind_pm_resume() -> flush_work(&fan_control_fw->work), and
xe_late_bind_work() now calls xe_hwmon_fan_update_post_lb(), which takes
hwmon->registration_lock:
hwmon->registration_lock -> kn->dep_map -> xe_pm_runtime_d3cold_map ->
(&fan_control_fw->work) -> hwmon->registration_lock
[ ... ]
> +/**
> + * xe_hwmon_fan_update_post_lb - Update fan info after late binding
> + * @xe: xe device instance
> + *
> + * This function reads the number of fans and their stock table after late binding.
> + */
> +void xe_hwmon_fan_update_post_lb(struct xe_device *xe)
> +{
> + /* Pair with the release store in xe_hwmon_register(). */
> + struct xe_hwmon *hwmon = smp_load_acquire(&xe->hwmon);
> +
> + if (!hwmon || !xe->info.has_fan_control)
> + return;
> +
> + guard(mutex)(&hwmon->registration_lock);
> + if (READ_ONCE(xe->hwmon) != hwmon)
> + return;
> +
> + mutex_lock(&hwmon->hwmon_lock);
> +
> + if (xe_hwmon_read_fan_control_info(hwmon))
> + xe_warn(hwmon->xe, "failed to read stock fan tables after late binding\n");
> +
> + mutex_unlock(&hwmon->hwmon_lock);
> +}
[Severity: Low]
This isn't a bug, but the kernel-doc above says
xe_hwmon_fan_update_post_lb() reads the number of fans, whereas it only
calls xe_hwmon_read_fan_control_info() and does not call
xe_hwmon_get_fan_enable_mask(). The v2 changelog in the commit message
also mentions returning an error from xe_hwmon_get_fan_enable_mask() and
keeping the old mask on failure, which is not part of this patch.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128055923.3316956-1-karthik.poosa@intel.com?part=8
next prev parent reply other threads:[~2026-11-28 6:27 UTC|newest]
Thread overview: 18+ 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-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-28 5:59 ` [PATCH v5 04/10] drm/xe/hwmon: Expose pwm[1-3] Karthik Poosa
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-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-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 [this message]
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
2026-11-28 5:59 ` [PATCH v5 10/10] drm/xe/hwmon: Add kernel-doc for fan control Karthik Poosa
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-238493@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