Skip to contentSkip to conversation

PATCH v4 ASUS EC Sensors

PATCH Superseded Eugene Shalygin 4 participants 11 messages Jan 11, 2022 – Jan 16, 2022

Subsystems (3)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Eugene Shalygin

author maintainer
#0 lore raw

This patchset replaces the HWMON asus_wmi_ec_sensors driver with an implementation that does not use WMI but queries the embedded controller directly.

That provides two enhancements: sensor reading became quicker (on some systems or kernel configuration it took almost a full second to read all the sensors, that transfers less than 15 bytes of data), the driver became more fexible. The driver now relies on ACPI mutex to lock access to the EC, in the same way as the WMI DSDT code does.

Chenges in v5:
- Place the sensors bitset directly into the driver_data field of the dmi_system_id struct.
- Replace doc comments with regular ones.

Changes in v4:
- Deprecate the wmi driver rather than removing it.

Changes in v3:
- Remove BIOS version checks and BIOS version dependent mutex path.

Changes in v2:
- Replace sensor flags enum with bitset
- Replace module init/probe functions with module_platform_driver_probe and ask the platform drivers framework to load the driver when ACPI EC is found (ACPI ID "PNP0C09").
- Extend board data with BIOS version attribute for the mutex path to be BIOS version dependent.
- Add module parameter to override the mutex path.

author maintainer
#1 lore raw

PATCH v5 1/3 hwmon: (asus-ec-sensors) add driver for ASUS EC

This driver provides the same data as the asus_wmi_ec_sensors driver (and gets it from the same source) but does not use WMI, polling the ACPI EC directly.

That provides two enhancements: sensor reading became quicker (on some systems or kernel configuration it took almost a full second to read all the sensors, that transfers less than 15 bytes of data), the driver became more flexible. The driver now relies on ACPI mutex to lock access to the EC in the same way as the WMI code does.

---
 MAINTAINERS                     |   6 +
 drivers/hwmon/Kconfig           |  11 +
 drivers/hwmon/Makefile          |   1 +
 drivers/hwmon/asus-ec-sensors.c | 691 ++++++++++++++++++++++++++++++++
 4 files changed, 709 insertions(+)
 create mode 100644 drivers/hwmon/asus-ec-sensors.c
MAINTAINERS +6 -0
index fddd28d3db15..845f09bc0457 100644
@@ -3012,6 +3012,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/hwmon/asus_wmi_ec_sensors.c
 
+ASUS EC HARDWARE MONITOR DRIVER
+M:	Eugene Shalygin <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/hwmon/asus-ec-sensors.c
+
 ASUS WIRELESS RADIO CONTROL DRIVER
 M:	João Paulo Rechi Vita <[email protected]>
 L:	[email protected]
drivers/hwmon/Kconfig +11 -0
index 43e5245874ad..2c16b19d2c03 100644
@@ -2253,6 +2253,17 @@ config SENSORS_ASUS_WMI_EC
 	  This driver can also be built as a module. If so, the module
 	  will be called asus_wmi_sensors_ec.
 
+config SENSORS_ASUS_EC
+	tristate "ASUS EC Sensors"
+	help
+	  If you say yes here you get support for the ACPI embedded controller
+	  hardware monitoring interface found in ASUS motherboards. The driver
+	  currently supports B550/X570 boards, although other ASUS boards might
+	  provide this monitoring interface as well.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called asus_ec_sensors.
+
 endif # ACPI
 
 endif # HWMON
drivers/hwmon/Makefile +1 -0
index 3a1551b3d570..2e5c216bb5d7 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_HWMON_VID)		+= hwmon-vid.o
 # APCI drivers
 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_ASUS_WMI_EC)	+= asus_wmi_ec_sensors.o
 
drivers/hwmon/asus-ec-sensors.c new file +691 -0

691 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v5 2/3 hwmon: (asus-ec-sensors) update documentation

