[PATCH 2/2] drm/nouveau/hwmon: hide pwm1_enable and make pwm1 read-only when fan mode is unavailable
From: Jakub Ludera via B4 Relay
Date: Sun Dec 06 2026 - 06:25:01 EST
From: Jakub Ludera <jakub_ludera@xxxxxxx>
When fan management is controlled by the GPU's VBIOS/PREOS PMU
firmware, nvkm_therm_fan_mode() rejects software mode changes and
leaves NVKM_THERM_ATTR_FAN_MODE at -1 (NVKM_THERM_CTRL_NONE).
Exposing -1 through pwm1_enable violates the hwmon sysfs ABI, and
exposing pwm1 as writable when mode is -1 causes all writes to fail
with -EINVAL. Check NVKM_THERM_ATTR_FAN_MODE in
nouveau_pwm_is_visible() to hide pwm1_enable and expose pwm1 as
read-only (0444) when software fan mode control is unavailable.
Signed-off-by: Jakub Ludera <jakub_ludera@xxxxxxx>
---
drivers/gpu/drm/nouveau/nouveau_hwmon.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
index 726397ab035d..264b1f028d47 100644
--- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
@@ -297,15 +297,19 @@ nouveau_pwm_is_visible(const void *data, u32 attr, int channel)
{
struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
struct nvkm_therm *therm = nvxx_therm(drm);
+ int mode;
if (!therm || !therm->attr_get || !therm->fan_get ||
therm->fan_get(therm) < 0)
return 0;
+ mode = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE);
+
switch (attr) {
case hwmon_pwm_enable:
+ return mode < 0 ? 0 : 0644;
case hwmon_pwm_input:
- return 0644;
+ return mode < 0 ? 0444 : 0644;
default:
return 0;
}
--
2.56.1