From: sashiko-bot@kernel.org
To: "Karthik Poosa" <karthik.poosa@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v5 06/10] drm/xe/hwmon: Enable fan curve control support
Date: Sat, 28 Nov 2026 06:10:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-238486@kernel.org> (raw)
In-Reply-To: <20261128055923.3316956-7-karthik.poosa@intel.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] drm/xe/hwmon: missing stock table check in
xe_hwmon_curve_attributes_visible()
- [Medium] drm/xe/hwmon: xe_hwmon_pwm_read() returns fcp[0].speed on
user fan curves
- [Low] drm/xe/hwmon: missing ABI documentation update claimed in commit
message
- [Low] drm/xe/hwmon: unhandled XE_FAN_PWM_UNINITIALIZED in curve show
callbacks
--
commit 51f62604f9e213b63207cde46fb9f696d1728daf
Author: Karthik Poosa <karthik.poosa@intel.com>
drm/xe/hwmon: Enable fan curve control support
This commit exposes fan curve temperature and PWM control points in hwmon
sysfs via pwm[1-3]_auto_point[1-10]_temp and pwm[1-3]_auto_point[1-10]_pwm,
allowing userspace to stage and commit custom fan curves to PCODE.
> Update Xe hwmon ABI documentation for pwm auto point temperature
> attributes.
>
> v2:
> - Use xe helpers for dmesg logs.
> - Update kernel version in Xe hwmon documentation.
[Severity: Low]
Was the Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon update
dropped from this patch? The commit message says the ABI documentation is
updated, but this commit only touches drivers/gpu/drm/xe/xe_hwmon.c and
leaves pwm[1-3]_auto_point[1-10]_temp and pwm[1-3]_auto_point[1-10]_pwm
undocumented.
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index b6214ef933165..4d6eb6f6fbc2f 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
[ ... ]
> @@ -1389,6 +1482,312 @@ static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm, boo
> return 0;
> }
>
> +#define XE_CURVE_IDX(fan, point) (((fan) << 8) | (point))
> +#define XE_CURVE_FAN(idx) ((u8)(((idx) >> 8) & 0xff))
> +#define XE_CURVE_POINT(idx) ((u8)((idx) & 0xff))
> +
> +static int
> +xe_hwmon_decode_curve_index(struct xe_hwmon *hwmon, u32 index, u8 *fan, u8 *point)
> +{
> + u8 local_fan = XE_CURVE_FAN(index);
> + u8 local_point = XE_CURVE_POINT(index);
> +
> + if (local_fan >= FAN_MAX || local_point >= MAX_FAN_CONTROL_POINTS) {
> + xe_dbg(hwmon->xe, "invalid fan curve index 0x%x: fan %u point %u\n",
> + index, local_fan, local_point);
> + return -EINVAL;
> + }
> +
> + *fan = local_fan;
> + *point = local_point;
> +
> + 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 ssize_t
> +xe_hwmon_pwm_auto_point_temp_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
> + struct xe_hwmon *hwmon = dev_get_drvdata(dev);
> + enum fan_table_type active_table;
> + struct xe_hwmon_fan_info *fi;
> + u32 point_count;
> + u8 point;
> + u8 temp;
> + int ret;
> + u8 fan;
> +
> + ret = xe_hwmon_decode_curve_index(hwmon, sattr->index, &fan, &point);
> + if (ret)
> + return ret;
> +
> + guard(mutex)(&hwmon->hwmon_lock);
> +
> + fi = &hwmon->fi[fan];
> + active_table = xe_hwmon_get_active_fan_table(hwmon, fan);
[Severity: Low]
Should xe_hwmon_pwm_auto_point_temp_show() and
xe_hwmon_pwm_auto_point_pwm_show() return -ENODATA when
fi->pwm_enable_mode is XE_FAN_PWM_UNINITIALIZED, the same way
xe_hwmon_pwm_read() does for hwmon_pwm_enable? Right now
xe_hwmon_get_active_fan_table() maps XE_FAN_PWM_UNINITIALIZED to
USER_FAN_TABLE, so after a failed xe_hwmon_fan_set_auto() call the show
callbacks report stale user-table points or 0 instead of an error.
> +
> + point_count = fi->fan_table[active_table].point_count;
> +
> + if (point >= point_count)
> + temp = 0;
> + else
> + temp = fi->fan_table[active_table].fcp[point].temp;
> + return sysfs_emit(buf, "%u\n", temp * MILLIDEGREE_PER_DEGREE);
> +}
> +
> +static int xe_hwmon_update_user_fan_point(struct xe_hwmon *hwmon, u8 fan, u32 point,
> + bool is_temp, u8 value)
> +{
> + struct xe_hwmon_fan_info *fi = &hwmon->fi[fan];
> + struct fan_table *table;
> + u32 point_count;
> + int ret;
> +
> + table = &fi->fan_table[USER_FAN_TABLE];
> +
> + if (is_temp) {
> + table->staged_fcp[point].temp = value;
> + table->temp_staged |= BIT(point);
> + } else {
> + table->staged_fcp[point].speed = value;
> + table->speed_staged |= BIT(point);
> + }
> +
> + /* Wait for a complete prefix; (0, 0) ends the curve without becoming a point. */
> + for (point_count = 0; point_count < MAX_FAN_CONTROL_POINTS; point_count++) {
> + if (!(table->temp_staged & BIT(point_count)) ||
> + !(table->speed_staged & BIT(point_count)))
> + return 0;
> + if (!table->staged_fcp[point_count].temp &&
> + !table->staged_fcp[point_count].speed)
> + break;
> + }
> +
> + if (point_count < MIN_FAN_CONTROL_POINTS) {
> + xe_dbg(hwmon->xe, "fan %d curve needs at least %d points, got %u\n",
> + fan, MIN_FAN_CONTROL_POINTS, point_count);
> + ret = -EINVAL;
> + goto clear_staged;
> + }
> +
> + ret = xe_hwmon_commit_user_fan_table(hwmon, fan, table->staged_fcp, point_count);
> + if (ret)
> + goto clear_staged;
> +
> + /* Publish the new curve only after firmware accepts its point count. */
> + memcpy(table->fcp, table->staged_fcp, point_count * sizeof(table->fcp[0]));
> + table->point_count = point_count;
> + fi->pwm_enable_mode = XE_FAN_PWM_MANUAL_USER_TABLE;
> + fi->is_full_speed = false;
[Severity: Medium]
When a multi-point user fan curve is committed here, does reading pwmN in
xe_hwmon_pwm_read() return the wrong PWM value?
drivers/gpu/drm/xe/xe_hwmon.c:xe_hwmon_pwm_read() {
...
if (xe_hwmon_get_active_fan_table(hwmon, channel) == STOCK_FAN_TABLE) {
...
} 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;
}
...
}
For a custom curve with different speeds across temperature points,
fcp[0].speed is only the speed at the lowest temperature point rather than
the active PWM from PMT telemetry (on Battlemage) or interpolation across
USER_FAN_TABLE. Also, if xe_hwmon_commit_user_fan_table() and its
xe_hwmon_fan_set_auto() fallback both fail, point_count is reset to 0 and
pwm_enable_mode is set to XE_FAN_PWM_UNINITIALIZED, yet xe_hwmon_pwm_read()
still takes this USER_FAN_TABLE branch and returns stale fcp[0].speed.
[ ... ]
> +static umode_t xe_hwmon_curve_attributes_visible(struct kobject *kobj,
> + struct attribute *attr, int index)
> +{
> + struct device *dev = kobj_to_dev(kobj);
> + struct xe_hwmon *hwmon = dev_get_drvdata(dev);
> + u32 fan = index / XE_CURVE_ATTRS_PER_FAN;
> +
> + if (!hwmon->xe->info.has_fan_control || !IS_FAN_ENABLED(hwmon, fan))
> + return 0;
> +
> + /* All slots must exist at registration, before the user curve has been staged. */
> + return attr->mode;
> +}
[Severity: Medium]
Should xe_hwmon_curve_attributes_visible() also check
!hwmon->fi[fan].fan_table[STOCK_FAN_TABLE].point_count like
xe_hwmon_pwm_is_visible() does?
drivers/gpu/drm/xe/xe_hwmon.c:xe_hwmon_pwm_is_visible() {
if (!hwmon->xe->info.has_fan_control || !IS_FAN_ENABLED(hwmon, channel) ||
!hwmon->fi[channel].fan_table[STOCK_FAN_TABLE].point_count)
return 0;
...
}
When a fan channel is enabled in fan_enable_mask (such as on DG2, or when
reading the stock table in xe_hwmon_read_fan_control_info() fails or
returns 0 points), pwmN and pwmN_enable are hidden and fi->pwm_enable_mode
stays XE_FAN_PWM_UNINITIALIZED, but all 20 pwmN_auto_point* attributes are
still exposed even though every write to them will fail with -EINVAL.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128055923.3316956-1-karthik.poosa@intel.com?part=6
next prev parent reply other threads:[~2026-11-28 6:10 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 [this message]
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-238486@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