Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 00/10] drm/xe/hwmon: Add fan control support
@ 2026-11-30 18:50 Karthik Poosa
  2026-11-30 18:50 ` [PATCH v6 01/10] drm/xe/hwmon: Initialize fan-control backend and table cache Karthik Poosa
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Karthik Poosa @ 2026-11-30 18:50 UTC (permalink / raw)
  To: intel-xe
  Cc: rodrigo.vivi, anshuman.gupta, badal.nilawar, raag.jadav,
	riana.tauro, sk.anirban, mallesh.koujalagi, soham.purkait,
	ravi.kishore.koppuravuri, 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.

Series overview

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

Karthik Poosa (10):
  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/hwmon: Restore fan user tables after resume
  drm/xe/hwmon: Refresh fan data after late binding
  drm/xe: Expose tjmax_fan_control_enable device sysfs
  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                |    3 +
 drivers/gpu/drm/xe/xe_device_sysfs.c          |   62 +
 drivers/gpu/drm/xe/xe_hwmon.c                 | 1278 ++++++++++++++++-
 drivers/gpu/drm/xe/xe_hwmon.h                 |    6 +
 drivers/gpu/drm/xe/xe_late_bind_fw.c          |    3 +
 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                    |   11 +-
 12 files changed, 1513 insertions(+), 29 deletions(-)

-- 
2.34.1


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

end of thread, other threads:[~2026-11-30 21:32 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox