修改hp-wmi 驱动实现对HP Victus 16-r0xxx 的风扇与性能控制

我在惠普光影精灵上安装Arch Linux,发现无法读取或控制风扇转速,由于电脑主板控制风扇转速相应比较慢,这导致高负载场景下容易出现处理器到90 C°才紧急提高风扇转速问题,同时独立显卡功耗锁在 80 W,没法做到像 windows 系统上开启性能模式那样使用 120 w 显卡功率,我推测是内核驱动暂不支持我使用的电脑。

这周我用 hp linux wmi fan control 等关键词搜索时找到了一个项目 omen-fan-control,这个项目通过对内核驱动 hp-wmi 打补丁,包含内核驱动“添加 victus S 模组手动控制风扇”相关提交,我下载omen-fan-control 中的内核模块hp-wmi, dkms.conf 与 Makefile,然后用 PKGBUILD 做一个dkms软件包安装在系统上,但是失败了。经过对内核日志检查发现 hp_wmi 模块未识别到我的设备,我使用 dmidecode 命令获取了Victus 16-r0xxx的DMI 主板名字 为 8BC2,在驱动hp-wmi.c 做修改从而让驱动识别我的设备。

355行下面
        /* DMI Board names of Victus 16-r0xxx laptops. */
        {
          .matches = {DMI_MATCH(DMI_BOARD_NAME, "8BC2")},
          .driver_data = (void *)&omen_v1_thermal_params,
        },

我在 Windows系统上测试发现电脑负责性能控制 EC 地址为0x59, 其中值0x30 表示均衡/节能,0x31 表示高性能,因此选择 HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET 作为热配置参数,修改驱动后使用 makepkg制作软件包,安装后重启,发现sensors 出现风扇转速读数,同时在终端模拟器 kitty 中执行 cat /sys/firmware/acpi/platform_profile_choices 发现可用选项 low-power balanced performance,使用tuned + tuned-ppd 管理电源并切换到性能模式后成功让显卡功率上限提升到 120 W。

hp-isa-0000
Adapter: ISA adapter
fan1:        1600 RPM
fan2:        1600 RPM
pwm1:             35%  MANUAL CONTROL

spd5118-i2c-11-52
Adapter: SMBus I801 adapter at 0000:00:1f.4
temp1:        +40.8°C  (low  =  +0.0°C, high = +55.0°C)
                       (crit low =  +0.0°C, crit = +85.0°C)

ucsi_source_psy_USBC000:001-isa-0000
Adapter: ISA adapter
in0:           0.00 V  (min =  +0.00 V, max =  +0.00 V)
curr1:         0.00 A  (max =  +0.00 A)

nvme-pci-0200
Adapter: PCI adapter
Composite:    +33.9°C  (low  = -273.1°C, high = +84.8°C)
                       (crit = +84.8°C)
Sensor 1:     +33.9°C  (low  = -273.1°C, high = +65261.8°C)
Sensor 2:     +34.9°C  (low  = -273.1°C, high = +65261.8°C)

BAT1-acpi-0
Adapter: ACPI interface
in0:          12.75 V  
power1:        0.00 W  

iwlwifi_1-virtual-0
Adapter: Virtual device
temp1:            N/A  

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +40.0°C  (high = +100.0°C, crit = +100.0°C)
Core 0:        +38.0°C  (high = +100.0°C, crit = +100.0°C)
Core 4:        +36.0°C  (high = +100.0°C, crit = +100.0°C)
Core 8:        +38.0°C  (high = +100.0°C, crit = +100.0°C)
Core 12:       +34.0°C  (high = +100.0°C, crit = +100.0°C)
Core 16:       +37.0°C  (high = +100.0°C, crit = +100.0°C)
Core 20:       +33.0°C  (high = +100.0°C, crit = +100.0°C)
Core 24:       +36.0°C  (high = +100.0°C, crit = +100.0°C)
Core 28:       +38.0°C  (high = +100.0°C, crit = +100.0°C)
Core 32:       +36.0°C  (high = +100.0°C, crit = +100.0°C)
Core 33:       +36.0°C  (high = +100.0°C, crit = +100.0°C)
Core 34:       +36.0°C  (high = +100.0°C, crit = +100.0°C)
Core 35:       +36.0°C  (high = +100.0°C, crit = +100.0°C)
Core 36:       +35.0°C  (high = +100.0°C, crit = +100.0°C)
Core 37:       +35.0°C  (high = +100.0°C, crit = +100.0°C)
Core 38:       +35.0°C  (high = +100.0°C, crit = +100.0°C)
Core 39:       +35.0°C  (high = +100.0°C, crit = +100.0°C)

spd5118-i2c-11-50
Adapter: SMBus I801 adapter at 0000:00:1f.4
temp1:        +41.0°C  (low  =  +0.0°C, high = +55.0°C)
                       (crit low =  +0.0°C, crit = +85.0°C)

nvme-pci-0900
Adapter: PCI adapter
Composite:    +40.9°C  (low  = -273.1°C, high = +89.8°C)
                       (crit = +94.8°C)
Sensor 1:     +40.9°C  (low  = -273.1°C, high = +65261.8°C)
Sensor 2:     +35.9°C  (low  = -273.1°C, high = +65261.8°C)

acpitz-acpi-0
Adapter: ACPI interface
temp1:        +27.8°C  
temp2:        +10.0°C  

针对新增 DMI 信息这部分内容,可以参考下方commit制作个补丁,提交至上游,后续就无需自行单独维护。

我现在不知道怎么用邮件向内核提交补丁,网络上的教材暂时没看明白

用git send-email就好啦。