In reply to Eugene Shalygin
---
 Documentation/hwmon/asus_ec_sensors.rst     | 51 +++++++++++++++++++++
 Documentation/hwmon/asus_wmi_ec_sensors.rst | 38 ---------------
 2 files changed, 51 insertions(+), 38 deletions(-)
 create mode 100644 Documentation/hwmon/asus_ec_sensors.rst
 delete mode 100644 Documentation/hwmon/asus_wmi_ec_sensors.rst
Documentation/hwmon/asus_ec_sensors.rst new file +51 -0
new file mode 100644
index 000000000000..b8820cd1bd62
@@ -0,0 +1,51 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+Kernel driver asus_ec_sensors
+=================================
+
+Supported boards:
+ * PRIME X570-PRO,
+ * Pro WS X570-ACE,
+ * ROG CROSSHAIR VIII DARK HERO,
+ * ROG CROSSHAIR VIII FORMULA,
+ * ROG CROSSHAIR VIII HERO,
+ * ROG CROSSHAIR VIII IMPACT,
+ * ROG STRIX B550-E GAMING,
+ * ROG STRIX B550-I GAMING,
+ * ROG STRIX X570-E GAMING,
+ * ROG STRIX X570-I GAMING
+
+Authors:
+    - Eugene Shalygin <[email protected]>
+
+Description:
+------------
+ASUS mainboards publish hardware monitoring information via Super I/O
+chip and the ACPI embedded controller (EC) registers. Some of the sensors
+are only available via the EC.
+
+The driver is aware of and reads the following sensors:
+
+1. Chipset (PCH) temperature
+2. CPU package temperature
+3. Motherboard temperature
+4. Readings from the T_Sensor header
+5. VRM temperature
+6. CPU_Opt fan RPM
+7. VRM heatsink fan RPM
+8. Chipset fan RPM
+9. Readings from the "Water flow meter" header (RPM)
+10. Readings from the "Water In" and "Water Out" temperature headers
+11. CPU current
+
+Sensor values are read from EC registers, and to avoid race with the board
+firmware the driver acquires ACPI mutex, the one used by the WMI when its
+methods access the EC.
+
+Module Parameters
+-----------------
+ * mutex_path: string
+		The driver holds path to the ACPI mutex for each board (actually,
+		the path is mostly identical for them). If ASUS changes this path
+		in a future BIOS update, this parameter can be used to override
+		the stored in the driver value until it gets updated.
Documentation/hwmon/asus_wmi_ec_sensors.rst deleted +0 -38
deleted file mode 100644
index 1b287f229e86..000000000000
@@ -1,38 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0-or-later
-
-Kernel driver asus_wmi_ec_sensors
-=================================
-
-Supported boards:
- * PRIME X570-PRO,
- * Pro WS X570-ACE,
- * ROG CROSSHAIR VIII DARK HERO,
- * ROG CROSSHAIR VIII FORMULA,
- * ROG CROSSHAIR VIII HERO,
- * ROG STRIX B550-E GAMING,
- * ROG STRIX B550-I GAMING,
- * ROG STRIX X570-E GAMING.
-
-Authors:
-    - Eugene Shalygin <[email protected]>
-
-Description:
-------------
-ASUS mainboards publish hardware monitoring information via Super I/O
-chip and the ACPI embedded controller (EC) registers. Some of the sensors
-are only available via the EC.
-
-ASUS WMI interface provides a method (BREC) to read data from EC registers,
-which is utilized by this driver to publish those sensor readings to the
-HWMON system. The driver is aware of and reads the following sensors:
-
-1. Chipset (PCH) temperature
-2. CPU package temperature
-3. Motherboard temperature
-4. Readings from the T_Sensor header
-5. VRM temperature
-6. CPU_Opt fan RPM
-7. Chipset fan RPM
-8. Readings from the "Water flow meter" header (RPM)
-9. Readings from the "Water In" and "Water Out" temperature headers
-10. CPU current
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH v5 3/3 hwmon: deprecate asis_wmi_ec_sensors driver

