Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Adds experimental manual fan RPM target control for HP Victus board 8A3D by extending the existing hp-wmi hwmon interface to expose standard fan*_target/fan*_max attributes and a manual pwm1_enable=1 mode.
Changes:
- Introduces a per-hwmon-device private state to track target/max RPM and the selected PWM mode.
- Exposes
fan1_target,fan2_target,fan1_max, andfan2_maxconditionally (board8A3Dorforce_manual_fan_control). - Implements a firmware write path for applying clamped RPM targets via
HPWMI_FAN_SPEED_SET_QUERY, and extendspwm1_enablehandling to support manual mode.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| module_param(force_manual_fan_control, bool, 0644); | ||
| MODULE_PARM_DESC(force_manual_fan_control, | ||
| "Expose experimental fan_target manual fan control"); |
| static int hp_wmi_fan_speed_set_targets(struct hp_wmi_hwmon_priv *priv) | ||
| { | ||
| u8 fan_speed[HPWMI_FAN_COUNT]; | ||
| int ret; | ||
|
|
||
| fan_speed[HPWMI_CPU_FAN] = DIV_ROUND_CLOSEST(priv->target_rpm[HPWMI_CPU_FAN], 100); | ||
| fan_speed[HPWMI_GPU_FAN] = DIV_ROUND_CLOSEST(priv->target_rpm[HPWMI_GPU_FAN], 100); | ||
|
|
||
| ret = hp_wmi_get_fan_count_userdefine_trigger(); | ||
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| ret = hp_wmi_fan_speed_max_set(0); | ||
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_SET_QUERY, HPWMI_GM, | ||
| &fan_speed, sizeof(fan_speed), 0); | ||
| if (ret) | ||
| return ret < 0 ? ret : -EINVAL; |
| static int hp_wmi_apply_manual_fan_target(struct hp_wmi_hwmon_priv *priv, | ||
| int fan, long rpm) | ||
| { | ||
| if (!hp_wmi_manual_fan_control_available()) | ||
| return -EOPNOTSUPP; | ||
| if (fan < 0 || fan >= HPWMI_FAN_COUNT) | ||
| return -EINVAL; | ||
|
|
||
| priv->target_rpm[fan] = hp_wmi_clamp_fan_target(fan, rpm); | ||
| return hp_wmi_fan_speed_set_targets(priv); | ||
| } |
| if (hp_wmi_manual_fan_control_available() && | ||
| priv->fan_mode == HPWMI_PWM_MANUAL) { | ||
| *val = HPWMI_PWM_MANUAL; | ||
| return 0; | ||
| } | ||
| switch (hp_wmi_fan_speed_max_get()) { | ||
| case 0: | ||
| /* 0 is automatic fan, which is 2 for hwmon */ | ||
| *val = 2; | ||
| priv->fan_mode = HPWMI_PWM_AUTO; | ||
| *val = HPWMI_PWM_AUTO; | ||
| return 0; |
| case hwmon_pwm: | ||
| switch (val) { | ||
| case 0: | ||
| if (is_victus_s_thermal_profile()) | ||
| hp_wmi_get_fan_count_userdefine_trigger(); | ||
| /* 0 is no fan speed control (max), which is 1 for us */ | ||
| return hp_wmi_fan_speed_max_set(1); | ||
| ret = hp_wmi_fan_speed_max_set(1); | ||
| if (!ret) | ||
| priv->fan_mode = HPWMI_PWM_MAX; | ||
| return ret; | ||
| case 1: | ||
| if (!hp_wmi_manual_fan_control_available()) | ||
| return -EOPNOTSUPP; | ||
| return hp_wmi_fan_speed_set_targets(priv); | ||
| case 2: | ||
| /* 2 is automatic speed control, which is 0 for us */ | ||
| if (is_victus_s_thermal_profile()) { | ||
| hp_wmi_get_fan_count_userdefine_trigger(); | ||
| return hp_wmi_fan_speed_max_reset(); | ||
| } else | ||
| return hp_wmi_fan_speed_max_set(0); | ||
| ret = hp_wmi_fan_speed_max_reset(); | ||
| } else { | ||
| ret = hp_wmi_fan_speed_max_set(0); | ||
| } | ||
| if (!ret) | ||
| priv->fan_mode = HPWMI_PWM_AUTO; | ||
| return ret; | ||
| default: |
|
Closing this because the active upstream is the Linux kernel, and manual Victus fan control has already landed there via the platform-drivers-x86 v7.0 pull. The accepted mainline implementation exposes the standard hwmon PWM interface (/) rather than the interface from this experimental DKMS patch.\n\nRelevant upstream references:\n- platform/x86 pull includes hp-wmi manual fan control and keep-alive: https://www.spinics.net/lists/platform-driver-x86/msg58776.html\n- Linus merge: https://linux.googlesource.com/linux/kernel/git/torvalds/linux/+/f50822fd8675c68d294e89bd102f7b487ca3acd3\n |
|
Correction to my previous comment: shell quoting stripped the inline code names. Closing this because the active upstream is the Linux kernel, and manual Victus fan control has already landed there via the platform-drivers-x86 v7.0 pull. The accepted mainline implementation exposes the standard hwmon PWM interface ( Relevant upstream references:
|
Summary
Add experimental manual fan RPM target control for HP Victus board
8A3Dthrough the existing hp-wmi hwmon device.This exposes standard hwmon fan target attributes:
fan1_targetfan2_targetfan1_maxfan2_maxIt also accepts
pwm1_enable=1as manual mode, while preserving the existing mappings:pwm1_enable=0: max fanpwm1_enable=2: automatic fan controlNotes
The implementation uses the existing
HPWMI_FAN_SPEED_SET_QUERYpath and keeps manual fan control gated to board8A3D, with an opt-inforce_manual_fan_controlmodule parameter for testing other systems.Requested RPM values are clamped to conservative board-specific bounds before being converted to the firmware payload values.
Validation
Tested on:
8A3DF.227.0.3-1-cachyos-bore-ltoBuild validation:
make -C src KERNELDIR=/lib/modules/$(uname -r)/build LLVM=1 CC=clangRuntime validation after installing and reloading
hp_wmi:Observed both
fan1_targetandfan2_target, and userspace probe reported direct fan control available.