gdp-fan hwmon driver support
Feature Request
If requesting support for a new device, see this Doc Page first.
Description
This is a feature ticket based on a previously submitted untemplated issue: #545 (closed)
I'm reproducing here to see if others are interested in proper fan controls for this hardware. (hand-held devices) Please upvote if interested.
In short: This driver does expose fan contrls, but has non-standard behavior requiring special handling. Currently in CC, it will show them as uncontrollable rpm-only fans.
Driver support issue and analysis:
-
The driver at boot/by default sets the pwm_enable value to 2 (auto). This is inline with pretty much all hwmon drivers. CC uses that value because it's already been set by the BIOS as the default.
-
What's unusual about this driver, and what makes this difficult for most fan control software on Linux, is:
Many boards (except listed under wm2 above) don't support reading the current pwm value in auto mode. That will just return EOPNOTSUPP. In manual mode it will always return the real value.
Notice the emphasis on "READING" the fan duty in auto mode. This behavior is different to all other drivers that I'm aware of. Many hwmon driver implementations have dealt with this issue explicitly, and use cached values for reliable user-space usage. Additionally, it says "many boards", meaning not all boards using this driver have this behavior, which makes things slightly more complicated. The thinkpad hwmon driver, as well as many other laptop drivers, are an example where the hardware doesn't report a fan duty in auto mode as well, but the driver either reports 255 (default) or the last applied speed so that pwm is always readable. That behavior is semi-standard and this driver diverges from that.
-
Ideally, this would be handled upstream in the driver itself, but I'm currently unsure of the author's possibilities around that - that and changing the driver behavior afterwards isn't always easy.
-
To properly handle this behavior without an upstream change, and keep auto mode still available for users, will require emulating the behavior of what the other hwmon drivers do and cache the pwm value with a default value. Keeping auto mode available is a good feature to have, and I think especially for these devices in particular.
-
That is not a minor change to implement properly. Additionally, monitoring the fan duty value becomes difficult if the device only sometimes reports values.
-
The solution the OP implemented, in essence, disables auto mode for all hwmon devices. Forcing manual mode for all hwmon devices is ok for a quick fix, but ofc not as a general solution. Note: one can also disable auto-mode per fan channel without any code changes by setting the pwmN_enable value to 1 before CC starts. CC then does not know that 2/auto is an available setting for the driver.
-
Some explanation of CC startup and hwmon fan channels:
CC uses the existing pwmN_enable value at startup as the default value for the channel. (Default Profile) During initialization, CC does a few tests to make sure the driver allows fan controls and then sets it back to the default value before finishing up initialization or applying any user settings. The warning being output in the logs reflects the driver's behavior, in that the pwm channel is not readable when in auto/default mode. That normally means that fan controls are not available for that channel. It is normal however, that pwmN is not writable when in auto mode, which is fine and standard behavior. It's the read error behavior that makes this non-standard.
Info from OP:
# echo 2 > /sys/class/hwmon/hwmon2/pwm1_enable && cat /sys/class/hwmon/hwmon2/pwm1
cat: /sys/class/hwmon/hwmon2/pwm1: Operation not supported
Jan 11 05:01:52 p4 .coolercontrold-wrapped[336740]: Uncontrollable RPM-only fan found at /sys/class/hwmon/hwmon2/fan1_input
"gpdfan":{"locations":\["/sys/class/hwmon/hwmon2","/sys/devices/platform/gpd_fan","platform:gpd_fan"\],"driver name":\["gpd_fan"\],"driver version":\["6.18.3"\]}
Possible Solutions
- The simplest solution here seems to be to use a default pwm value (probably 255) for gdp_fan drivers when they return Operation Not Permitted.
Add a