From: sashiko-bot@kernel.org
To: "Karthik Poosa" <karthik.poosa@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v5 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable
Date: Sat, 28 Nov 2026 06:13:55 +0000 [thread overview]
Message-ID: <sashiko-outbox-238488@kernel.org> (raw)
In-Reply-To: <20261128055923.3316956-6-karthik.poosa@intel.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/xe/hwmon: wrong pwm readback in xe_hwmon_pwm_read() for
non-stock modes
- [Medium] drm/xe/hwmon: xe_hwmon_set_user_fan_pwm() clobbers user table
in mode 0
- [Low] drm/xe/hwmon: missing point count check in
xe_hwmon_fan_set_auto()
--
commit 562936f0b505f7da573995f262799f779e7aab25
Author: Karthik Poosa <karthik.poosa@intel.com>
drm/xe/hwmon: Expose pwm[1-3]_enable
This commit exposes the pwm[1-3]_enable hwmon sysfs attributes to select
between full-speed, manual user-table, and automatic firmware fan control
modes, and documents them in the Xe hwmon ABI.
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 78ef926feffcb..b6214ef933165 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
[ ... ]
> @@ -1209,9 +1230,88 @@ static int xe_hwmon_fan_set_auto(struct xe_hwmon *hwmon, u8 fan)
> PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_NUM_FAN_CONTROL_POINTS, fan),
> 0);
> if (ret)
> - return ret;
> + goto fail;
>
> fi->fan_table[USER_FAN_TABLE].point_count = 0;
> + fi->pwm_enable_mode = XE_FAN_PWM_AUTO_STOCK_TABLE;
> + fi->is_full_speed = false;
> + return 0;
[Severity: Low]
Should xe_hwmon_fan_set_auto() call xe_hwmon_get_fan_point_count() to verify
that firmware cleared the user point count to 0 before marking
XE_FAN_PWM_AUTO_STOCK_TABLE active? The v5 changelog notes that user point
counts are verified after auto-mode writes as well as table activation, and
both xe_hwmon_activate_user_fan_table() and xe_hwmon_set_user_fan_pwm() do
this check.
[ ... ]
> @@ -2054,12 +2168,20 @@ static int xe_hwmon_get_pwm_from_pmt(struct xe_hwmon *hwmon, int channel, long *
> return -EOPNOTSUPP;
> }
>
> - xe_dbg(hwmon->xe, "fan %d PMT active PWM value: %u\n", channel, pwm);
> + xe_dbg(hwmon->xe, "fan %d: active pwm from PMT: %u\n", channel, pwm);
>
> *val = pwm;
> return 0;
> }
>
> +static enum fan_table_type xe_hwmon_get_active_fan_table(struct xe_hwmon *hwmon, u8 fan)
> +{
> + if (hwmon->fi[fan].pwm_enable_mode == XE_FAN_PWM_AUTO_STOCK_TABLE)
> + return STOCK_FAN_TABLE;
> + else
> + return USER_FAN_TABLE;
> +}
> +
> static int
> xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val)
> {
> @@ -2074,8 +2196,9 @@ xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val)
> switch (attr) {
> case hwmon_pwm_input:
> /* If the user fan table is not populated, get active stock pwm */
> - if (!fi->fan_table[USER_FAN_TABLE].point_count) {
> - xe_dbg(hwmon->xe, "user fan table not active for fan %d\n", channel);
> + if (xe_hwmon_get_active_fan_table(hwmon, channel) == STOCK_FAN_TABLE) {
> + xe_dbg(hwmon->xe, "getting active pwm for fan %d from stock table\n",
> + channel);
> switch (hwmon->xe->info.platform) {
> case XE_BATTLEMAGE:
> ret = xe_hwmon_get_pwm_from_pmt(hwmon, channel, &pwm);
> @@ -2084,13 +2207,18 @@ xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val)
> ret = xe_hwmon_get_stock_table_pwm(hwmon, channel, &pwm);
> break;
> }
> - if (ret)
> + if (ret) {
> + xe_err(hwmon->xe, "failed to get active pwm for fan %d, ret=%d\n",
> + channel, ret);
> goto unlock;
> + }
> } else {
> /*
> * pwmN writes set every user-table point to the same speed,
> * so the first point gives the cached manual PWM percentage.
> */
> + xe_dbg(hwmon->xe, "getting active pwm for fan %d from user table cache\n",
> + channel);
> pwm = fi->fan_table[USER_FAN_TABLE].fcp[0].speed;
> }
[Severity: Medium]
Can reading hwmon_pwm_input return the wrong PWM duty value when
pwm_enable_mode is not XE_FAN_PWM_AUTO_STOCK_TABLE?
When pwm[1-3]_enable is switched from 2 to 1 before any flat write to
pwm[1-3], xe_hwmon_activate_user_fan_table() populates USER_FAN_TABLE from
STOCK_FAN_TABLE with a multi-point temperature curve. In that state the
points in USER_FAN_TABLE do not share a single speed, so reading
fi->fan_table[USER_FAN_TABLE].fcp[0].speed always reports the lowest
temperature breakpoint speed instead of reading PMT on Battlemage or
interpolating the active table against package temperature.
In addition, xe_hwmon_get_active_fan_table() returns USER_FAN_TABLE when
fi->pwm_enable_mode is XE_FAN_PWM_UNINITIALIZED. If a mode transition and
its xe_hwmon_fan_set_auto() fallback fail after clearing
fi->fan_table[USER_FAN_TABLE].point_count to 0, reading pwm[1-3] returns
stale or zero fcp[0].speed instead of -ENODATA.
[ ... ]
> @@ -2125,7 +2263,48 @@ xe_hwmon_pwm_write(struct xe_hwmon *hwmon, u32 attr, int channel, long val)
> ret = -EINVAL;
> break;
> }
> - ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, (u8)val);
> + ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, (u8)val, false);
> + break;
> + case hwmon_pwm_enable:
> + if (val == XE_FAN_PWM_FULL_SPEED) {
> + ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, U8_MAX, true);
> + if (ret) {
> + xe_warn(hwmon->xe,
> + "full speed enable for fan %d failed, ret=%d\n",
> + channel, ret);
> + break;
> + }
> + } else if (val == XE_FAN_PWM_MANUAL_USER_TABLE) {
> + enum fan_table_type source = fi->fan_table[USER_FAN_TABLE].point_count ?
> + USER_FAN_TABLE : STOCK_FAN_TABLE;
> +
> + /*
> + * Manual fan speed control using user fan table.
> + * If user fan table is not programmed, it would be initialized with
> + * clamped stock points which allows manual control with some
> + * default points.
> + */
> + ret = xe_hwmon_activate_user_fan_table(hwmon, channel, false, source);
[Severity: Medium]
Does setting pwm[1-3]_enable to 0 (XE_FAN_PWM_FULL_SPEED) overwrite
fi->fan_table[USER_FAN_TABLE] and leave the fan pinned at 100% when
subsequently switching to mode 1 (XE_FAN_PWM_MANUAL_USER_TABLE)?
Calling xe_hwmon_set_user_fan_pwm(hwmon, channel, U8_MAX, true) replaces
fi->fan_table[USER_FAN_TABLE].fcp[0..1] with 100% speed points and sets
fi->fan_table[USER_FAN_TABLE].point_count to MIN_FAN_CONTROL_POINTS. When
userspace later writes 1 to pwm[1-3]_enable, point_count is non-zero, so
source becomes USER_FAN_TABLE instead of STOCK_FAN_TABLE (or any previously
configured user table) and xe_hwmon_activate_user_fan_table() re-applies the
100% full-speed table.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128055923.3316956-1-karthik.poosa@intel.com?part=5
next prev parent reply other threads:[~2026-11-28 6:14 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 [this message]
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
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-238488@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