Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Poosa, Karthik" <karthik.poosa@intel.com>
To: "Purkait, Soham" <soham.purkait@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: <rodrigo.vivi@intel.com>, <anshuman.gupta@intel.com>,
	<badal.nilawar@intel.com>, <raag.jadav@intel.com>,
	<riana.tauro@intel.com>, <sk.anirban@intel.com>,
	<mallesh.koujalagi@intel.com>
Subject: Re: [PATCH v2 7/9] drm/xe/hwmon: Add kernel-doc for fan control
Date: Fri, 4 Sep 2026 20:05:00 +0530	[thread overview]
Message-ID: <b07e327d-4ee7-4b04-9455-29acaaf3772a@intel.com> (raw)
In-Reply-To: <5082034f-13f5-419e-98d0-a558a6f8d111@intel.com>


On 04-09-2026 09:32, Purkait, Soham wrote:
> HI Karthik,
>
> On 17-07-2026 09:47, 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>
>> Assisted-by: Codex:gpt-5-4
>> ---
>>   drivers/gpu/drm/xe/xe_hwmon.c | 43 +++++++++++++++++++++++++++++++++++
>>   1 file changed, 43 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c 
>> b/drivers/gpu/drm/xe/xe_hwmon.c
>> index a3ed139ad446..770f07fb6511 100644
>> --- a/drivers/gpu/drm/xe/xe_hwmon.c
>> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
>> @@ -123,6 +123,49 @@ 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.
>> + *
>> + * 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 mode selects how those tables are used:
>> + *
>> + * - ``XE_FAN_PWM_AUTO_STOCK_TABLE`` restores automatic control 
>> using the stock
>> + *   firmware table.
>> + * - ``XE_FAN_PWM_MANUAL_USER_TABLE`` enables the user table for 
>> manual control.
>> + * - ``XE_FAN_PWM_FULL_SPEED`` reuses the user table path but 
>> programs every
>> + *   point to 100 percent duty cycle as a full-speed override.
>> + *
>> + * 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. Manual writes are accepted only while ``pwmN_enable`` is 
>> set to
>> + *   ``XE_FAN_PWM_MANUAL_USER_TABLE``.
> Could you please double check this claim ? Seems like in 
> XE_FAN_PWM_FULL_SPEED mode of pwmN_enable also accepts the manual write.

you are right,

we shall restrict pwm writes for FULL speed mode also.

current we are checking only for auto mode in xe_hwmon_set_user_fan_pwm()