In reply to Eugene Shalygin
---
 drivers/hwmon/Kconfig | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/Kconfig +4 -1
index 2c16b19d2c03..5e693c93d43a 100644
@@ -2243,13 +2243,16 @@ config SENSORS_ASUS_WMI
 
 config SENSORS_ASUS_WMI_EC
 	tristate "ASUS WMI B550/X570"
-	depends on ACPI_WMI
+	depends on ACPI_WMI && !SENSORS_ASUS_EC
 	help
 	  If you say yes here you get support for the ACPI embedded controller
 	  hardware monitoring interface found in B550/X570 ASUS motherboards.
 	  This driver will provide readings of fans, voltages and temperatures
 	  through the system firmware.
 
+	  This driver is deprecated in favor of the ASUS EC Sensors driver
+	  which provides fully compatible output.
+
 	  This driver can also be built as a module. If so, the module
 	  will be called asus_wmi_sensors_ec.
 
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v5 3/3] hwmon: deprecate asis_wmi_ec_sensors driver

Hello.

Quoted 9 lines · On úterý 11. ledna 2022 19:03:46 CET Eugene Shalygin wrote:
---
 drivers/hwmon/Kconfig | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/Kconfig +0 -0
index 2c16b19d2c03..5e693c93d43a 100644

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI · line 2246

Quoted 5 lines
drivers/hwmon/Kconfig +1 -1
@@ -2243,13 +2243,16 @@ config SENSORS_ASUS_WMI
 
 config SENSORS_ASUS_WMI_EC
 	tristate "ASUS WMI B550/X570"
-	depends on ACPI_WMI
+	depends on ACPI_WMI && !SENSORS_ASUS_EC

Not sure how it handles SENSORS_ASUS_EC=m. Probably, it should be:

```
depends on ACPI_WMI && SENSORS_ASUS_EC=n
```

?

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI · line 2257

Quoted 11 lines
drivers/hwmon/Kconfig +3 -0
 	help
 	  If you say yes here you get support for the ACPI embedded controller
 	  hardware monitoring interface found in B550/X570 ASUS motherboards.
 	  This driver will provide readings of fans, voltages and temperatures
 	  through the system firmware.
 
+	  This driver is deprecated in favor of the ASUS EC Sensors driver
+	  which provides fully compatible output.
+
 	  This driver can also be built as a module. If so, the module
 	  will be called asus_wmi_sensors_ec.

Thanks.

Signature · 1 line
Oleksandr Natalenko (post-factum)
maintainer
#5 lore raw

Re: [PATCH v5 3/3] hwmon: deprecate asis_wmi_ec_sensors driver

Quoted 20 lines · Oleksandr Natalenko

Hello.

Quoted 9 lines · On úterý 11. ledna 2022 19:03:46 CET Eugene Shalygin wrote:
---
  drivers/hwmon/Kconfig | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/Kconfig +0 -0
index 2c16b19d2c03..5e693c93d43a 100644

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI · line 2246

Quoted 5 lines
drivers/hwmon/Kconfig +1 -1
@@ -2243,13 +2243,16 @@ config SENSORS_ASUS_WMI
 
  config SENSORS_ASUS_WMI_EC
  	tristate "ASUS WMI B550/X570"
-	depends on ACPI_WMI
+	depends on ACPI_WMI && !SENSORS_ASUS_EC

Not sure how it handles SENSORS_ASUS_EC=m. Probably, it should be:

Quoted 4 lines
```
depends on ACPI_WMI && SENSORS_ASUS_EC=n
```

Odd language, and good catch. If I understand correctly, the result of !SENSORS_ASUS_EC is 'm' if SENSORS_ASUS_EC=m. So, yes, it looks like this needs to be "ACPI_WMI && SENSORS_ASUS_EC=n".

Guenter

Quoted 16 lines

?

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI · line 2257

