All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Purkait, Soham" <soham.purkait@intel.com>
To: Karthik Poosa <karthik.poosa@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: <rodrigo.vivi@intel.com>, <anshuman.gupta@intel.com>,
	<badal.nilawar@intel.com>, <raag.jadav@intel.com>
Subject: Re: [PATCH v9 11/11] drm/xe/hwmon: Add kernel-doc for fan control
Date: Thu, 3 Dec 2026 01:25:15 +0530	[thread overview]
Message-ID: <ab911cf5-5151-4cf2-b765-90032523520b@intel.com> (raw)
In-Reply-To: <20261202195221.1862825-12-karthik.poosa@intel.com>


On 03-12-2026 01:22, 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.
>
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
> ---
>
> v2:
>   -Update the fan-control documentation to describe late-binding visibility
>    refresh, staged point-prefix curves, suspended and restored user tables,
>    and TjMax fan-control preservation across suspend and resume.
>
> v3:
> - Update pwmN that it reports active pwm duty cycle.
> - Update pwmN_enable that it return -ENODATA when control mode is
>    uninitialized.
>
>   drivers/gpu/drm/xe/xe_hwmon.c | 81 +++++++++++++++++++++++++++++++++++
>   1 file changed, 81 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 0407f6f1ab45..3e9a5d2e47c9 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -141,6 +141,87 @@ 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 with at
> + * least two points. 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.
> + *
> + * Late-bound fan firmware refreshes the stock table and maximum fan speed.
> + * Active manual and full-speed user tables are re-programmed after the refresh,
> + * while the cached user curve is preserved. Active manual and full-speed fan
> + * state is also restored across system suspend, runtime D3cold, and FLR. TjMax
> + * fan control is independently saved and restored across those state-loss
> + * transitions. D3hot runtime suspend does not lose firmware state and does not
> + * require TjMax or fan-table restoration.
> + *
> + * 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`` reports the active PWM duty cycle in the hwmon 0..255 range.
> + *   Writes set a fixed duty cycle in manual mode.
> + * - ``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. Each write fills the selected point, and the staged curve is committed
> + * once a complete point prefix ends with (0, 0) or reaches the last supported
> + * point. The (0, 0) end marker is not included in the committed 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. Staged temperature and PWM values are cleared after the
> + * completing write, whether firmware accepts or rejects the curve.
> + * Firmware acceptance publishes the staged curve in the cached user table;
> + * rejection keeps the previously cached user curve.
> + *
> + * 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 while the
> + * control mode is uninitialized.
> + */
> +
>   /**
>    * enum xe_fan_pwm_enable_mode - fan PWM enable modes
>    */
LGTM:

Reviewed-by: Soham Purkait <soham.purkait@intel.com>

      reply	other threads:[~2026-12-02 19:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 19:52 [PATCH v9 00/11] drm/xe/hwmon: Add fan control support Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 01/11] drm/xe/hwmon: Rename has_fan_control to has_fan Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 02/11] drm/xe/hwmon: Initialize fan-control backend and table cache Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 03/11] drm/xe/hwmon: Expose fanN_max Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 04/11] drm/xe/pcode: Add ordered write batch helper Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 05/11] drm/xe/hwmon: Expose pwm[1-3] Karthik Poosa
2026-12-02 19:53   ` Purkait, Soham
2026-12-02 19:52 ` [PATCH v9 06/11] drm/xe/hwmon: Expose pwm[1-3]_enable Karthik Poosa
2026-12-02 19:53   ` Purkait, Soham
2026-12-02 19:52 ` [PATCH v9 07/11] drm/xe/hwmon: Enable fan curve control support Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 08/11] drm/xe: Expose tjmax_fan_control_enable device sysfs Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 09/11] drm/xe/hwmon: Restore fan user tables after resume Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 10/11] drm/xe/hwmon: Refresh fan data after late binding Karthik Poosa
2026-12-02 19:52 ` [PATCH v9 11/11] drm/xe/hwmon: Add kernel-doc for fan control Karthik Poosa
2026-12-02 19:55   ` Purkait, Soham [this message]

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=ab911cf5-5151-4cf2-b765-90032523520b@intel.com \
    --to=soham.purkait@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=karthik.poosa@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=rodrigo.vivi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.