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 05/11] drm/xe/hwmon: Expose pwm[1-3]
Date: Thu, 3 Dec 2026 01:23:08 +0530	[thread overview]
Message-ID: <6ce477cc-06af-4b27-85e2-564adb441eff@intel.com> (raw)
In-Reply-To: <20261202195221.1862825-6-karthik.poosa@intel.com>


On 03-12-2026 01:22, Karthik Poosa wrote:
> Expose pwm[1-3] hwmon attributes for each available fan. Userspace can
> read PWM values in the range 0..255 and set a manual fan speed
> independently of the fan curve. Switching back to the stock curve is
> added by a later patch.
>
> Read active PWM from PMT on BMG. On other platforms, derive PWM from the
> stock curve when no user table is active.
>
> After writing the user table, read back its point count to verify
> firmware accepted it. If verification fails, restore stock fan control.
>
> Document pwm[1-3] in the Xe hwmon ABI.
>
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
> ---
>
> v2:
>   - Use xe helpers for dmesg logs.
>   - Avoid using hwmon->num_fans to get fan count in
>     xe_hwmon_pwm_is_visible().
>
> v3:
>   - Set PWM directly through the user table; avoid initializing it from the
>     stock table. (Soham)
>   - Move the unused xe_hwmon_activate_user_fan_table() to the subsequent
>     patch.
>   - Fail pwmN reads when no value has been written, rather than activating
>     the user table from the stock table.
>   - Define MIN_FAN_CONTROL_POINTS as 2.
>   - Use MIN_FAN_CONTROL_POINTS for PWM configuration. (Soham)
>   - Use batched writes for configuring fan control points when setting pwmN.
>   - Add and rephrase couple debug logs.
>   - Update the hwmon documentation.
>
> v4:
>   - Use tab indentation in ABI doc and MIN_FAN_CONTROL_POINTS. (Soham)
>   - Drop unused linux/delay.h include. (Soham)
>   - Clamp min PWM to 100% since fan table speed is in percent. (Soham)
>   - Log both the requested pwm and the applied percentage. (Soham)
>   - Fail the pwm write if pcode reports a user point count other than
>     MIN_FAN_CONTROL_POINTS after the write. (Soham)
>   - Drop redundant channel range checks in pwm read/write. (Soham)
>   - Fix misleading comments and debug log alignment. (Soham)
>   - Note that the 0..255 to percent round trip is lossy. (Soham)
>   - Update ABI Date and KernelVersion to November 2026 and 7.5.
>   - Document that pwm values below the fan minimum are raised to it.
>   - Return -ENODATA and log at debug level when pwm has not been set.
>   - Invalidate the cached user table when the pwm write or verify fails.
>   - Clear point count on pcode read failure.
>   - Drop unneeded parentheses in MIN_FAN_CONTROL_POINTS and FIXED_PWM_TEMP.
>   - Document pcode user table write ordering.
>
> v5:
>   - Expose pwm[1-3] node only if stock table is valid.
>   - Read current pwm from PMT for BMG and from stock table for other
>     platforms when user table is not active.
>   - Read back the user point count after every PWM table write and fall
>     back to stock table when the count is not accepted.
>
> v6:
>   - Add couple of warnings. (Soham)
>
> v7:
>   - Move user fan-table batch construction and verification into
>     new function xe_hwmon_commit_user_fan_table(). (Badal)
>   - Keep xe_hwmon_set_user_fan_pwm() responsible for preparing the
>     fixed two-point curve and updating the cached user table. (Badal)
>   - Log an out-of-range PWM read at debug level, as pollers reading pwmN
>     after resume flood dmesg. (Rodrigo)
>   - Drop Soham Reviewed-by as refactor occurred.
>   - Make pwm node visible only if stock points > MIN_FAN_CONTROL_POINTS.
>
>   .../ABI/testing/sysfs-driver-intel-xe-hwmon   |   9 +
>   drivers/gpu/drm/xe/regs/xe_pmt.h              |   5 +
>   drivers/gpu/drm/xe/xe_hwmon.c                 | 362 ++++++++++++++++++
>   drivers/gpu/drm/xe/xe_pcode_api.h             |   3 +
>   4 files changed, 379 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon b/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon
> index ac9ccfd47eab..34c50f13f0b4 100644
> --- a/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon
> +++ b/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon
> @@ -346,3 +346,12 @@ Description:	RW. Package burst power limit interval (Tau in PL2/Tau) in
>   		milliseconds over which sustained power is averaged.
>   
>   		Only supported for particular Intel Xe graphics platforms.
> +
> +What:		/sys/bus/pci/drivers/xe/.../hwmon/hwmon<i>/pwm[1-3]
> +Date:		December 2026
> +KernelVersion:	7.5
> +Contact:	intel-xe@lists.freedesktop.org
> +Description:	RW. Target fan PWM duty value in the range 0..255, where 255
> +		is 100% fan speed.
> +
> +		Only supported for particular Intel Xe graphics platforms.
> diff --git a/drivers/gpu/drm/xe/regs/xe_pmt.h b/drivers/gpu/drm/xe/regs/xe_pmt.h
> index fb5b5a8648ba..4fec057b2dd6 100644
> --- a/drivers/gpu/drm/xe/regs/xe_pmt.h
> +++ b/drivers/gpu/drm/xe/regs/xe_pmt.h
> @@ -15,6 +15,11 @@
>   #define	ENERGY_PKG			REG_GENMASK64(31, 0)
>   #define	ENERGY_CARD			REG_GENMASK64(63, 32)
>   
> +#define BMG_FAN_PWM_PMT_OFFSET		(0x58)
> +#define BMG_FAN1_PWM			REG_GENMASK64(15, 0)
> +#define BMG_FAN2_PWM			REG_GENMASK64(31, 16)
> +#define BMG_FAN3_PWM			REG_GENMASK64(47, 32)
> +
>   #define PUNIT_VERSION_OFFSET		0xA0
>   
>   #define XE_PMT_BASE_OFFSET		0xE0000
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 1d7ba1149917..e77ab0685bb7 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -157,6 +157,9 @@ enum fan_table_type {
>   /* Maximum number of fan control points supported by each fan. */
>   #define MAX_FAN_CONTROL_POINTS	10
>   
> +/* Minimum number of points required for a user fan table. */
> +#define MIN_FAN_CONTROL_POINTS	2
> +
>   /* Fan control point index: bit31 selects fan table type; bits30:0 control point index. */
>   #define FCP_INDEX(table_type, point_num) (((u32)(table_type) << 31) | \
>   						((u32)(point_num) & GENMASK(30, 0)))
> @@ -923,6 +926,7 @@ static const struct hwmon_channel_info * const hwmon_info[] = {
>   	HWMON_CHANNEL_INFO(energy, HWMON_E_INPUT | HWMON_E_LABEL, HWMON_E_INPUT | HWMON_E_LABEL),
>   	HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_MAX, HWMON_F_INPUT | HWMON_F_MAX,
>   			   HWMON_F_INPUT | HWMON_F_MAX),
> +	HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT, HWMON_PWM_INPUT, HWMON_PWM_INPUT),
>   	NULL
>   };
>   
> @@ -1166,6 +1170,162 @@ static int xe_hwmon_get_fan_enable_mask(struct xe_hwmon *hwmon)
>   	return 0;
>   }
>   
> +static int xe_hwmon_get_fan_point_count(struct xe_hwmon *hwmon, u8 fan, u32 *point_count,
> +					enum fan_table_type table_type)
> +{
> +	int ret;
> +
> +	*point_count = 0;
> +	ret = xe_hwmon_pcode_read_fan_control(hwmon,
> +					      (table_type == USER_FAN_TABLE) ?
> +					      FSC_READ_USER_FAN_CONTROL_POINTS :
> +					      FSC_READ_STOCK_FAN_CONTROL_POINTS,
> +					      fan, point_count);
> +	if (ret) {
> +		*point_count = 0;
> +		xe_err(hwmon->xe, "failed to read fan %d %s point count, ret=%d\n", fan,
> +		       (table_type == USER_FAN_TABLE) ? "user" : "stock", ret);
> +		return ret;
> +	}
> +
> +	if (*point_count > MAX_FAN_CONTROL_POINTS) {
> +		xe_err(hwmon->xe, "fan %d %s point count %u exceeds max %u\n", fan,
> +		       (table_type == USER_FAN_TABLE) ? "user" : "stock", *point_count,
> +		       MAX_FAN_CONTROL_POINTS);
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +/*
> + * Set the fan to automatic mode by clearing the user fan table.
> + * This will make the firmware run the stock fan table.
> + */
> +static int xe_hwmon_fan_set_auto(struct xe_hwmon *hwmon, u8 fan)
> +{
> +	struct xe_hwmon_fan_info *fi = &hwmon->fi[fan];
> +	int ret;
> +
> +	ret = xe_pcode_write(xe_device_get_root_tile(hwmon->xe),
> +			     PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_NUM_FAN_CONTROL_POINTS, fan),
> +			     0);
> +	if (ret)
> +		return ret;
> +
> +	fi->fan_table[USER_FAN_TABLE].point_count = 0;
> +
> +	return 0;
> +}
> +
> +static int xe_hwmon_commit_user_fan_table(struct xe_hwmon *hwmon, u8 fan,
> +					  const struct fan_control_point *points, u32 point_count)
> +{
> +	/* The extra write is for the final write that sets the number of fan control points */
> +	struct xe_pcode_write writes[MAX_FAN_CONTROL_POINTS + 1];
> +	u32 accepted_count = 0;
> +	u32 point;
> +	int ret, write_ret, verify_ret;
> +
> +	if (point_count < MIN_FAN_CONTROL_POINTS ||
> +	    point_count > MAX_FAN_CONTROL_POINTS) {
> +		xe_err(hwmon->xe, "fan %d table needs %d-%d points, got %u\n", fan,
> +		       MIN_FAN_CONTROL_POINTS, MAX_FAN_CONTROL_POINTS, point_count);
> +		return -EINVAL;
> +	}
> +
> +	for (point = 0; point < point_count; point++) {
> +		u8 temp = points[point].temp;
> +		u8 speed = points[point].speed;
> +
> +		/* Firmware requires increasing temperature and non-decreasing speed. */
> +		if (point > 0) {
> +			u8 prev_temp = points[point - 1].temp;
> +			u8 prev_speed = points[point - 1].speed;
> +
> +			if (temp <= prev_temp || speed < prev_speed) {
> +				xe_dbg(hwmon->xe,
> +				       "fan %d point %u not monotonic: %u/%u%% after %u/%u%%\n",
> +				       fan, point, temp, speed, prev_temp, prev_speed);
> +				return -EINVAL;
> +			}
> +		}
> +
> +		/* Prepare the write for this fan control point */
> +		writes[point].mbox = PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_FAN_TABLE,
> +						fan);
> +		writes[point].data = FIELD_PREP(FAN_CONTROL_POINT_TEMP_MASK, temp) |
> +				FIELD_PREP(FAN_CONTROL_POINT_SPEED_MASK, speed);
> +	}
> +
> +	xe_dbg(hwmon->xe, "committing fan %d user table with %u points\n", fan, point_count);
> +
> +	/* pcode fills the user table from point 0 in write order; the count write commits it. */
> +	writes[point_count].mbox = PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_NUM_FAN_CONTROL_POINTS,
> +					      fan);
> +	writes[point_count].data = point_count;
> +
> +	write_ret = xe_pcode_write_batch(xe_device_get_root_tile(hwmon->xe), writes,
> +					 point_count + 1);
> +	if (write_ret)
> +		xe_err(hwmon->xe, "failed to write fan %d user table, ret=%d\n", fan, write_ret);
> +
> +	verify_ret = xe_hwmon_get_fan_point_count(hwmon, fan, &accepted_count, USER_FAN_TABLE);
> +	if (write_ret || verify_ret || accepted_count != point_count) {
> +		int failure_ret = write_ret ?: verify_ret ?: -EIO;
> +
> +		if (verify_ret || accepted_count != point_count)
> +			xe_err(hwmon->xe,
> +			       "fan %d table count verification failed: ret=%d, expected=%u, got=%u\n",
> +			       fan, verify_ret, point_count, accepted_count);
> +		/* Firmware may have accepted only part of the table; fall back to stock. */
> +		ret = xe_hwmon_fan_set_auto(hwmon, fan);
> +		if (ret)
> +			xe_err(hwmon->xe, "failed to restore fan %d to stock mode, ret=%d\n", fan,
> +			       ret);
> +		return failure_ret;
> +	}
> +
> +	xe_dbg(hwmon->xe, "fan %d user table committed successfully with %u points\n", fan,
> +	       point_count);
> +	return 0;
> +}
> +
> +/* Temperature to set when setting the fan PWM with pwm[1-3]. */
> +#define FIXED_PWM_TEMP	1
> +
> +static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm)
> +{
> +	struct xe_hwmon_fan_info *fi = &hwmon->fi[fan];
> +	struct fan_table *user_table = &fi->fan_table[USER_FAN_TABLE];
> +	struct fan_control_point points[MIN_FAN_CONTROL_POINTS];
> +	int ret, i;
> +	u8 speed;
> +
> +	/* Fan table speed are in percent. */
> +	speed = min_t(u32, DIV_ROUND_CLOSEST(pwm * 100, U8_MAX), 100);
> +
> +	/* Fan control needs at least two points; program them all at the same speed. */
> +	for (i = 0; i < MIN_FAN_CONTROL_POINTS; i++) {
> +		points[i].temp = FIXED_PWM_TEMP + i;
> +		points[i].speed = speed;
> +	}
> +
> +	ret = xe_hwmon_commit_user_fan_table(hwmon, fan, points, MIN_FAN_CONTROL_POINTS);
> +	if (ret) {
> +		xe_err(hwmon->xe, "failed to set pwm %u (%u%%) for fan %d, ret=%d\n",
> +		       pwm, speed, fan, ret);
> +		return ret;
> +	}
> +
> +	/* Update the user fan table cache. */
> +	memcpy(user_table->fcp, points, sizeof(points));
> +	user_table->point_count = MIN_FAN_CONTROL_POINTS;
> +	xe_dbg(hwmon->xe, "applied pwm %u (%u%%) for fan %d\n", pwm, speed, fan);
> +
> +	return 0;
> +}
> +
>   static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon)
>   {
>   	bool found = false;
> @@ -1795,6 +1955,22 @@ xe_hwmon_fan_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
>   	}
>   }
>   
> +static umode_t
> +xe_hwmon_pwm_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
> +{
> +	/* Manual control starts from the stock table, so it needs a usable curve. */
> +	if (!hwmon->xe->info.has_fan_control || !IS_FAN_ENABLED(hwmon, channel) ||
> +	    hwmon->fi[channel].fan_table[STOCK_FAN_TABLE].point_count < MIN_FAN_CONTROL_POINTS)
> +		return 0;
> +
> +	switch (attr) {
> +	case hwmon_pwm_input:
> +		return 0644;
> +	default:
> +		return 0;
> +	}
> +}
> +
>   static int
>   xe_hwmon_fan_input_read(struct xe_hwmon *hwmon, int channel, long *val)
>   {
> @@ -1848,6 +2024,185 @@ xe_hwmon_fan_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val)
>   	}
>   }
>   
> +/**
> + * xe_hwmon_get_stock_table_pwm - Calculate PWM from the stock fan curve
> + * @hwmon: hwmon instance, with hwmon_lock held and runtime PM active
> + * @channel: fan channel
> + * @val: calculated PWM percentage
> + *
> + * Read package temperature and linearly interpolate the stock table. Temperatures
> + * outside the table range use the speed at the nearest endpoint.
> + *
> + * Return: 0 on success, or a negative error code.
> + */
> +static int xe_hwmon_get_stock_table_pwm(struct xe_hwmon *hwmon, int channel, long *val)
> +{
> +	const struct fan_table *table = &hwmon->fi[channel].fan_table[STOCK_FAN_TABLE];
> +	long temperature, pwm;
> +	int point, ret;
> +
> +	lockdep_assert_held(&hwmon->hwmon_lock);
> +
> +	if (!table->point_count)
> +		return -ENODATA;
> +
> +	ret = xe_hwmon_temp_read(hwmon, hwmon_temp_input, CHANNEL_PKG, &temperature);
> +	if (ret)
> +		return ret;
> +
> +	pwm = table->fcp[0].speed;
> +	for (point = 1; point < table->point_count; point++) {
> +		const struct fan_control_point *lower = &table->fcp[point - 1];
> +		const struct fan_control_point *upper = &table->fcp[point];
> +		long lower_temp = lower->temp * MILLIDEGREE_PER_DEGREE;
> +		long upper_temp = upper->temp * MILLIDEGREE_PER_DEGREE;
> +		long pwm_delta = upper->speed - lower->speed;
> +
> +		/* Find the bracketing points; temperatures outside the curve use endpoints. */
> +		if (temperature <= lower_temp)
> +			break;
> +		if (temperature < upper_temp) {
> +			pwm += DIV_ROUND_CLOSEST(pwm_delta * (temperature - lower_temp),
> +						upper_temp - lower_temp);
> +			break;
> +		}
> +		pwm = upper->speed;
> +	}
> +
> +	*val = pwm;
> +	xe_dbg(hwmon->xe, "fan %d stock table active PWM value: %ld\n", channel, pwm);
> +	return 0;
> +}
> +
> +/**
> + * xe_hwmon_get_pwm_from_pmt - Read active fan PWM from PMT telemetry
> + * @hwmon: hwmon instance, with hwmon_lock held and runtime PM active
> + * @channel: fan channel
> + * @val: raw PWM percentage returned by PMT
> + *
> + * Return: 0 on success, or a negative error code.
> + */
> +static int xe_hwmon_get_pwm_from_pmt(struct xe_hwmon *hwmon, int channel, long *val)
> +{
> +	u64 pmt_val;
> +	u32 guid, pwm;
> +	int ret;
> +
> +	lockdep_assert_held(&hwmon->hwmon_lock);
> +
> +	if (hwmon->xe->info.platform != XE_BATTLEMAGE)
> +		return -EOPNOTSUPP;
> +
> +	ret = xe_vsec_get_guid(hwmon->xe, &guid);
> +	if (ret) {
> +		xe_warn(hwmon->xe, "failed to read pwm, PMT unavailable: %d\n", ret);
> +		return ret;
> +	}
> +
> +	ret = xe_pmt_telem_read(hwmon->xe->drm.dev, guid, &pmt_val,
> +				BMG_FAN_PWM_PMT_OFFSET, sizeof(pmt_val));
> +	if (ret != sizeof(pmt_val)) {
> +		xe_warn(hwmon->xe, "pwm read from PMT failed: %d\n", ret);
> +		return ret < 0 ? ret : -EIO;
> +	}
> +
> +	switch (channel) {
> +	case FAN_1:
> +		pwm = REG_FIELD_GET64(BMG_FAN1_PWM, pmt_val);
> +		break;
> +	case FAN_2:
> +		pwm = REG_FIELD_GET64(BMG_FAN2_PWM, pmt_val);
> +		break;
> +	case FAN_3:
> +		pwm = REG_FIELD_GET64(BMG_FAN3_PWM, pmt_val);
> +		break;
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +
> +	xe_dbg(hwmon->xe, "fan %d: active pwm from PMT: %u\n", channel, pwm);
> +
> +	*val = pwm;
> +	return 0;
> +}
> +
> +static int
> +xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val)
> +{
> +	struct xe_hwmon_fan_info *fi;
> +	long pwm;
> +	int ret = 0;
> +
> +	mutex_lock(&hwmon->hwmon_lock);
> +
> +	fi = &hwmon->fi[channel];
> +
> +	switch (attr) {
> +	case hwmon_pwm_input:
> +		/* If the user fan table is not populated, get active stock pwm */
> +		if (!fi->fan_table[USER_FAN_TABLE].point_count) {
> +			xe_dbg(hwmon->xe, "user fan table not active for fan %d\n", channel);
> +			switch (hwmon->xe->info.platform) {
> +			case XE_BATTLEMAGE:
> +				ret = xe_hwmon_get_pwm_from_pmt(hwmon, channel, &pwm);
> +				break;
> +			default:
> +				ret = xe_hwmon_get_stock_table_pwm(hwmon, channel, &pwm);
> +				break;
> +			}
> +			if (ret)
> +				goto unlock;
> +		} else {
> +			/*
> +			 * pwmN writes set every user-table point to the same speed,
> +			 * so the first point gives the cached manual PWM percentage.
> +			 */
> +			pwm = fi->fan_table[USER_FAN_TABLE].fcp[0].speed;
> +		}
> +		if (pwm < 0 || pwm > 100) {
> +			xe_dbg(hwmon->xe, "invalid PWM value %ld read for fan %d\n", pwm, channel);
> +			ret = -ERANGE;
> +			goto unlock;
> +		}
> +		/* Speed is cached in percent, so the 0..255 round trip may be off by a step. */
> +		*val = DIV_ROUND_CLOSEST(pwm * U8_MAX, 100);
> +		xe_dbg(hwmon->xe, "pwm read for fan %d: %ld\n", channel, *val);
> +		break;
> +	default:
> +		ret = -EOPNOTSUPP;
> +		break;
> +	}
> +
> +unlock:
> +	mutex_unlock(&hwmon->hwmon_lock);
> +	return ret;
> +}
> +
> +static int
> +xe_hwmon_pwm_write(struct xe_hwmon *hwmon, u32 attr, int channel, long val)
> +{
> +	int ret = 0;
> +
> +	mutex_lock(&hwmon->hwmon_lock);
> +
> +	switch (attr) {
> +	case hwmon_pwm_input:
> +		if (val < 0 || val > U8_MAX) {
> +			xe_dbg(hwmon->xe, "pwm %ld out of range for fan %d\n", val, channel);
> +			ret = -EINVAL;
> +			break;
> +		}
> +		ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, (u8)val);
> +		break;
> +	default:
> +		ret = -EOPNOTSUPP;
> +		break;
> +	}
> +	mutex_unlock(&hwmon->hwmon_lock);
> +
> +	return ret;
> +}
> +
>   static umode_t
>   xe_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_types type,
>   		    u32 attr, int channel)
> @@ -1874,6 +2229,9 @@ xe_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_types type,
>   	case hwmon_fan:
>   		ret = xe_hwmon_fan_is_visible(hwmon, attr, channel);
>   		break;
> +	case hwmon_pwm:
> +		ret = xe_hwmon_pwm_is_visible(hwmon, attr, channel);
> +		break;
>   	default:
>   		ret = 0;
>   		break;
> @@ -1903,6 +2261,8 @@ xe_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
>   		return xe_hwmon_energy_read(hwmon, attr, channel, val);
>   	case hwmon_fan:
>   		return xe_hwmon_fan_read(hwmon, attr, channel, val);
> +	case hwmon_pwm:
> +		return xe_hwmon_pwm_read(hwmon, attr, channel, val);
>   	default:
>   		return -EOPNOTSUPP;
>   	}
> @@ -1921,6 +2281,8 @@ xe_hwmon_write(struct device *dev, enum hwmon_sensor_types type, u32 attr,
>   		return xe_hwmon_power_write(hwmon, attr, channel, val);
>   	case hwmon_curr:
>   		return xe_hwmon_curr_write(hwmon, attr, channel, val);
> +	case hwmon_pwm:
> +		return xe_hwmon_pwm_write(hwmon, attr, channel, val);
>   	default:
>   		return -EOPNOTSUPP;
>   	}
> diff --git a/drivers/gpu/drm/xe/xe_pcode_api.h b/drivers/gpu/drm/xe/xe_pcode_api.h
> index 2308e5464082..bf321ed19251 100644
> --- a/drivers/gpu/drm/xe/xe_pcode_api.h
> +++ b/drivers/gpu/drm/xe/xe_pcode_api.h
> @@ -86,9 +86,12 @@
>   #define     MEMORY_CONFIG_SUBCOMMAND_READ_MAX_FREQUENCY 0x1
>   
>   #define   FAN_SPEED_CONTROL			0x7D
> +#define     FSC_WRITE_NUM_FAN_CONTROL_POINTS	0x0
> +#define     FSC_WRITE_FAN_TABLE			0x1
>   #define     FSC_READ_MAX_FAN_RPS		0x3
>   #define     FSC_READ_NUM_FANS			0x4
>   #define     FSC_READ_STOCK_FAN_CONTROL_POINTS	0x5
> +#define     FSC_READ_USER_FAN_CONTROL_POINTS	0x6
>   #define     FSC_READ_FAN_TABLE			0x7
>   #define     FAN_CONTROL_POINT_TEMP_MASK		REG_GENMASK(7, 0)
>   #define     FAN_CONTROL_POINT_SPEED_MASK	REG_GENMASK(15, 8)
LGTM:

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

  reply	other threads:[~2026-12-02 19:53 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 [this message]
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

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=6ce477cc-06af-4b27-85e2-564adb441eff@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.