From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Karthik Poosa <karthik.poosa@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <anshuman.gupta@intel.com>,
<badal.nilawar@intel.com>, <raag.jadav@intel.com>,
<riana.tauro@intel.com>, <sk.anirban@intel.com>,
<mallesh.koujalagi@intel.com>, <soham.purkait@intel.com>,
<ravi.kishore.koppuravuri@intel.com>
Subject: Re: [PATCH v6 10/10] drm/xe/hwmon: Add kernel-doc for fan control
Date: Mon, 30 Nov 2026 16:04:51 -0500 [thread overview]
Message-ID: <aw3k84XRta6f2UBA@intel.com> (raw)
In-Reply-To: <20261130185050.36979-11-karthik.poosa@intel.com>
On Tue, Dec 01, 2026 at 12:20:50AM +0530, Karthik Poosa wrote:
> Add kernel-doc for xe hwmon fan control and describe the fan control
> model built around firmware stock tables and driver-managed user tables.
>
> Document the exposed sysfs files for fan speed, maximum speed, pwm
> control, pwm mode selection, and per-point fan curve temperature/PWM
> programming.
>
> This makes the hwmon fan control userspace interface easier to discover
> and understand.
>
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
>
> v2:
> - Clarify the registration-time visibility requirements.
> - Document how late binding affects existing fan attributes.
>
> v3:
> - Document that curve files need a stock table and that tables
> programmed by pwmN_enable modes 0 and 1 follow the curve rules.
> - Document that a failed stock table refresh after late binding keeps
> the previous table.
> - Document -ENODATA reads when the fan control mode is not
> established.
> - Document that a failed completing curve write drops all staged
> points. (Soham)
>
> drivers/gpu/drm/xe/xe_hwmon.c | 70 +++++++++++++++++++++++++++++++++++
> 1 file changed, 70 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 4ee51cfc9283..70a4e4941390 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -140,6 +140,76 @@ struct xe_hwmon_energy_info {
> long accum_energy;
> };
>
> +/**
> + * DOC: Xe fan control
> + *
> + * Xe fan control is exposed through the hwmon pwm and fan interfaces when the
> + * platform advertises PCODE-backed fan management support.
> + *
> + * Attribute visibility is determined during hwmon registration. ``fanN_max``
> + * requires maximum fan speed data, while ``pwmN``, ``pwmN_enable`` and the
> + * ``pwmN_auto_pointM_*`` curve files require a readable stock fan table. Late
> + * binding refreshes cached data for existing fans but does not create
> + * attributes that were hidden at registration. The stock table can change with
> + * the late bound firmware; if a complete table cannot be read, the previous one
> + * is kept.
> + *
> + * The implementation tracks two fan tables per fan:
> + *
> + * - A stock table read from firmware through PCODE.
> + * - A user table cached in the driver and programmed back through PCODE.
> + *
> + * The pwmN_enable sysfs value selects how those tables are used:
> + *
> + * - 0 (``XE_FAN_PWM_FULL_SPEED``) programs the user table at 100 percent duty
> + * cycle as a full-speed override. The cached user curve is kept.
> + * - 1 (``XE_FAN_PWM_MANUAL_USER_TABLE``) enables the user table for manual
> + * control. Without a cached user curve, it starts from the stock table.
> + * - 2 (``XE_FAN_PWM_AUTO_STOCK_TABLE``) restores automatic control using the
> + * stock firmware table. The cached user curve is kept for a later switch to
> + * mode 1.
> + *
> + * Any table programmed by modes 0 and 1 must meet the curve rules below;
> + * otherwise the mode switch fails with -EINVAL.
> + *
> + * The fan-control sysfs files are:
> + *
> + * - ``fanN_input`` reports the measured fan speed in RPM.
> + * - ``fanN_max`` reports the maximum supported fan speed in RPM.
> + * - ``pwmN`` reads or sets the manual PWM duty cycle in the hwmon 0..255
> + * range.
> + * - ``pwmN_enable`` selects the mode described above.
> + * - ``pwmN_auto_pointM_temp`` reports the temperature of point ``M`` of the
> + * stock table in mode 2 or of the user table otherwise, in millidegrees
> + * Celsius. Writes stage the user-table point.
> + * - ``pwmN_auto_pointM_pwm`` reports the PWM value of point ``M`` of the same
> + * table in the hwmon 0..255 range. Writes stage the user-table point.
> + *
> + * Writes to ``pwmN``, ``pwmN_auto_pointM_temp`` and ``pwmN_auto_pointM_pwm``
> + * are accepted only while ``pwmN_enable`` is 1; otherwise they fail with
> + * -EINVAL. Firmware stores duty cycle in percent, so PWM values read back
> + * rounded to the nearest percent step. Nonzero curve PWM writes are kept at
> + * least 1 percent so rounding cannot turn them into an end marker.
> + *
> + * Writes to ``pwmN_auto_pointM_temp`` and ``pwmN_auto_pointM_pwm`` are staged
> + * in the driver, so intermediate writes never reach firmware as a partial
> + * curve. The staged curve is committed once points 1..K all have both a
> + * temperature and a PWM value and either point K+1 is set to (0, 0) or K is
> + * the last supported point. The (0, 0) end marker is not part of the curve.
> + * A curve must have at least two points, temperature must increase and PWM
> + * must not decrease from one point to the next; otherwise the completing write
> + * fails with -EINVAL. A completing write that fails drops all staged points.
> + *
> + * Writes to ``pwmN`` replace the user table with a two-point table at a
> + * constant duty cycle.
> + *
> + * If a user-table write is not accepted by firmware, the fan falls back to
> + * mode 2 and the previously cached user curve is kept. If that fallback also
> + * fails, the fan control mode is not established and reads of ``pwmN``,
> + * ``pwmN_enable`` and ``pwmN_auto_pointM_*`` fail with -ENODATA until a mode
> + * is written again.
> + */
> +
> /**
> * enum xe_fan_pwm_enable_mode - fan PWM enable modes
> */
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-11-30 21:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 18:50 [PATCH v6 00/10] drm/xe/hwmon: Add fan control support Karthik Poosa
2026-11-30 18:50 ` [PATCH v6 01/10] drm/xe/hwmon: Initialize fan-control backend and table cache Karthik Poosa
2026-11-30 19:04 ` sashiko-bot
2026-11-30 18:50 ` [PATCH v6 02/10] drm/xe/hwmon: Expose fanN_max Karthik Poosa
2026-11-30 18:50 ` [PATCH v6 03/10] drm/xe/pcode: Add ordered write batch helper Karthik Poosa
2026-11-30 20:59 ` Rodrigo Vivi
2026-11-30 18:50 ` [PATCH v6 04/10] drm/xe/hwmon: Expose pwm[1-3] Karthik Poosa
2026-11-30 18:50 ` [PATCH v6 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable Karthik Poosa
2026-11-30 18:50 ` [PATCH v6 06/10] drm/xe/hwmon: Enable fan curve control support Karthik Poosa
2026-11-30 21:00 ` Rodrigo Vivi
2026-11-30 18:50 ` [PATCH v6 07/10] drm/xe/hwmon: Restore fan user tables after resume Karthik Poosa
2026-11-30 21:03 ` Rodrigo Vivi
2026-11-30 18:50 ` [PATCH v6 08/10] drm/xe/hwmon: Refresh fan data after late binding Karthik Poosa
2026-11-30 18:50 ` [PATCH v6 09/10] drm/xe: Expose tjmax_fan_control_enable device sysfs Karthik Poosa
2026-11-30 18:50 ` [PATCH v6 10/10] drm/xe/hwmon: Add kernel-doc for fan control Karthik Poosa
2026-11-30 21:04 ` Rodrigo Vivi [this message]
2026-11-30 20:52 ` ✓ CI.KUnit: success for drm/xe/hwmon: Add fan control support (rev3) Patchwork
2026-11-30 21:32 ` ✓ Xe.CI.BAT: " 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=aw3k84XRta6f2UBA@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=karthik.poosa@intel.com \
--cc=mallesh.koujalagi@intel.com \
--cc=raag.jadav@intel.com \
--cc=ravi.kishore.koppuravuri@intel.com \
--cc=riana.tauro@intel.com \
--cc=sk.anirban@intel.com \
--cc=soham.purkait@intel.com \
/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