All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 00/11] drm/xe/hwmon: Add fan control support
@ 2026-12-02 19:52 Karthik Poosa
  2026-12-02 19:52 ` [PATCH v9 01/11] drm/xe/hwmon: Rename has_fan_control to has_fan Karthik Poosa
                   ` (10 more replies)
  0 siblings, 11 replies; 18+ messages in thread
From: Karthik Poosa @ 2026-12-02 19:52 UTC (permalink / raw)
  To: intel-xe
  Cc: rodrigo.vivi, anshuman.gupta, badal.nilawar, raag.jadav,
	soham.purkait, Karthik Poosa

This series adds Intel Xe fan control through the hwmon sysfs ABI: fan
maximum speed, direct PWM control, mode selection and programmable fan
curves. Supported platforms are BMG in this series.

Each fan has a stock table read from firmware and a user table cached in
the driver and written back through PCODE.

Fan control flows across system and runtime suspend-resume and late-binding
flows also handled.

Series overview

 01 Rename has_fan_control to has_fan.
 02 Initialize fan-control backend and table cache
    Read the fan enable mask and stock fan tables.
 03 Expose fanN_max
    Maximum fan speed in RPM.
 04 Add ordered write batch helper
    PCODE helper that writes a fan table without interleaved mailbox
    commands.
 05 Expose pwm[1-3]
    Constant duty cycle in the hwmon 0..255 range.
 06 Expose pwm[1-3]_enable
    0 = full speed, 1 = manual user table, 2 = firmware automatic.
 07 Enable fan curve control support
    pwm[1-3]_auto_point[1-10]_{temp,pwm}.
 08 Expose tjmax_fan_control_enable device sysfs
 09 Restore fan user tables after resume
 10 Refresh fan data after late binding
 11 Add kernel-doc for fan control

The ABI is documented in
Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon and
Documentation/ABI/testing/sysfs-driver-intel-xe-gpu.

Usage

Read fan speed and max RPM:
  cat /sys/class/hwmon/hwmonX/fan1_input
  cat /sys/class/hwmon/hwmonX/fan1_max

Manual mode with a fixed PWM:
  echo 1 > /sys/class/hwmon/hwmonX/pwm1_enable
  echo 120 > /sys/class/hwmon/hwmonX/pwm1

Back to firmware automatic control:
  echo 2 > /sys/class/hwmon/hwmonX/pwm1_enable

Program a 3-point fan curve:
  echo 1 > /sys/class/hwmon/hwmonX/pwm1_enable
  echo 30000 > /sys/class/hwmon/hwmonX/pwm1_auto_point1_temp
  echo 50 > /sys/class/hwmon/hwmonX/pwm1_auto_point1_pwm
  echo 60000 > /sys/class/hwmon/hwmonX/pwm1_auto_point2_temp
  echo 120 > /sys/class/hwmon/hwmonX/pwm1_auto_point2_pwm
  echo 85000 > /sys/class/hwmon/hwmonX/pwm1_auto_point3_temp
  echo 200 > /sys/class/hwmon/hwmonX/pwm1_auto_point3_pwm
  echo 0 > /sys/class/hwmon/hwmonX/pwm1_auto_point4_temp
  echo 0 > /sys/class/hwmon/hwmonX/pwm1_auto_point4_pwm

Notes
 - Package temperature (temp2_input) is the fan table temperature
   reference.
 - Fans start in pwmN_enable = 2 after probe. pwmN and curve point
   writes need pwmN_enable = 1.
 - A curve has 2 to 10 points. Temperature must increase and PWM must
   not decrease from one point to the next.
 - Curve writes are staged and committed once point K+1 is (0, 0) or
   all 10 points are set. A completing write that fails drops all
   staged points.
 - The user curve is kept across pwmN_enable 0 and 2 and re-applied
   when switching back to 1.
 - If firmware does not accept a user table, the fan falls back to
   pwmN_enable = 2.

v2:
 - Add kernel-doc for fan control.
 - Save/restore the user fan table across suspend/resume.
 - Refresh fan info after late binding; keep the user's PWM mode.
 - Show stock table points in the curve attributes when pwmN_enable = 2.

v3:
 - Address v2 review comments.
 - Add an ordered PCODE write batch helper.
 - Support a variable number of fan curve points.
 - Add missing failure checks.
 - Use only 2 fan curve points when setting pwmN.

v4:
 - Address v3 https://patchwork.freedesktop.org/series/176241/ review
   comments. (Soham)
 - Clamp oversized fan masks and stock tables; continue when one fan's
   stock table fails to read.
 - Clear cached values on failed pcode reads.
 - Use percent for fan speed and clamp min PWM to 100%.
 - Fail pwmN writes if pcode reports the wrong user point count.
 - Create fan curve attributes at probe time; add the (0, 0) end
   marker; points must not decrease.
 - Document pwmN_enable values and the curve rules.
 - Call the system PM hooks from xe_device_suspend()/xe_device_resume(),
   which also covers FLR; check d3cold only for runtime PM.
 - Fix the late binding firmware ID check; start fans enabled after
   late binding in automatic mode.
 - Rebase on drm-xe-next; update the ABI Date and KernelVersion.