Quoted 11 lines
drivers/hwmon/Kconfig +3 -0
  	help
  	  If you say yes here you get support for the ACPI embedded controller
  	  hardware monitoring interface found in B550/X570 ASUS motherboards.
  	  This driver will provide readings of fans, voltages and temperatures
  	  through the system firmware.
 
+	  This driver is deprecated in favor of the ASUS EC Sensors driver
+	  which provides fully compatible output.
+
  	  This driver can also be built as a module. If so, the module
  	  will be called asus_wmi_sensors_ec.

Thanks.

#6 lore raw

Re: [PATCH v5 3/3] hwmon: deprecate asis_wmi_ec_sensors driver

Hello.

Quoted 21 lines · On čtvrtek 13. ledna 2022 3:51:47 CET Guenter Roeck wrote:
Quoted 20 lines · Oleksandr Natalenko

Hello.

Quoted 9 lines · On úterý 11. ledna 2022 19:03:46 CET Eugene Shalygin wrote:
---
  drivers/hwmon/Kconfig | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/Kconfig +0 -0
index 2c16b19d2c03..5e693c93d43a 100644

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI · line 2246

Quoted 5 lines
drivers/hwmon/Kconfig +1 -1
@@ -2243,13 +2243,16 @@ config SENSORS_ASUS_WMI
 
  config SENSORS_ASUS_WMI_EC
  	tristate "ASUS WMI B550/X570"
-	depends on ACPI_WMI
+	depends on ACPI_WMI && !SENSORS_ASUS_EC

Not sure how it handles SENSORS_ASUS_EC=m. Probably, it should be:

Quoted 8 lines
Quoted 4 lines
```
depends on ACPI_WMI && SENSORS_ASUS_EC=n
```

Odd language, and good catch. If I understand correctly, the result of !SENSORS_ASUS_EC is 'm' if SENSORS_ASUS_EC=m. So, yes, it looks like this needs to be "ACPI_WMI && SENSORS_ASUS_EC=n".

With this change:

on ASUS Pro WS X570-ACE.

Quoted 21 lines

Guenter

Quoted 16 lines

?

drivers/hwmon/Kconfig config SENSORS_ASUS_WMI · line 2257

Quoted 11 lines
drivers/hwmon/Kconfig +3 -0
  	help
  	  If you say yes here you get support for the ACPI embedded controller
  	  hardware monitoring interface found in B550/X570 ASUS motherboards.
  	  This driver will provide readings of fans, voltages and temperatures
  	  through the system firmware.
 
+	  This driver is deprecated in favor of the ASUS EC Sensors driver
+	  which provides fully compatible output.
+
  	  This driver can also be built as a module. If so, the module
  	  will be called asus_wmi_sensors_ec.

Thanks.

Signature · 1 line
Oleksandr Natalenko (post-factum)
#7 lore raw
In reply to Eugene Shalygin

2022. január 11., kedd 19:03 keltezéssel, Eugene Shalygin írta:

Quoted 21 lines

This patchset replaces the HWMON asus_wmi_ec_sensors driver with an implementation that does not use WMI but queries the embedded controller directly.

That provides two enhancements: sensor reading became quicker (on some systems or kernel configuration it took almost a full second to read all the sensors, that transfers less than 15 bytes of data), the driver became more fexible. The driver now relies on ACPI mutex to lock access to the EC, in the same way as the WMI DSDT code does.

Chenges in v5:
- Place the sensors bitset directly into the driver_data field of the dmi_system_id struct.
- Replace doc comments with regular ones.

Changes in v4:
- Deprecate the wmi driver rather than removing it.

Changes in v3:
- Remove BIOS version checks and BIOS version dependent mutex path.

Quoted 9 lines

Changes in v2:
- Replace sensor flags enum with bitset
- Replace module init/probe functions with module_platform_driver_probe and ask the platform drivers framework to load the driver when ACPI EC is found (ACPI ID "PNP0C09").
- Extend board data with BIOS version attribute for the mutex path to be BIOS version dependent.
- Add module parameter to override the mutex path.

Hi

