hwmon: Add fan monitoring support for HONOR FMI-XX
Subsystems (3)
RFC PATCH 1/1 hwmon: Add fan monitoring support for HONOR FMI-XX
The HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
--- Documentation/hwmon/honor-fmi.rst | 32 +++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 7 ++ drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/honor-fmi.c | 195 ++++++++++++++++++++++++++++++ 6 files changed, 246 insertions(+) create mode 100644 Documentation/hwmon/honor-fmi.rst create mode 100644 drivers/hwmon/honor-fmi.c
Documentation/hwmon/honor-fmi.rst new file +32 -0
@@ -0,0 +1,32 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver honor-fmi +======================= + +Supported systems: + + * HONOR FMI-XX + +Author: Nikita Dubrovskih <[email protected]> + +Description +----------- + +The driver provides read-only monitoring of the fan speed on the HONOR FMI-XX. +The system firmware implements a ``GFNS`` ACPI method which returns the speed +of one of two firmware fan channels in RPM. Embedded Controller access and +serialization are handled by the firmware method. + +The driver does not expose fan control or direct Embedded Controller access. + +Sysfs entries +------------- + +The following attributes are supported: + +======================= ======= ============================================= +Name Perm Description +======================= ======= ============================================= +``fan1_input`` RO Fan channel 0 speed in RPM +``fan2_input`` RO Fan channel 1 speed in RPM +======================= ======= =============================================
Documentation/hwmon/index.rst +1 -0
@@ -90,6 +90,7 @@ Hardware Monitoring Kernel Drivers gxp-fan-ctrl hac300s hih6130 + honor-fmi hp-wmi-sensors hs3001 htu31
MAINTAINERS +7 -0
@@ -11854,6 +11854,13 @@ F: lib/test_hmm* F: mm/hmm* F: tools/testing/selftests/mm/*hmm* +HONOR FMI-XX HARDWARE MONITOR DRIVER +M: Nikita Dubrovskih <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/honor-fmi.rst +F: drivers/hwmon/honor-fmi.c + HONEYWELL ABP2030PA PRESSURE SENSOR SERIES IIO DRIVER M: Petre Rodan <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +10 -0
@@ -2785,6 +2785,16 @@ 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_HONOR_FMI + tristate "HONOR FMI-XX fan monitor" + depends on X86 + help + If you say yes here, you get support for fan speed monitoring on + the HONOR FMI-XX laptop through its firmware ACPI method. + + This driver can also be built as a module. If so, the module + will be called honor-fmi. + config SENSORS_HP_WMI tristate "HP WMI Sensors" depends on ACPI_WMI
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_HONOR_FMI) += honor-fmi.o obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o # Native drivers
drivers/hwmon/honor-fmi.c new file +195 -0
195 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] The function `honor_fmi_read_rpm` illegally mixes `goto`-based error handling with a scoped…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] The function honor_fmi_read_rpm illegally mixes goto-based error handling with a scoped guard(mutex) lock.
- [Low] The new entry in the MAINTAINERS file is inserted out of alphabetical order.
--
--- Patch [1]: [RFC PATCH] hwmon: Add fan monitoring support for HONOR FMI-XX --- commit 8d90c25d369a88a7d4700de11f8a23c2eaf15bbc
Author: Nikita Dubrovskih <[email protected]>
hwmon: Add fan monitoring support for HONOR FMI-XX
This patch introduces a read-only hwmon driver for HONOR FMI-XX laptops. It queries fan speeds using the firmware-provided \GFNS ACPI method and exposes the results via sysfs.
Quoted 6 lines
MAINTAINERS +0
-0@@ -11854,6 +11854,13 @@ F: lib/test_hmm* F: mm/hmm*
MAINTAINERS F: lib/test_hmm* · line 11864
Quoted 10 lines
MAINTAINERS +7
-0F: tools/testing/selftests/mm/*hmm* +HONOR FMI-XX HARDWARE MONITOR DRIVER +M: Nikita Dubrovskih <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/honor-fmi.rst +F: drivers/hwmon/honor-fmi.c + HONEYWELL ABP2030PA PRESSURE SENSOR SERIES IIO DRIVER
[Severity: Low]
This isn't a bug, but should this new entry be placed after HONEYWELL?
Alphabetically, "HONOR" comes after "HONEYWELL" (O follows E), so inserting it here breaks the alphabetical order of the MAINTAINERS file.
[ ... ]
Quoted 5 lines
drivers/hwmon/honor-fmi.c new file +0
-0
[ ... ]
Quoted 35 lines
drivers/hwmon/honor-fmi.c new file +35
-0+static int honor_fmi_read_rpm (struct honor_fmi_data *data,int channel, +long *rpm) +{ +union acpi_object input = { + .buffer = { + .type =ACPI_TYPE_BUFFER , + .length =3 , + }, + }; +struct acpi_object_list arguments = { + .count =1 , + .pointer = &input, + }; +struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *result; +u8 input_bytes[3 ] = {0 ,0 , channel }; +acpi_status status; +int ret =0 ; + + input.buffer.pointer = input_bytes; + +guard (mutex)(&data->lock); + status =acpi_evaluate_object (data->gfns,NULL , &arguments, &output); +if (ACPI_FAILURE (status)) +return -EIO ; + + result = output.pointer; +if (!result || result->type !=ACPI_TYPE_BUFFER || + result->buffer.length <HONOR_FMI_GFNS_RESULT_SIZE ) { + ret = -EPROTO ; + goto out_free; + } + +if (result->buffer.pointer[0 ]) { + ret = -EIO ;
drivers/hwmon/honor-fmi.c line 84
Quoted 10 lines
drivers/hwmon/honor-fmi.c new file +10
-0+ goto out_free; + } + + *rpm = result->buffer.pointer[1 ] | + (result->buffer.pointer[2 ] <<8 ); + +out_free: +kfree (output.pointer); +return ret; +}
[Severity: Low]
Does this function mix goto-based error handling with scope-based cleanups?
The cleanup subsystem guidelines request that guard() helpers and goto-based cleanups are not mixed in the same function.
Could the output buffer be managed using __free(kfree) to completely eliminate the out_free label?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Guenter Roeck
maintainerQuoted 142 lines · Nikita Dubrovskih
The HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
Signed-off-by Nikita Dubrovskih <[email protected]>--- Documentation/hwmon/honor-fmi.rst | 32 +++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 7 ++ drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/honor-fmi.c | 195 ++++++++++++++++++++++++++++++ 6 files changed, 246 insertions(+)create mode 100644
Documentation/hwmon/honor-fmi.rstcreate mode 100644drivers/hwmon/honor-fmi.cDocumentation/hwmon/honor-fmi.rst new file +32
-0@@ -0,0 +1,32 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver honor-fmi +======================= + +Supported systems: + + * HONOR FMI-XX + +Author: Nikita Dubrovskih <[email protected]> + +Description +----------- + +The driver provides read-only monitoring of the fan speed on the HONOR FMI-XX. +The system firmware implements a ``GFNS`` ACPI method which returns the speed +of one of two firmware fan channels in RPM. Embedded Controller access and +serialization are handled by the firmware method. + +The driver does not expose fan control or direct Embedded Controller access. + +Sysfs entries +------------- + +The following attributes are supported: + +======================= ======= ============================================= +Name Perm Description +======================= ======= ============================================= +``fan1_input`` RO Fan channel 0 speed in RPM +``fan2_input`` RO Fan channel 1 speed in RPM +======================= ======= =============================================Documentation/hwmon/index.rst +1
-0@@ -90,6 +90,7 @@ Hardware Monitoring Kernel Drivers gxp-fan-ctrl hac300s hih6130 + honor-fmi hp-wmi-sensors hs3001 htu31MAINTAINERS +7
-0@@ -11854,6 +11854,13 @@ F: lib/test_hmm* F: mm/hmm* F: tools/testing/selftests/mm/*hmm* +HONOR FMI-XX HARDWARE MONITOR DRIVER +M: Nikita Dubrovskih <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/honor-fmi.rst +F: drivers/hwmon/honor-fmi.c + HONEYWELL ABP2030PA PRESSURE SENSOR SERIES IIO DRIVER M: Petre Rodan <[email protected]> L: [email protected]drivers/hwmon/Kconfig +10
-0@@ -2785,6 +2785,16 @@ 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_HONOR_FMI + tristate "HONOR FMI-XX fan monitor" + depends on X86 + help + If you say yes here, you get support for fan speed monitoring on + the HONOR FMI-XX laptop through its firmware ACPI method. + + This driver can also be built as a module. If so, the module + will be called honor-fmi. + config SENSORS_HP_WMI tristate "HP WMI Sensors" depends on ACPI_WMIdrivers/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_HONOR_FMI) += honor-fmi.o obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o # Native driversdrivers/hwmon/honor-fmi.c new file +11
-0@@ -0,0 +1,195 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Read-only fan monitoring for the HONOR FMI-XX. +* +* The firmware-provided \GFNS ACPI method accepts a three-byte buffer. +* Byte 2 selects fan 0 or 1. It returns a status byte followed by a +* little-endian 16-bit fan speed in RPM. The method owns all Embedded +* Controller access and serialization; this driver deliberately exposes no +* fan control interface. +*/ +
drivers/hwmon/honor-fmi.c line 21
Quoted 10 lines
drivers/hwmon/honor-fmi.c new file +10
-0+#include <linux/acpi.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/hwmon.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/platform_device.h> + +#define HONOR_FMI_FAN_COUNT 2 +#define HONOR_FMI_GFNS_RESULT_SIZE 3
#define<space>NAME<tab>value
and align value, please.
drivers/hwmon/honor-fmi.c line 26
Quoted 5 lines
drivers/hwmon/honor-fmi.c new file +5
-0+ +struct honor_fmi_data { +acpi_handle gfns; +/* Serialize firmware method evaluation. */ +struct mutex lock;
I do not see why this lock would be needed on top of the hardware monitoring subsystem lock.
Quoted 56 lines
drivers/hwmon/honor-fmi.c new file +56
-0+}; + +static const struct dmi_system_id honor_fmi_dmi_table[] = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"HONOR" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"FMI-XX" ), + }, + }, + {} +}; +MODULE_DEVICE_TABLE (dmi, honor_fmi_dmi_table); + +static int honor_fmi_read_rpm (struct honor_fmi_data *data,int channel, +long *rpm) +{ +union acpi_object input = { + .buffer = { + .type =ACPI_TYPE_BUFFER , + .length =3 , + }, + }; +struct acpi_object_list arguments = { + .count =1 , + .pointer = &input, + }; +struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *result; +u8 input_bytes[3 ] = {0 ,0 , channel }; +acpi_status status; +int ret =0 ; + + input.buffer.pointer = input_bytes; + +guard (mutex)(&data->lock); + status =acpi_evaluate_object (data->gfns,NULL , &arguments, &output); +if (ACPI_FAILURE (status)) +return -EIO ; + + result = output.pointer; +if (!result || result->type !=ACPI_TYPE_BUFFER || + result->buffer.length <HONOR_FMI_GFNS_RESULT_SIZE ) { + ret = -EPROTO ; + goto out_free; + } + +if (result->buffer.pointer[0 ]) { + ret = -EIO ; + goto out_free; + } + + *rpm = result->buffer.pointer[1 ] | + (result->buffer.pointer[2 ] <<8 ); + +out_free: +kfree (output.pointer);
drivers/hwmon/honor-fmi.c line 92
Quoted 10 lines
drivers/hwmon/honor-fmi.c new file +10
-0+return ret; +} + +static umode_t honor_fmi_is_visible (const void *data, +enum hwmon_sensor_types type,u32 attr, +int channel) +{ +if (type == hwmon_fan && attr == hwmon_fan_input && + channel <HONOR_FMI_FAN_COUNT ) +return 0444 ;
Unnecessary check. Just return 0444.
drivers/hwmon/honor-fmi.c line 104
Quoted 12 lines
drivers/hwmon/honor-fmi.c new file +12
-0+ +return 0 ; +} + +static int honor_fmi_read (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long *value) +{ +struct honor_fmi_data *data =dev_get_drvdata (dev); + +if (type != hwmon_fan || attr != hwmon_fan_input || + channel >=HONOR_FMI_FAN_COUNT ) +return -EOPNOTSUPP ;
Unnecessary check.
Quoted 29 lines
drivers/hwmon/honor-fmi.c new file +29
-0+ +return honor_fmi_read_rpm (data, channel, value); +} + +static const struct hwmon_ops honor_fmi_hwmon_ops = { + .is_visible = honor_fmi_is_visible, + .read = honor_fmi_read, +}; + +static const struct hwmon_channel_info *const honor_fmi_hwmon_info[] = { +HWMON_CHANNEL_INFO (fan,HWMON_F_INPUT ,HWMON_F_INPUT ), +NULL +}; + +static const struct hwmon_chip_info honor_fmi_chip_info = { + .ops = &honor_fmi_hwmon_ops, + .info = honor_fmi_hwmon_info, +}; + +static int honor_fmi_probe (struct platform_device *pdev) +{ +struct honor_fmi_data *data; +struct device *hwmon_dev; +acpi_status status; + +if (!dmi_check_system (honor_fmi_dmi_table)) +return -ENODEV ; + + data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );
drivers/hwmon/honor-fmi.c line 143
Quoted 10 lines
drivers/hwmon/honor-fmi.c new file +10
-0+if (!data) +return -ENOMEM ; + + status =acpi_get_handle (NULL ,"\\GFNS" , &data->gfns); +if (ACPI_FAILURE (status)) +return dev_err_probe (&pdev->dev, -ENODEV , +"firmware does not provide \\GFNS\n" ); + +mutex_init (&data->lock); +platform_set_drvdata (pdev, data);
I do not see where this is used or needed.
Quoted 25 lines
drivers/hwmon/honor-fmi.c new file +25
-0+ + hwmon_dev =devm_hwmon_device_register_with_info (&pdev->dev,"honor_fmi" , + data, + &honor_fmi_chip_info, +NULL ); +return PTR_ERR_OR_ZERO (hwmon_dev); +} + +static struct platform_driver honor_fmi_driver = { + .probe = honor_fmi_probe, + .driver = { + .name ="honor-fmi-hwmon" , + }, +}; + +static struct platform_device *honor_fmi_device; + +static int __init honor_fmi_init (void ) +{ +int ret; + +if (!dmi_check_system (honor_fmi_dmi_table)) +return -ENODEV ; + + ret =platform_driver_register (&honor_fmi_driver);
drivers/hwmon/honor-fmi.c line 178
Quoted 10 lines
drivers/hwmon/honor-fmi.c new file +10
-0+if (ret) +return ret; + + honor_fmi_device =platform_device_register_simple ("honor-fmi-hwmon" , +PLATFORM_DEVID_NONE , +NULL ,0 ); +if (IS_ERR (honor_fmi_device)) { + ret =PTR_ERR (honor_fmi_device); +platform_driver_unregister (&honor_fmi_driver); +return ret;
No need to assign the error to ret.
return PTR_ERR(honor_fmi_device);> + }
Quoted 16 lines
drivers/hwmon/honor-fmi.c new file +16
-0+ +return 0 ; +} + +static void __exit honor_fmi_exit(void) +{ +platform_device_unregister (honor_fmi_device); +platform_driver_unregister (&honor_fmi_driver); +} + +module_init (honor_fmi_init); +module_exit (honor_fmi_exit); + +MODULE_AUTHOR ("Nikita Dubrovskih <[email protected]>" ); +MODULE_DESCRIPTION ("HONOR FMI-XX fan speed monitor" ); +MODULE_LICENSE ("GPL" );
RFC PATCH v2 1/1 hwmon: Add fan monitoring support for HONOR FMI-XX
In reply to Nikita DubrovskihThe HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
---
Changes in v2:
- Drop the redundant mutex and callback argument validation.
- Remove unused platform drvdata and simplify the init error path.
- Align the macro definition and order the MAINTAINERS entry.
Documentation/hwmon/honor-fmi.rst | 32 ++++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 7 ++ drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/honor-fmi.c | 178 ++++++++++++++++++++++++++++++ 6 files changed, 229 insertions(+) create mode 100644 Documentation/hwmon/honor-fmi.rst create mode 100644 drivers/hwmon/honor-fmi.c
Documentation/hwmon/honor-fmi.rst new file +32 -0
@@ -0,0 +1,32 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver honor-fmi +======================= + +Supported systems: + + * HONOR FMI-XX + +Author: Nikita Dubrovskih <[email protected]> + +Description +----------- + +The driver provides read-only monitoring of the fan speed on the HONOR FMI-XX. +The system firmware implements a ``GFNS`` ACPI method which returns the speed +of one of two firmware fan channels in RPM. Embedded Controller access and +serialization are handled by the firmware method. + +The driver does not expose fan control or direct Embedded Controller access. + +Sysfs entries +------------- + +The following attributes are supported: + +======================= ======= ============================================= +Name Perm Description +======================= ======= ============================================= +``fan1_input`` RO Fan channel 0 speed in RPM +``fan2_input`` RO Fan channel 1 speed in RPM +======================= ======= =============================================
Documentation/hwmon/index.rst +1 -0
@@ -90,6 +90,7 @@ Hardware Monitoring Kernel Drivers gxp-fan-ctrl hac300s hih6130 + honor-fmi hp-wmi-sensors hs3001 htu31
MAINTAINERS +7 -0
@@ -11876,6 +11876,13 @@ S: Maintained F: Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml F: drivers/iio/pressure/mprls0025pa* +HONOR FMI-XX HARDWARE MONITOR DRIVER +M: Nikita Dubrovskih <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/honor-fmi.rst +F: drivers/hwmon/honor-fmi.c + HP BIOSCFG DRIVER M: Jorge Lopez <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +10 -0
@@ -2785,6 +2785,16 @@ 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_HONOR_FMI + tristate "HONOR FMI-XX fan monitor" + depends on X86 + help + If you say yes here, you get support for fan speed monitoring on + the HONOR FMI-XX laptop through its firmware ACPI method. + + This driver can also be built as a module. If so, the module + will be called honor-fmi. + config SENSORS_HP_WMI tristate "HP WMI Sensors" depends on ACPI_WMI
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_HONOR_FMI) += honor-fmi.o obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o # Native drivers
drivers/hwmon/honor-fmi.c new file +178 -0
178 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
The HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
Quoted 5 lines
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
Signed-off-by Nikita Dubrovskih <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Guenter Roeck
maintainerQuoted 8 lines · Nikita Dubrovskih
The HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
Quoted 6 lines
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
Signed-off-by Nikita Dubrovskih <[email protected]>---
Looks ok. I do not have any further comments.
This is an RFC, so I won't apply it.
Thanks,
Guenter
Quoted 300 lines
Changes in v2:
- Drop the redundant mutex and callback argument validation.
- Remove unused platform drvdata and simplify the init error path.
- Align the macro definition and order theMAINTAINERSentry.Documentation/hwmon/honor-fmi.rst | 32 ++++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 7 ++ drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/honor-fmi.c | 178 ++++++++++++++++++++++++++++++ 6 files changed, 229 insertions(+) create mode 100644 Documentation/hwmon/honor-fmi.rst create mode 100644 drivers/hwmon/honor-fmi.cDocumentation/hwmon/honor-fmi.rst new file +32
-0@@ -0,0 +1,32 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver honor-fmi +======================= + +Supported systems: + + * HONOR FMI-XX + +Author: Nikita Dubrovskih <[email protected]> + +Description +----------- + +The driver provides read-only monitoring of the fan speed on the HONOR FMI-XX. +The system firmware implements a ``GFNS`` ACPI method which returns the speed +of one of two firmware fan channels in RPM. Embedded Controller access and +serialization are handled by the firmware method. + +The driver does not expose fan control or direct Embedded Controller access. + +Sysfs entries +------------- + +The following attributes are supported: + +======================= ======= ============================================= +Name Perm Description +======================= ======= ============================================= +``fan1_input`` RO Fan channel 0 speed in RPM +``fan2_input`` RO Fan channel 1 speed in RPM +======================= ======= =============================================Documentation/hwmon/index.rst +1
-0@@ -90,6 +90,7 @@ Hardware Monitoring Kernel Drivers gxp-fan-ctrl hac300s hih6130 + honor-fmi hp-wmi-sensors hs3001 htu31MAINTAINERS +7
-0@@ -11876,6 +11876,13 @@ S: Maintained F: Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml F: drivers/iio/pressure/mprls0025pa* +HONOR FMI-XX HARDWARE MONITOR DRIVER +M: Nikita Dubrovskih <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/honor-fmi.rst +F: drivers/hwmon/honor-fmi.c + HP BIOSCFG DRIVER M: Jorge Lopez <[email protected]> L: [email protected]drivers/hwmon/Kconfig +10
-0@@ -2785,6 +2785,16 @@ 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_HONOR_FMI + tristate "HONOR FMI-XX fan monitor" + depends on X86 + help + If you say yes here, you get support for fan speed monitoring on + the HONOR FMI-XX laptop through its firmware ACPI method. + + This driver can also be built as a module. If so, the module + will be called honor-fmi. + config SENSORS_HP_WMI tristate "HP WMI Sensors" depends on ACPI_WMIdrivers/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_HONOR_FMI) += honor-fmi.o obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o # Native driversdrivers/hwmon/honor-fmi.c new file +178
-0@@ -0,0 +1,178 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Read-only fan monitoring for the HONOR FMI-XX. +* +* The firmware-provided \GFNS ACPI method accepts a three-byte buffer. +* Byte 2 selects fan 0 or 1. It returns a status byte followed by a +* little-endian 16-bit fan speed in RPM. The method owns all Embedded +* Controller access and serialization; this driver deliberately exposes no +* fan control interface. +*/ + +#include <linux/acpi.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/hwmon.h> +#include <linux/module.h> +#include <linux/platform_device.h> + +#define HONOR_FMI_GFNS_RESULT_SIZE 3 + +struct honor_fmi_data { +acpi_handle gfns; +}; + +static const struct dmi_system_id honor_fmi_dmi_table[] = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"HONOR" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"FMI-XX" ), + }, + }, + {} +}; +MODULE_DEVICE_TABLE (dmi, honor_fmi_dmi_table); + +static int honor_fmi_read_rpm (struct honor_fmi_data *data,int channel, +long *rpm) +{ +union acpi_object input = { + .buffer = { + .type =ACPI_TYPE_BUFFER , + .length =3 , + }, + }; +struct acpi_object_list arguments = { + .count =1 , + .pointer = &input, + }; +struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *result; +u8 input_bytes[3 ] = {0 ,0 , channel }; +acpi_status status; +int ret =0 ; + + input.buffer.pointer = input_bytes; + + status =acpi_evaluate_object (data->gfns,NULL , &arguments, &output); +if (ACPI_FAILURE (status)) +return -EIO ; + + result = output.pointer; +if (!result || result->type !=ACPI_TYPE_BUFFER || + result->buffer.length <HONOR_FMI_GFNS_RESULT_SIZE ) { + ret = -EPROTO ; + goto out_free; + } + +if (result->buffer.pointer[0 ]) { + ret = -EIO ; + goto out_free; + } + + *rpm = result->buffer.pointer[1 ] | + (result->buffer.pointer[2 ] <<8 ); + +out_free: +kfree (output.pointer); +return ret; +} + +static umode_t honor_fmi_is_visible (const void *data, +enum hwmon_sensor_types type,u32 attr, +int channel) +{ +return 0444 ; +} + +static int honor_fmi_read (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long *value) +{ +struct honor_fmi_data *data =dev_get_drvdata (dev); + +return honor_fmi_read_rpm (data, channel, value); +} + +static const struct hwmon_ops honor_fmi_hwmon_ops = { + .is_visible = honor_fmi_is_visible, + .read = honor_fmi_read, +}; + +static const struct hwmon_channel_info *const honor_fmi_hwmon_info[] = { +HWMON_CHANNEL_INFO (fan,HWMON_F_INPUT ,HWMON_F_INPUT ), +NULL +}; + +static const struct hwmon_chip_info honor_fmi_chip_info = { + .ops = &honor_fmi_hwmon_ops, + .info = honor_fmi_hwmon_info, +}; + +static int honor_fmi_probe (struct platform_device *pdev) +{ +struct honor_fmi_data *data; +struct device *hwmon_dev; +acpi_status status; + +if (!dmi_check_system (honor_fmi_dmi_table)) +return -ENODEV ; + + data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + status =acpi_get_handle (NULL ,"\\GFNS" , &data->gfns); +if (ACPI_FAILURE (status)) +return dev_err_probe (&pdev->dev, -ENODEV , +"firmware does not provide \\GFNS\n" ); + + hwmon_dev =devm_hwmon_device_register_with_info (&pdev->dev,"honor_fmi" , + data, + &honor_fmi_chip_info, +NULL ); +return PTR_ERR_OR_ZERO (hwmon_dev); +} + +static struct platform_driver honor_fmi_driver = { + .probe = honor_fmi_probe, + .driver = { + .name ="honor-fmi-hwmon" , + }, +}; + +static struct platform_device *honor_fmi_device; + +static int __init honor_fmi_init (void ) +{ +int ret; + +if (!dmi_check_system (honor_fmi_dmi_table)) +return -ENODEV ; + + ret =platform_driver_register (&honor_fmi_driver); +if (ret) +return ret; + + honor_fmi_device =platform_device_register_simple ("honor-fmi-hwmon" , +PLATFORM_DEVID_NONE , +NULL ,0 ); +if (IS_ERR (honor_fmi_device)) { +platform_driver_unregister (&honor_fmi_driver); +return PTR_ERR (honor_fmi_device); + } + +return 0 ; +} + +static void __exit honor_fmi_exit(void) +{ +platform_device_unregister (honor_fmi_device); +platform_driver_unregister (&honor_fmi_driver); +} + +module_init (honor_fmi_init); +module_exit (honor_fmi_exit); + +MODULE_AUTHOR ("Nikita Dubrovskih <[email protected]>" ); +MODULE_DESCRIPTION ("HONOR FMI-XX fan speed monitor" ); +MODULE_LICENSE ("GPL" );
PATCH v3 1/1 hwmon: Add fan monitoring support for HONOR FMI-XX
In reply to Nikita DubrovskihThe HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
---
Changes in v3:
- Drop the RFC tag following maintainer review; no code changes.
Changes in v2:
- Drop the redundant mutex and callback argument validation.
- Remove unused platform drvdata and simplify the init error path.
- Align the macro definition and order the MAINTAINERS entry.
Documentation/hwmon/honor-fmi.rst | 32 ++++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 7 ++ drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/honor-fmi.c | 178 ++++++++++++++++++++++++++++++ 6 files changed, 229 insertions(+) create mode 100644 Documentation/hwmon/honor-fmi.rst create mode 100644 drivers/hwmon/honor-fmi.c
Documentation/hwmon/honor-fmi.rst new file +32 -0
@@ -0,0 +1,32 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver honor-fmi +======================= + +Supported systems: + + * HONOR FMI-XX + +Author: Nikita Dubrovskih <[email protected]> + +Description +----------- + +The driver provides read-only monitoring of the fan speed on the HONOR FMI-XX. +The system firmware implements a ``GFNS`` ACPI method which returns the speed +of one of two firmware fan channels in RPM. Embedded Controller access and +serialization are handled by the firmware method. + +The driver does not expose fan control or direct Embedded Controller access. + +Sysfs entries +------------- + +The following attributes are supported: + +======================= ======= ============================================= +Name Perm Description +======================= ======= ============================================= +``fan1_input`` RO Fan channel 0 speed in RPM +``fan2_input`` RO Fan channel 1 speed in RPM +======================= ======= =============================================
Documentation/hwmon/index.rst +1 -0
@@ -90,6 +90,7 @@ Hardware Monitoring Kernel Drivers gxp-fan-ctrl hac300s hih6130 + honor-fmi hp-wmi-sensors hs3001 htu31
MAINTAINERS +7 -0
@@ -11876,6 +11876,13 @@ S: Maintained F: Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml F: drivers/iio/pressure/mprls0025pa* +HONOR FMI-XX HARDWARE MONITOR DRIVER +M: Nikita Dubrovskih <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/honor-fmi.rst +F: drivers/hwmon/honor-fmi.c + HP BIOSCFG DRIVER M: Jorge Lopez <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +10 -0
@@ -2785,6 +2785,16 @@ 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_HONOR_FMI + tristate "HONOR FMI-XX fan monitor" + depends on X86 + help + If you say yes here, you get support for fan speed monitoring on + the HONOR FMI-XX laptop through its firmware ACPI method. + + This driver can also be built as a module. If so, the module + will be called honor-fmi. + config SENSORS_HP_WMI tristate "HP WMI Sensors" depends on ACPI_WMI
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_HONOR_FMI) += honor-fmi.o obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o # Native drivers
drivers/hwmon/honor-fmi.c new file +178 -0
178 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The `SENSORS_HONOR_FMI` Kconfig option is missing a dependency on `ACPI`. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The SENSORS_HONOR_FMI Kconfig option is missing a dependency on ACPI. --
--- Patch [1]: [PATCH v3] hwmon: Add fan monitoring support for HONOR FMI-XX --- commit 049ec54bdd36a31d06eb1fb6aa8b9f74bd2a4a59
Author: Nikita Dubrovskih <[email protected]>
hwmon: Add fan monitoring support for HONOR FMI-XX
The HONOR FMI-XX firmware exposes a serialized \GFNS ACPI method to return fan speeds. This commit adds a DMI-restricted, read-only hwmon driver to monitor these speeds, without exposing direct Embedded Controller access.
Quoted 4 lines
drivers/hwmon/Kconfig +0
-0
[ ... ]
drivers/hwmon/Kconfig config SENSORS_ASUS_EC · line 2790
Quoted 7 lines
drivers/hwmon/Kconfig +3
-0@@ -2785,6 +2785,16 @@ 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_HONOR_FMI + tristate "HONOR FMI-XX fan monitor" + depends on X86
[Severity: Low]
Does this Kconfig entry need a dependency on ACPI?
Without CONFIG_ACPI, ACPICA core functions like acpi_get_handle() are replaced with static inline stubs that return AE_NOT_CONFIGURED. This means the driver probe function will unconditionally fail with -ENODEV, and the driver effectively becomes dead code when configured this way.
Quoted 3 lines
drivers/hwmon/Kconfig +3
-0+ help + If you say yes here, you get support for fan speed monitoring on + the HONOR FMI-XX laptop through its firmware ACPI method.
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v4 1/1 hwmon: Add fan monitoring support for HONOR FMI-XX
In reply to Nikita DubrovskihThe HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
---
Changes in v4:
- Add the missing ACPI dependency to the Kconfig entry.
Changes in v3:
- Drop the RFC tag following maintainer review; no code changes.
Changes in v2:
- Drop the redundant mutex and callback argument validation.
- Remove unused platform drvdata and simplify the init error path.
- Align the macro definition and order the MAINTAINERS entry.
Documentation/hwmon/honor-fmi.rst | 32 ++++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 7 ++ drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/honor-fmi.c | 178 ++++++++++++++++++++++++++++++ 6 files changed, 229 insertions(+) create mode 100644 Documentation/hwmon/honor-fmi.rst create mode 100644 drivers/hwmon/honor-fmi.c
Documentation/hwmon/honor-fmi.rst new file +32 -0
@@ -0,0 +1,32 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver honor-fmi +======================= + +Supported systems: + + * HONOR FMI-XX + +Author: Nikita Dubrovskih <[email protected]> + +Description +----------- + +The driver provides read-only monitoring of the fan speed on the HONOR FMI-XX. +The system firmware implements a ``GFNS`` ACPI method which returns the speed +of one of two firmware fan channels in RPM. Embedded Controller access and +serialization are handled by the firmware method. + +The driver does not expose fan control or direct Embedded Controller access. + +Sysfs entries +------------- + +The following attributes are supported: + +======================= ======= ============================================= +Name Perm Description +======================= ======= ============================================= +``fan1_input`` RO Fan channel 0 speed in RPM +``fan2_input`` RO Fan channel 1 speed in RPM +======================= ======= =============================================
Documentation/hwmon/index.rst +1 -0
@@ -90,6 +90,7 @@ Hardware Monitoring Kernel Drivers gxp-fan-ctrl hac300s hih6130 + honor-fmi hp-wmi-sensors hs3001 htu31
MAINTAINERS +7 -0
@@ -11876,6 +11876,13 @@ S: Maintained F: Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml F: drivers/iio/pressure/mprls0025pa* +HONOR FMI-XX HARDWARE MONITOR DRIVER +M: Nikita Dubrovskih <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/honor-fmi.rst +F: drivers/hwmon/honor-fmi.c + HP BIOSCFG DRIVER M: Jorge Lopez <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +10 -0
@@ -2785,6 +2785,16 @@ 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_HONOR_FMI + tristate "HONOR FMI-XX fan monitor" + depends on X86 && ACPI + help + If you say yes here, you get support for fan speed monitoring on + the HONOR FMI-XX laptop through its firmware ACPI method. + + This driver can also be built as a module. If so, the module + will be called honor-fmi. + config SENSORS_HP_WMI tristate "HP WMI Sensors" depends on ACPI_WMI
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_HONOR_FMI) += honor-fmi.o obj-$(CONFIG_SENSORS_HP_WMI) += hp-wmi-sensors.o # Native drivers
drivers/hwmon/honor-fmi.c new file +178 -0
178 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
The HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
Quoted 5 lines
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
Signed-off-by Nikita Dubrovskih <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Guenter Roeck
maintainerQuoted 8 lines · Nikita Dubrovskih
The HONOR FMI-XX firmware exposes a serialized \\GFNS ACPI method. It returns a status byte and a 16-bit fan speed in RPM for either of two firmware channels.
Add a DMI-restricted, read-only hwmon driver using that firmware interface. The driver deliberately exposes no fan control or direct Embedded Controller access.
Quoted 5 lines
The interface was validated on firmware 1.09 with fan channel 0 reporting approximately 2500-2800 RPM. Channel 1 is readable and remained at 0 RPM during idle and a short CPU load.
Signed-off-by Nikita Dubrovskih <[email protected]>
Queued for 7.4.
Thanks,
Guenter