v5:
 - Address review comments on v4 patch
   https://patchwork.freedesktop.org/series/179435/ from sashiko.
 - Add new sysfs tjmax_fan_control_enable for enable/disable of
   tjmax fan control.
 - Move CRI fan control support out of this patch series.
 - Add kgdoc patch at the end of the patch series.

v6:
 - Address v5 https://patchwork.freedesktop.org/series/179435/ review
   comments. (Soham, sashiko)
 - Report the active PWM from pwmN: PMT on BMG, otherwise interpolated
   from the active fan table; 100 in full speed mode; -ENODATA while
   the fan control mode is not established.
 - Keep the cached user curve across pwmN_enable 0 and 2; full speed
   no longer overwrites it. Remove the redundant is_full_speed flag.
 - Write and verify all user tables through one helper that falls back
   to stock control on failure. Reject tables with fewer than two
   points or non-increasing temperatures before writing to firmware.
 - Hide pwmN_auto_point* without a stock table, return -ENODATA from
   them while the mode is not established, and document them in the
   ABI. Keep staged curve points when the user table is re-applied.
 - Explain why fan table writes must not be interleaved with other
   mailbox commands, and the pcode lock hold time.
 - Do not flush the late binding work from resume, which could deadlock
   against the MEI device resume.
 - Keep the previous stock table and max RPM if the refresh after late
   binding fails; re-program user tables of fans in manual or full
   speed mode after late binding.
 - Unregister the hwmon device outside registration_lock to avoid a
   deadlock with late binding work.
 - tjmax_fan_control_enable: do not expose on SR-IOV VFs, report only
   the enable bit, drop the probe-time visibility read and use one
   wording in the commit message, ABI and DOC comment.
 - Align enum kernel-doc with the ABI, add debug logs before -EINVAL
   returns and use "late binding" consistently.
 - Update the fan ABI Date to December 2026.

v7:
 - Rebase.
 - Reorder the TjMax sysfs, suspend/resume, late-binding, and documentation
   patches.
 - 01: Return an error only if no fan has a readable stock table; skip
   unsupported fan-control reads on DG2 and remove the stale min-PWM note.
 - 04: Move fan-table batch construction and verification into the shared
   commit helper; reduce invalid PWM read logging to debug and require a
   usable stock table for pwm visibility. (Badal)
 - 05: Reuse the commit helper for mode changes; return -ENODATA for
   uninitialized BMG PWM reads; simplify user-table cache updates. (Badal)
 - 06: Refactor curve control to use the table helpers moved into earlier
   patches. (Badal)
 - 08: Preserve fan TjMax control across suspend and resume. (Soham)
 - 09: Decouple xe_hwmon and xe_late_bind_fw using a worker. (Badal)
 - 10: Update documentation as per the above changes.
 
v8:
 - Address review comments from sashiko.
 - Add new patch at the start to rename .has_fan_control to .has_fan.
   .has_fan_control will be now used only for fan control only.
 
v9:
 - Rebase on drm-xe-next. Resolve sashiko patch apply error.

Karthik Poosa (11):
  drm/xe/hwmon: Rename has_fan_control to has_fan
  drm/xe/hwmon: Initialize fan-control backend and table cache
  drm/xe/hwmon: Expose fanN_max
  drm/xe/pcode: Add ordered write batch helper
  drm/xe/hwmon: Expose pwm[1-3]
  drm/xe/hwmon: Expose pwm[1-3]_enable
  drm/xe/hwmon: Enable fan curve control support
  drm/xe: Expose tjmax_fan_control_enable device sysfs
  drm/xe/hwmon: Restore fan user tables after resume
  drm/xe/hwmon: Refresh fan data after late binding
  drm/xe/hwmon: Add kernel-doc for fan control

 .../ABI/testing/sysfs-driver-intel-xe-gpu     |   20 +
 .../ABI/testing/sysfs-driver-intel-xe-hwmon   |   82 +
 drivers/gpu/drm/xe/regs/xe_pmt.h              |    5 +
 drivers/gpu/drm/xe/xe_device.c                |    6 +
 drivers/gpu/drm/xe/xe_device_sysfs.c          |   63 +
 drivers/gpu/drm/xe/xe_device_types.h          |    2 +
 drivers/gpu/drm/xe/xe_hwmon.c                 | 1746 +++++++++++++++--
 drivers/gpu/drm/xe/xe_hwmon.h                 |    6 +
 drivers/gpu/drm/xe/xe_pci.c                   |    4 +-
 drivers/gpu/drm/xe/xe_pci_types.h             |    1 +
 drivers/gpu/drm/xe/xe_pcode.c                 |   49 +
 drivers/gpu/drm/xe/xe_pcode.h                 |   12 +
 drivers/gpu/drm/xe/xe_pcode_api.h             |   11 +
 drivers/gpu/drm/xe/xe_pm.c                    |   12 +-
 14 files changed, 1838 insertions(+), 181 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-12-02 22:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 22:29   ` Rodrigo Vivi
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 22:29   ` Rodrigo Vivi
2026-12-02 19:52 ` [PATCH v9 10/11] drm/xe/hwmon: Refresh fan data after late binding Karthik Poosa
2026-12-02 22:31   ` Rodrigo Vivi
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 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.