I believe the subject should say "v5" and not "v4". In any case, FYI, git format-patch has the --cover-letter option, which will generate a cover letter template with the right patch version, etc.

Regards,
Barnabás Pőcze

author maintainer
#8 lore raw

Hello,

Yes, my mistake, and thank you for the hint!

Regards,
Eugene

Quoted 44 lines · Barnabás Pőcze

2022. január 11., kedd 19:03 keltezéssel, Eugene Shalygin írta:

Quoted 21 lines

This patchset replaces the HWMON asus_wmi_ec_sensors driver with an implementation that does not use WMI but queries the embedded controller directly.

That provides two enhancements: sensor reading became quicker (on some systems or kernel configuration it took almost a full second to read all the sensors, that transfers less than 15 bytes of data), the driver became more fexible. The driver now relies on ACPI mutex to lock access to the EC, in the same way as the WMI DSDT code does.

Chenges in v5:
- Place the sensors bitset directly into the driver_data field of the dmi_system_id struct.
- Replace doc comments with regular ones.

Changes in v4:
- Deprecate the wmi driver rather than removing it.

Changes in v3:
- Remove BIOS version checks and BIOS version dependent mutex path.

Quoted 9 lines

Changes in v2:
- Replace sensor flags enum with bitset
- Replace module init/probe functions with module_platform_driver_probe and ask the platform drivers framework to load the driver when ACPI EC is found (ACPI ID "PNP0C09").
- Extend board data with BIOS version attribute for the mutex path to be BIOS version dependent.
- Add module parameter to override the mutex path.

Hi

I believe the subject should say "v5" and not "v4". In any case, FYI, git format-patch has the --cover-letter option, which will generate a cover letter template with the right patch version, etc.

Regards,
Barnabás Pőcze

#9 lore raw
In reply to Eugene Shalygin

Hello.

Quoted 10 lines · On úterý 11. ledna 2022 19:03:43 CET Eugene Shalygin wrote:

This patchset replaces the HWMON asus_wmi_ec_sensors driver with an implementation that does not use WMI but queries the embedded controller directly.

That provides two enhancements: sensor reading became quicker (on some systems or kernel configuration it took almost a full second to read all the sensors, that transfers less than 15 bytes of data), the driver became more fexible. The driver now relies on ACPI mutex to lock access to the EC, in the same way as the WMI DSDT code does.

Quoted 4 lines

Chenges in v5:
- Place the sensors bitset directly into the driver_data field of the dmi_system_id struct.
- Replace doc comments with regular ones.

BTW, is this OK:

```
[   11.104396] asus-ec-sensors PNP0C09:00: board has 6 EC sensors that span 7 registers
[   11.104400] asus-ec-sensors PNP0C09:00: hwmon: 'asus-ec-sensors' is not a valid name attribute, please fix
```

?

Quoted 7 lines

Changes in v4:
- Deprecate the wmi driver rather than removing it.

Changes in v3:
- Remove BIOS version checks and BIOS version dependent mutex path.

Quoted 8 lines

Changes in v2:
- Replace sensor flags enum with bitset
- Replace module init/probe functions with module_platform_driver_probe and ask the platform drivers framework to load the driver when ACPI EC is found (ACPI ID "PNP0C09").
- Extend board data with BIOS version attribute for the mutex path to be BIOS version dependent.
- Add module parameter to override the mutex path.

Thanks.

Signature · 1 line
Oleksandr Natalenko (post-factum)
author maintainer
#10 lore raw

Hello,

Quoted 5 lines · Oleksandr Natalenko

BTW, is this OK:

```

[   11.104396] asus-ec-sensors PNP0C09:00: board has 6 EC sensors that span 7 registers
[   11.104400] asus-ec-sensors PNP0C09:00: hwmon: 'asus-ec-sensors' is not a valid name attribute, please fix

Thank you for reminding me to fix the name! I have to replace dashes with underscores, apparently, as hwmon itself uses dashes as separators. I'll send out an update with all three corrections accumulated so far.

Regards,
Eugene