1206         if (fi->pwm_enable_mode == XE_FAN_PWM_AUTO_STOCK_TABLE) {
1207                 xe_dbg(hwmon->xe, "fan %d manual table is not 
active, cannot set pwm\n", fan);
1208                 return -EINVAL;
1209         }

>> + * - ``pwmN_enable`` selects stock automatic mode, manual user-table 
>> mode, or
>> + *   full-speed override.
>> + * - ``pwmN_auto_pointM_temp`` exposes the temperature threshold for 
>> user-table
>> + *   point ``M`` in millidegrees Celsius.
>> + * - ``pwmN_auto_pointM_pwm`` exposes the PWM value for user-table 
>> point ``M``
>> + *   in the hwmon 0..255 range.
>
> Is it always user-table point ? What happens when mode is set to 
> XE_FAN_PWM_AUTO_STOCK_TABLE ?

1. Yes it is always user table point, stock table is read only from 
pcode mailbox.

2. fan curve point writes are allowed only in manual user mode,

see, xe_hwmon_pwm_auto_point_temp_store()

1388         if (fi->pwm_enable_mode != XE_FAN_PWM_MANUAL_USER_TABLE) {
1389                 drm_err(&hwmon->xe->drm,
1390                         "pwm%d_enable not in manual mode; cannot 
update temp point %d\n",
1391                         fan, point);
1392                 return -EINVAL;
1393         }

xe_hwmon_pwm_auto_point_pwm_store()

1492         if (fi->pwm_enable_mode != XE_FAN_PWM_MANUAL_USER_TABLE) {
1493                 drm_err(&hwmon->xe->drm,
1494                         "pwm%d_enable is not in manual user mode, 
cannot update pwm point %d\n",
1495                         fan, point);
1496                 return -EINVAL;
1497         }

>
> Thanks,
> Soham
>
>> + *
>> + * Writes to pwmN_auto_pointM_temp and pwmN_auto_pointM_pwm update 
>> the cached
>> + * user table entries. The driver commits the full user table once 
>> the last
>> + * point has both temperature and PWM values, which keeps 
>> intermediate sysfs
>> + * writes from pushing partially updated curves to firmware.
>> + *
>> + * Writes to pwmN provide a constant manual duty cycle by rewriting 
>> every point
>> + * in the active user table to the same PWM value, clamped against 
>> the minimum
>> + * duty cycle reported by firmware for that fan.
>> + */
>> +
>>   enum xe_fan_pwm_enable_mode {
>>       /** @XE_FAN_PWM_FULL_SPEED: force all user table points to full 
>> speed */
>>       XE_FAN_PWM_FULL_SPEED = 0,

  reply	other threads:[~2026-09-04 14:35 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  4:17 [PATCH v2 0/9] Add fan control support Karthik Poosa
2026-07-17  4:16 ` ✓ CI.KUnit: success for Add fan control support (rev2) Patchwork
2026-07-17  4:17 ` [PATCH v2 1/9] drm/xe/pcode: Introduce xe_pcode_read_timeout() API Karthik Poosa
2026-07-17  4:17 ` [PATCH v2 2/9] drm/xe/hwmon: initialize fan-control backend and table cache Karthik Poosa
2026-08-10  6:03   ` Nilawar, Badal
2026-08-25 16:10     ` Poosa, Karthik
2026-08-11 13:11   ` Nilawar, Badal
2026-08-17 17:01     ` Poosa, Karthik
2026-08-25 16:14     ` Poosa, Karthik
2026-07-17  4:17 ` [PATCH v2 3/9] drm/xe/hwmon: expose fanN_max Karthik Poosa
2026-07-23  5:34   ` Purkait, Soham
2026-07-17  4:17 ` [PATCH v2 4/9] drm/xe/hwmon: expose pwm[1-3] Karthik Poosa
2026-07-24  7:02   ` Purkait, Soham
2026-08-11 13:58     ` Poosa, Karthik
2026-09-01  6:06   ` Purkait, Soham
2026-09-02  7:14     ` Poosa, Karthik
2026-09-03  6:22   ` Purkait, Soham
2026-07-17  4:17 ` [PATCH v2 5/9] drm/xe/hwmon: expose pwm[1-3]_enable Karthik Poosa
2026-09-02  5:57   ` Purkait, Soham
2026-07-17  4:17 ` [PATCH v2 6/9] drm/xe/hwmon: Enable fan curve control support Karthik Poosa
2026-07-22 18:16   ` Purkait, Soham
2026-08-27 12:07     ` Poosa, Karthik
2026-09-03 17:13       ` Purkait, Soham
2026-09-02  6:35   ` Purkait, Soham
2026-09-02  7:36     ` Poosa, Karthik
2026-09-03 17:36   ` Purkait, Soham
2026-07-17  4:17 ` [PATCH v2 7/9] drm/xe/hwmon: Add kernel-doc for fan control Karthik Poosa
2026-09-04  4:02   ` Purkait, Soham
2026-09-04 14:35     ` Poosa, Karthik [this message]
2026-07-17  4:17 ` [PATCH v2 8/9] drm/xe/hwmon: preserve fan user table across suspend resume Karthik Poosa
2026-08-10  5:53   ` Nilawar, Badal
2026-08-27 10:27     ` Poosa, Karthik
2026-07-17  4:17 ` [PATCH v2 9/9] drm/xe/hwmon: Update fan info after late binding Karthik Poosa
2026-07-20  6:20   ` Purkait, Soham
2026-08-27 10:36     ` Poosa, Karthik
2026-07-17  5:00 ` ✓ Xe.CI.BAT: success for Add fan control support (rev2) Patchwork
2026-07-17  8:18 ` ✗ Xe.CI.FULL: failure " 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=b07e327d-4ee7-4b04-9455-29acaaf3772a@intel.com \
    --to=karthik.poosa@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mallesh.koujalagi@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=rodrigo.vivi@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