hwmon: add HP WMI Sensors driver
James Seo
maintainerPATCH v4 1/1 hwmon: add HP WMI Sensors driver
Hewlett-Packard (and some HP Compaq) business-class computers report hardware monitoring information via WMI. This driver exposes that information to hwmon.
Initial support is provided for temperature, fan speed, and intrusion sensor types. Provisional support is provided for voltage and current sensor types.
HP's WMI implementation permits many other types of numeric sensors. Therefore, a debugfs interface is also provided to enumerate and inspect all numeric sensors visible on the WMI side. This should facilitate adding support for other sensor types in the future.
Tested on a HP Z420, a HP EliteOne 800 G1, and a HP Compaq Elite 8300 SFF.
Note that provisionally supported sensor types are untested and seem to be rare-to-nonexistent in the wild, having been encountered neither on test systems nor in ACPI dumps from the Linux Hardware Database. They are included because their popularity in general makes their presence on past or future HP systems plausible and because no doubt exists as to how the sensors themselves would be represented in WMI (alarm attributes will need to wait for hardware to be located). A 2005 HP whitepaper gives the relevant sensor object MOF definition and sensor value scaling calculation, and both this driver and the official HP Performance Advisor utility comply with them (confirmed in the latter case by reverse engineering).
---
Changes in v4:
* Address reviewer comments
- Use devm_add_action_or_reset() to replace two uses of devm_add_action()
- Add a function to find WMI object instance count to prepare for upcoming changes in the WMI driver core
- Dynamically allocate some arrays in driver state and make requisite changes to debugfs implementation
* Cleanups and minor changes
- Free WMI object instance earlier to get rid of a goto
- Remove unused is_active member from sensor info struct
- Fix channel type count overcalculation
- Fix typo in comment
* Remove fields from driver state struct not needed after init and make requisite changes to init procedure
* Reword commit message
Changes in v3:
* Address reviewer comments
- Filter out only disconnected sensors
- Remove unnecessary GUID check
- Add comment about HP's odd choice of fan RPM sensor type
- Detect fault condition in a more nuanced manner
- Change format string for debugfs root directory name
- Don't have an else branch after return in an if statement
- Don't goto a return statement without cleanup before it
- Remove unused pointer from driver state struct
* Cleanups and minor changes
- Add support for "Temperature Index" Celsius sensors
- Adjust a goto to avoid an unnecessary call to kfree()
- Trim strings received from WMI
- Reword help entry in Kconfig
* Implement temperature, fan, and intrusion alarm attributes
* Expose "platform events" used for alarms in debugfs
* Significantly rework driver initialization
* Update commit message
* Update documentation
Changes in v2:
* Cleanups and minor changes
- Remove stray #include
- Use DIV_ROUND_CLOSEST in F to C conversion
- Consolidate uses of mutex_lock()/mutex_unlock()
- Process sensors in forward order by type
* Update commit message
* Update documentation
History:
v3: https://lore.kernel.org/linux-hwmon/[email protected]/
v2: https://lore.kernel.org/linux-hwmon/[email protected]/
v1: https://lore.kernel.org/linux-hwmon/[email protected]/
--- Documentation/hwmon/hp-wmi-sensors.rst | 137 ++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 7 + drivers/hwmon/Kconfig | 12 + drivers/hwmon/Makefile | 1 + drivers/hwmon/hp-wmi-sensors.c | 1887 ++++++++++++++++++++++++ 6 files changed, 2045 insertions(+) create mode 100644 Documentation/hwmon/hp-wmi-sensors.rst create mode 100644 drivers/hwmon/hp-wmi-sensors.c
Documentation/hwmon/hp-wmi-sensors.rst new file +137 -0
@@ -0,0 +1,137 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +.. include:: <isonum.txt> + +Linux HP WMI Sensors Driver +=========================== + +:Copyright: |copy| 2023 James Seo <[email protected]> + +Description +----------- + +Hewlett-Packard (and some HP Compaq) business-class computers report hardware +monitoring information via Windows Management Instrumentation (WMI). This +driver exposes that information to the Linux ``hwmon`` subsystem, allowing +userspace utilities like ``sensors`` to gather numeric sensor readings. + +``sysfs`` interface +------------------- + +When the driver is loaded, it discovers the sensors available on the current +system and creates the following ``sysfs`` attributes as necessary within +``/sys/class/hwmon/hwmon[X]``: + +(``[X]`` is some number that depends on other system components.) + +======================= ======= =================================== +Name Perm Description +======================= ======= =================================== +curr[X]_input RO Current in milliamperes (mA). +curr[X]_label RO Current sensor label. +fan[X]_input RO Fan speed in RPM. +fan[X]_label RO Fan sensor label. +fan[X]_fault RO Fan sensor fault indicator. +fan[X]_alarm RO Fan sensor alarm indicator. +in[X]_input RO Voltage in millivolts (mV). +in[X]_label RO Voltage sensor label. +temp[X]_input RO Temperature in millidegrees Celsius + (m\ |deg|\ C). +temp[X]_label RO Temperature sensor label. +temp[X]_fault RO Temperature sensor fault indicator. +temp[X]_alarm RO Temperature sensor alarm indicator. +intrusion[X]_alarm RW Chassis intrusion alarm indicator. +======================= ======= =================================== + +``fault`` attributes + Reading ``1`` instead of ``0`` as the ``fault`` attribute for a sensor + indicates that it has encountered some issue during operation such that + measurements from it should not be trusted. If a sensor with the fault + condition later recovers, reading this attribute will return ``0`` again. + +``alarm`` attributes + Reading ``1`` instead of ``0`` as the ``alarm`` attribute for a sensor + indicates that one of the following has occurred, depending on its type: + + - ``fan``: The fan has stalled or been disconnected while running. + - ``temp``: The sensor reading has reached a critical threshold. The exact + threshold is system-dependent. + - ``intrusion``: The system's chassis has been opened. + + After ``1`` is read from an ``alarm`` attribute, the attribute resets itself + and returns ``0`` on subsequent reads. As an exception, an + ``intrusion[X]_alarm`` can only be manually reset by writing ``0`` to it. + +``debugfs`` interface +--------------------- + +.. warning:: The ``debugfs`` interface is only available when the kernel is + compiled with option ``CONFIG_DEBUG_FS``, and is subject to + change without notice at any time. + +The standard ``hwmon`` interface in ``sysfs`` exposes sensors of several +common types that are connected as of driver initialization. However, there +are usually other sensors on the WMI side that do not meet these criteria. +In addition, a number of system-dependent "platform events" used for ``alarm`` +attributes may be present. A ``debugfs`` interface is therefore provided for +read-only access to *all* HP WMI sensors and platform events on the system. + +``/sys/kernel/debug/hp-wmi-sensors-[X]/sensor`` +contains one numbered entry per sensor with the following attributes: + +=============================== ======================================= +Name Example +=============================== ======================================= +name ``CPU0 Fan`` +description ``Reports CPU0 fan speed`` +sensor_type ``12`` +other_sensor_type (an empty string) +operational_status ``2`` +current_state ``Normal`` +possible_states ``Normal,Caution,Critical,Not Present`` +base_units ``19`` +unit_modifier ``0`` +current_reading ``1008`` +=============================== ======================================= + +``/sys/kernel/debug/hp-wmi-sensors-[X]/platform_events`` +contains one numbered entry per platform event with the following attributes: + +=============================== ==================== +Name Example +=============================== ==================== +name ``CPU0 Fan Stall`` +description ``CPU0 Fan Speed`` +source_namespace ``root\wmi`` +source_class ``HPBIOS_BIOSEvent`` +category ``3`` +possible_severity ``25`` +possible_status ``5`` +=============================== ==================== + +These represent the properties of the underlying ``HPBIOS_BIOSNumericSensor`` +and ``HPBIOS_PlatformEvents`` WMI objects, which vary between systems. See +[#]_ for more details, including Managed Object Format (MOF) definitions. + +Known issues and limitations +---------------------------- + +- If the existing ``hp-wmi`` driver for non-business-class HP systems is + already loaded, ``alarm`` attributes will be unavailable. This is because + the same WMI event GUID used by this driver for ``alarm`` attributes is + used on those systems for e.g. laptop hotkeys. +- Dubious sensor hardware and inconsistent system WMI implementations have + been observed to cause inaccurate readings and peculiar behavior, such as + alarms failing to occur or occurring only once per boot. +- Only temperature, fan speed, and intrusion sensor types have been seen in + the wild so far. Support for voltage and current sensors is therefore + provisional. +- Although HP WMI sensors may claim to be of any type, any oddball sensor + types unknown to hwmon will not be supported. + +References +---------- + +.. [#] Hewlett-Packard Development Company, L.P., + "HP Client Management Interface Technical White Paper", 2005. [Online]. + Available: https://h20331.www2.hp.com/hpsub/downloads/cmi_whitepaper.pdf
Documentation/hwmon/index.rst +1 -0
@@ -78,6 +78,7 @@ Hardware Monitoring Kernel Drivers gl518sm gxp-fan-ctrl hih6130 + hp-wmi-sensors ibmaem ibm-cffps ibmpowernv
MAINTAINERS +7 -0
@@ -9436,6 +9436,13 @@ L: [email protected] S: Orphan F: drivers/platform/x86/hp/tc1100-wmi.c +HP WMI HARDWARE MONITOR DRIVER +M: James Seo <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/hp-wmi-sensors.rst +F: drivers/hwmon/hp-wmi-sensors.c + HPET: High Precision Event Timers driver M: Clemens Ladisch <[email protected]> S: Maintained
drivers/hwmon/Kconfig +12 -0
@@ -2409,6 +2409,18 @@ config SENSORS_ASUS_EC This driver can also be built as a module. If so, the module will be called asus_ec_sensors. +config SENSORS_HP_WMI + tristate "HP WMI Sensors" + depends on ACPI_WMI + help + If you say yes here you get support for the ACPI hardware monitoring + interface found in HP (and some HP Compaq) business-class computers. + Available sensors vary between systems. Temperature and fan speed + sensors are the most common. + + This driver can also be built as a module. If so, the module + will be called hp_wmi_sensors. + endif # ACPI endif # HWMON
drivers/hwmon/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_SENSORS_ACPI_POWER) += acpi_power_meter.o obj-$(CONFIG_SENSORS_ATK0110) += asus_atk0110.o obj-$(CONFIG_SENSORS_ASUS_EC) += asus-ec-sensors.o obj-$(CONFIG_SENSORS_ASUS_WMI) += asus_wmi_sensors.o +obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o # Native drivers # asb100, then w83781d go first, as they can override other drivers' addresses.
drivers/hwmon/hp-wmi-sensors.c new file +1887 -0
1,887 lines not on this page · raw message
base-commit: d7b3ffe2d7e476f11d73b74093006aa936f59e8b
Signature · 1 line
2.34.1