hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card
Subsystems (3)
v3 cover hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card
This is a request for design and safety feedback, not a request to merge the series as-is. It adds opt-in monitoring of the three fan tachometers and three thermistors on an ASUS Fan Extension Card attached to a ROG MAXIMUS XI HERO (non-WiFi), BIOS 2004.
The pinned base is Guenter Roeck's hwmon-next at 8d0f79f49fb10c9f07fee6720551113272a1812b. It already contains the MAXIMUS IX EXTREME selector-based extension fan path and EC 00:60..62 temperature descriptors, but does not select these sensors on XI HERO.
The BIOS 2004 image (SHA-256 034e6c688ca41cf448745398ce3ccfa184dfae217287ee7b72039498ff5aa812) provides the following property and transaction evidence:
EXT_FAN1/2/3: properties 0x060400e2/e3/e4; write EC 00:43 with selector 0x0a/0x0b/0x0c, then read high/low RPM bytes at 00:57/58. The getter checks EC 00:d4 on every call and performs first-use or lost-latch read-modify-writes d4 |= 0x80 and 89 |= 0x07.
EXT_Sensor1/2/3: properties 0x06030032/34/36; after a firmware card property check, write EC 00:68 = 0x07 immediately before each read of 00:60/61/62. The exact meaning of 0x68 is not established.
BIOS 2203 has the same relevant fan mapping and getter control flow. The BIOS presence property, IsEXTFanCardExist (0x06060050), reads the EXTFanCard UEFI/Setup variable; we have not established a reliable live electrical card-presence signal. Accordingly, the XI HERO extension sensors remain disabled by default and are enabled only by an explicit module parameter on the exact non-WiFi DMI name. The WiFi entry is not changed. With the option enabled, the first read of any hwmon input may trigger a full refresh and the extension setup writes, even if the user did not request an EXT_* attribute.
Patch 1 changes generic EC/selector error propagation so a failed block read cannot publish a partial sensor cache. This affects failure paths on all supported boards, not only XI HERO. Patches 2 and 3 add the board opt-in, RPM path and thermistor path. Patch 2 currently relies on the restore/error path introduced by patch 1; we would rebase or reshape the series if the generic change should be reviewed separately.
The new transactions use the driver's configured ACPI EC mutex, normally \AMW0.ASMX on XI HERO. They do not add PWM, fan-control, NCT, direct EC-port or WMI accesses. They do write the EC bank selector, the BIOS observed d4/89 setup registers, the fan selector and 0x68. We do not claim that these writes are harmless when the optional card is absent.
A different, locally maintained asus-ec-sensors module for Unraid 7.4.1 / 6.18.64-Unraid has returned all six channels on a physical XI HERO with the card installed, including after one reboot. The binaries and some error/selector handling differ; that test is not a runtime test of this upstream RFC. All three v2 increments compiled with W=1 on both x86_64 and i386. For v3 we fault-injected the actual initialization helper on a host with memory-backed EC stubs. After a lost latch, v2 skipped the retry when either the read or write at 0x89 failed; v3 repeated both setup writes. The driver object compiled with W=1 and no warnings after each v3 patch on x86_64 and i386 with GCC 15.2.0. On x86_64 the v3 module also linked with W=1 against a freshly built vmlinux; modpost completed without diagnostics. We have not run v3 on hardware.
Questions for maintainers:
1. Is a default-off, exact-DMI opt-in acceptable when firmware exposes only a Setup-variable-backed card property, or is another presence mechanism required before these EC writes can be accepted?
2. Should the driver preserve the BIOS first-use d4/89 writes even when d4 bit 7 is already set? We have not isolated their necessity and do not want to replace a working BIOS sequence with an untested shortcut.
3. Is reproducing the BIOS's 68=07 write before every thermistor read an acceptable basis while its bit semantics remain unknown? A separate BIOS Extension control initialization path also writes 68=07.
4. Would you prefer patch 1 as a separate bugfix before the board support, and what fault-path regression evidence would be useful?
5. Is the separate non-WiFi board profile and module parameter an appropriate interface, or should the board/card policy be expressed differently?
Changes since v2:
- Add Fixes tags for the original block-read and selector error paths.
- Clear the cached initialization flag before attempting either setup write, so a partial recovery can be retried.
- Document enable_ext_fan and explain the BIOS cutoff of 165 RPM.
- Keep the thermistor patch functionally unchanged.
v2: https://lore.kernel.org/linux-hwmon/[email protected]/
John den Heijer (3):
hwmon: (asus-ec-sensors) propagate EC read and selector errors
hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM
hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors
Documentation/hwmon/asus_ec_sensors.rst | 7 ++ drivers/hwmon/asus-ec-sensors.c | 142 +++++++++++++++++++++--- 2 files changed, 131 insertions(+), 18 deletions(-)
base-commit: 8d0f79f49fb10c9f07fee6720551113272a1812b
Signature · 1 line
2.54.0 (Apple Git-157)
RFC PATCH v3 1/3 hwmon: (asus-ec-sensors) propagate EC read and selector errors
On an EC or selector failure, asus_ec_block_read() can continue with a partial buffer. A successful final bank restore then reports success, so update_ec_sensors() publishes stale bytes.
Propagate the first error. Attempt selector restoration in its bank, then restore the original bank. A failed restore also rejects the update. This changes the failure path for all supported boards.
--- drivers/hwmon/asus-ec-sensors.c | 39 ++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 13 deletions(-)
drivers/hwmon/asus-ec-sensors.c +26 -13
@@ -1309,7 +1309,7 @@ static int asus_ec_bank_switch(u8 bank, u8 *old)static int asus_ec_block_read (const struct device *dev,struct ec_sensors_data *ec) { -int ireg, ibank, status; +int ireg, ibank, status, restore_status;u8 bank, reg_bank, prev_bank, select, prev_select;bool select_saved;
@@ -1330,7 +1330,8 @@ static int asus_ec_block_read(const struct device *dev,for (ibank =0 ; ibank < ec->nr_banks; ibank++) {if (bank != ec->banks[ibank]) { bank = ec->banks[ibank]; -if (asus_ec_bank_switch (bank,NULL )) { + status =asus_ec_bank_switch (bank,NULL ); +if (status) {dev_warn (dev,"EC bank switch to %d failed" , bank);break ;
@@ -1345,24 +1346,36 @@ static int asus_ec_block_read(const struct device *dev, select =register_select (ec->registers[ireg]);if (select) {if (!select_saved) { -if (ec_read (ASUS_EC_SELECT_REGISTER , - &prev_select)) -continue ; + status =ec_read (ASUS_EC_SELECT_REGISTER , + &prev_select); +if (status) + goto restore_select; select_saved = true; } -if (ec_write (ASUS_EC_SELECT_REGISTER , select)) -continue ; + status =ec_write (ASUS_EC_SELECT_REGISTER , select); +if (status) + goto restore_select; } -ec_read (register_index (ec->registers[ireg]), - ec->read_buffer + ireg); + status =ec_read (register_index (ec->registers[ireg]), + ec->read_buffer + ireg); +if (status) + goto restore_select; } +restore_select:/* restore the selector while still in its bank */ -if (select_saved && -ec_write (ASUS_EC_SELECT_REGISTER , prev_select)) -dev_warn (dev,"EC selector restore failed" ); +if (select_saved) { + restore_status =ec_write (ASUS_EC_SELECT_REGISTER , + prev_select); +if (!status) + status = restore_status; + } +if (status) +break ; } - status =asus_ec_bank_switch (prev_bank,NULL ); + restore_status =asus_ec_bank_switch (prev_bank,NULL ); +if (!status) + status = restore_status;return status; }
Signature · 1 line
2.54.0 (Apple Git-157)
RFC PATCH v3 2/3 hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM
In reply to John den HeijerBIOS 2004 reads the three optional extension fan tachometers by writing selector 0x0a, 0x0b or 0x0c to EC bank-0 register 0x43 and reading the high and low RPM bytes from 0x57/0x58.
Before the first read, or after a lost latch, the BIOS getter sets bit 7 of 0xd4 and bits 0-2 of 0x89. Reuse the upstream MAXIMUS IX EXTREME selector path, but add this initialization only for the exact non-WiFi MAXIMUS XI HERO DMI name. Keep the optional-card support default-off:
a reliable live card-presence detector has not been established.
Enable the sensors with enable_ext_fan=1 only with the card installed. Match BIOS 2004 by reporting extension readings below 165 RPM (0xa5) as zero. If reinitialization fails, retry the whole sequence on the next refresh even if the enable bit is already set.
--- Documentation/hwmon/asus_ec_sensors.rst | 7 +++ drivers/hwmon/asus-ec-sensors.c | 78 +++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 5 deletions(-)
Documentation/hwmon/asus_ec_sensors.rst +7 -0
@@ -108,3 +108,10 @@ Module Parameters the stored in the driver value until it gets updated. A special string ":GLOBAL_LOCK" can be passed to use the ACPI global lock instead of a dedicated mutex. + + * enable_ext_fan: bool + Enable monitoring of the optional ASUS Fan Extension Card on the + ROG MAXIMUS XI HERO (non-WiFi). The default is false. Set + ``enable_ext_fan=1`` when loading the module only if the card is + installed. The driver cannot detect its presence. Reading any + hwmon input can trigger the EC writes that prepare the card.
drivers/hwmon/asus-ec-sensors.c +73 -5
169 lines not on this page · raw message
Signature · 1 line
2.54.0 (Apple Git-157)
RFC PATCH v3 3/3 hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors
In reply to John den HeijerBIOS 2004 maps the three optional Fan Extension Card thermistors to EC bank-0 registers 0x60, 0x61 and 0x62. Its getter writes 0x68=0x07 immediately before each read.
Reproduce that sequence only for the opted-in non-WiFi XI HERO and return -ENODATA for firmware-invalid values. The bit-level meaning of 0x68 is not established.
--- drivers/hwmon/asus-ec-sensors.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/hwmon/asus-ec-sensors.c +26 -1
@@ -49,6 +49,8 @@ static bool enable_ext_fan;#define ASUS_EC_EXT_FAN_RPM_MIN 0xa5#define ASUS_EC_EXT_FAN_ENABLE_REGISTER 0xd4#define ASUS_EC_EXT_FAN_CHANNEL_REGISTER 0x89 +#define ASUS_EC_EXT_TEMP_PREPARE_REGISTER 0x68 +#define ASUS_EC_EXT_TEMP_PREPARE_VALUE 0x07#define SENSOR_LABEL_LEN 16/*
@@ -413,6 +415,13 @@ static const struct ec_sensor_info sensors_family_intel_300[] = { [ec_sensor_temp_t_sensor] = EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x3d), [ec_sensor_temp_vrm] = EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e), +/* BIOS 2004 properties 0x06030032, 0x06030034, 0x06030036 */ + [ec_sensor_temp_sensor_extra_1] = + EC_SENSOR("EXT_Sensor1", hwmon_temp, 1, 0x00, 0x60), + [ec_sensor_temp_sensor_extra_2] = + EC_SENSOR("EXT_Sensor2", hwmon_temp, 1, 0x00, 0x61), + [ec_sensor_temp_sensor_extra_3] = + EC_SENSOR("EXT_Sensor3", hwmon_temp, 1, 0x00, 0x62), [ec_sensor_fan_cpu_opt] = EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0), [ec_sensor_fan_vrm_hs] = EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2),
@@ -1411,6 +1420,15 @@ static int asus_ec_block_read(const struct device *dev,if (status) goto restore_select; } +/* BIOS 2004 performs this write before each EXT probe read. */ +if (ec->ext_fan_enabled && !bank && +register_index (ec->registers[ireg]) >=0x60 && +register_index (ec->registers[ireg]) <=0x62 ) { + status =ec_write (ASUS_EC_EXT_TEMP_PREPARE_REGISTER , +ASUS_EC_EXT_TEMP_PREPARE_VALUE ); +if (status) + goto restore_select; + } status =ec_read (register_index (ec->registers[ireg]), ec->read_buffer + ireg);if (status)
@@ -1564,6 +1582,10 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type, ec_sensor <= ec_sensor_fan_ext_3 && value < ASUS_EC_EXT_FAN_RPM_MIN) value =0 ;if (sensor_info->type == hwmon_temp) { +if (state->ext_fan_enabled && + ec_sensor >= ec_sensor_temp_sensor_extra_1 && + ec_sensor <= ec_sensor_temp_sensor_extra_3 && value <-50 ) +return -ENODATA ;if ((environment_temp_sensors &BIT (ec_sensor)) &&is_blank_temperature_value (value))return -ENODATA ;
@@ -1665,7 +1687,10 @@ static int asus_ec_probe(struct platform_device *pdev) enable_ext_fan;if (ec_data->ext_fan_enabled) ec_data->sensor_mask |=SENSOR_FAN_EXT_1 | -SENSOR_FAN_EXT_2 |SENSOR_FAN_EXT_3 ; +SENSOR_FAN_EXT_2 |SENSOR_FAN_EXT_3 | +SENSOR_TEMP_SENSOR_EXTRA_1 | +SENSOR_TEMP_SENSOR_EXTRA_2 | +SENSOR_TEMP_SENSOR_EXTRA_3 ;switch (ec_data->board_info->family) {case family_amd_400_series:
Signature · 1 line
2.54.0 (Apple Git-157)
[email protected]
AI reviewSashiko has reviewed this 3-patch series and found no issues.
Sashiko has reviewed this 3-patch series and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]
Eugene Shalygin
maintainerRe: [RFC PATCH v3 2/3] hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM
In reply to John den HeijerHi!
Quoted 98 lines · John den Heijer
BIOS 2004 reads the three optional extension fan tachometers by writing selector
0x0a,0x0bor0x0cto EC bank-0 register0x43and reading the high and low RPM bytes from 0x57/0x58.Before the first read, or after a lost latch, the BIOS getter sets bit 7 of
0xd4and bits 0-2 of0x89. Reuse the upstream MAXIMUS IX EXTREME selector path, but add this initialization only for the exact non-WiFi MAXIMUS XI HERO DMI name. Keep the optional-card support default-off:
a reliable live card-presence detector has not been established.Enable the sensors with enable_ext_fan=1 only with the card installed. Match BIOS 2004 by reporting extension readings below 165 RPM (
0xa5) as zero. If reinitialization fails, retry the whole sequence on the next refresh even if the enable bit is already set.Signed-off-by John den Heijer <[email protected]>--- Documentation/hwmon/asus_ec_sensors.rst | 7 +++ drivers/hwmon/asus-ec-sensors.c | 78 +++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 5 deletions(-)Documentation/hwmon/asus_ec_sensors.rst +7
-0@@ -108,3 +108,10 @@ Module Parameters the stored in the driver value until it gets updated. A special string ":GLOBAL_LOCK" can be passed to use the ACPI global lock instead of a dedicated mutex. + + * enable_ext_fan: bool + Enable monitoring of the optional ASUS Fan Extension Card on the + ROG MAXIMUS XI HERO (non-WiFi). The default is false. Set + ``enable_ext_fan=1`` when loading the module only if the card is + installed. The driver cannot detect its presence. Reading any + hwmon input can trigger the EC writes that prepare the card.drivers/hwmon/asus-ec-sensors.c +21
-0@@ -37,6 +37,7 @@#include <linux/unaligned.h> static char *mutex_path_override; +static bool enable_ext_fan;/* Writing to this EC register switches EC bank */ #define ASUS_EC_BANK_REGISTER 0xff@@ -45,6 +46,9 @@ static char *mutex_path_override;* group of registers reports (e.g. one of the fans of the fan extension card). */ #define ASUS_EC_SELECT_REGISTER 0x43 +#define ASUS_EC_EXT_FAN_RPM_MIN 0xa5 +#define ASUS_EC_EXT_FAN_ENABLE_REGISTER 0xd4 +#define ASUS_EC_EXT_FAN_CHANNEL_REGISTER 0x89#define SENSOR_LABEL_LEN 16/* @@ -414,6 +418,12 @@ static const struct ec_sensor_info sensors_family_intel_300[] = { [ec_sensor_fan_vrm_hs] = EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2), [ec_sensor_fan_water_flow] = EC_SENSOR("Water_Flow", hwmon_fan, 2, 0x00, 0xbc), + [ec_sensor_fan_ext_1] = + EC_SENSOR_SELECT("EXT_FAN1", hwmon_fan, 2, 0x00, 0x57, 0x0a), + [ec_sensor_fan_ext_2] = + EC_SENSOR_SELECT("EXT_FAN2", hwmon_fan, 2, 0x00, 0x57, 0x0b), + [ec_sensor_fan_ext_3] = + EC_SENSOR_SELECT("EXT_FAN3", hwmon_fan, 2, 0x00, 0x57, 0x0c), [ec_sensor_temp_water_in] = EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00), [ec_sensor_temp_water_out] =@@ -484,6 +494,7 @@ static const struct ec_sensor_info sensors_family_intel_700[] = {struct ec_board_info {unsigned long sensors; +bool ext_fan_capable;/* * Defines which mutex to use for guarding access to the state and the * hardware. Can be either a full path to an AML mutex or the @@ -593,6 +604,16 @@ static const struct ec_board_info board_info_maximus_xi_hero = { .family = family_intel_300_series, }; +static const struct ec_board_info board_info_maximus_xi_hero_ext = { + .sensors =SENSOR_SET_TEMP_CHIPSET_CPU_MB | +SENSOR_TEMP_T_SENSOR | +SENSOR_TEMP_VRM |SENSOR_SET_TEMP_WATER | +SENSOR_FAN_CPU_OPT |SENSOR_FAN_WATER_FLOW , + .ext_fan_capable = true, + .mutex_path =ASUS_HW_ACCESS_MUTEX_ASMX , + .family = family_intel_300_series, +}; +static const struct ec_board_info board_info_maximus_z690_formula = { .sensors =SENSOR_TEMP_T_SENSOR |SENSOR_TEMP_VRM |SENSOR_SET_TEMP_WATER |SENSOR_FAN_WATER_FLOW ,
drivers/hwmon/asus-ec-sensors.c static const struct dmi_system_id dmi_table[] = { · line 1030
Quoted 7 lines
drivers/hwmon/asus-ec-sensors.c +1
-1@@ -1004,7 +1025,7 @@ static const struct dmi_system_id dmi_table[] = {DMI_EXACT_MATCH_ASUS_BOARD_NAME ("ROG CROSSHAIR X870E HERO" , &board_info_crosshair_x870e_hero),DMI_EXACT_MATCH_ASUS_BOARD_NAME ("ROG MAXIMUS XI HERO" , - &board_info_maximus_xi_hero), + &board_info_maximus_xi_hero_ext),DMI_EXACT_MATCH_ASUS_BOARD_NAME ("ROG MAXIMUS XI HERO (WI-FI)" , &board_info_maximus_xi_hero),
Now these last two records read illogical. Maybe rename the one for WiFI to board_info_maximus_xi_hero_wifi?
drivers/hwmon/asus-ec-sensors.c static bool unlock_global_acpi_lock(struct lock_data *data) · line 1159
Quoted 6 lines
drivers/hwmon/asus-ec-sensors.c +1
-0DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS X HERO",@@ -1135,6 +1156,9 @@ static bool unlock_global_acpi_lock(struct lock_data *data)struct ec_sensors_data {const struct ec_board_info *board_info;const struct ec_sensor_info *sensors_info; +unsigned long sensor_mask;
I don't like how the sensors in the board into and the final mask are separated.
Quoted 24 lines
drivers/hwmon/asus-ec-sensors.c +8
-2+bool ext_fan_enabled; +bool ext_fan_initialized;struct ec_sensor *sensors;/* * EC registers to read from: (select << 16) + (bank << 8) + index, @@ -1224,8 +1248,8 @@ static void setup_sensor_data(struct ec_sensors_data *ec) ec->nr_banks =0 ; ec->nr_registers =0 ; -for_each_set_bit (i, &ec->board_info->sensors, -BITS_PER_TYPE (ec->board_info->sensors)) { +for_each_set_bit (i, &ec->sensor_mask, +BITS_PER_TYPE (ec->sensor_mask)) { s->info_index = i; s->cached_value =0 ; ec->nr_registers +=@@ -1306,6 +1330,32 @@ static int asus_ec_bank_switch(u8 bank, u8 *old)return ec_write (ASUS_EC_BANK_REGISTER , bank); } +static int asus_ec_prepare_ext_fans (struct ec_sensors_data *ec) +{ +u8 enabled, channels; +int status;
drivers/hwmon/asus-ec-sensors.c static int asus_ec_bank_switch(u8 bank, u8 *old) · line 1346
Quoted 10 lines
drivers/hwmon/asus-ec-sensors.c +10
-0+ + status =ec_read (ASUS_EC_EXT_FAN_ENABLE_REGISTER , &enabled); +if (status) +return status; +if (ec->ext_fan_initialized && (enabled &BIT (7 ))) +return 0 ; + +/* Retry both setup writes if reinitialization fails partway. */ + ec->ext_fan_initialized = false; + status =ec_write (ASUS_EC_EXT_FAN_ENABLE_REGISTER , enabled |BIT (7 ));
If we need only bit 7, why combining it with garbage in enabled?
Quoted 36 lines
drivers/hwmon/asus-ec-sensors.c +18
-0+if (status) +return status; + status =ec_read (ASUS_EC_EXT_FAN_CHANNEL_REGISTER , &channels); +if (status) +return status; + status =ec_write (ASUS_EC_EXT_FAN_CHANNEL_REGISTER , + channels |GENMASK (2 ,0 )); +if (!status) + ec->ext_fan_initialized = true; +return status; +} +static int asus_ec_block_read (const struct device *dev,struct ec_sensors_data *ec) {@@ -1325,6 +1375,11 @@ static int asus_ec_block_read(const struct device *dev,dev_warn (dev,"Concurrent access to the ACPI EC detected.\nRace condition possible." ); } +if (ec->ext_fan_enabled) { + status =asus_ec_prepare_ext_fans (ec); +if (status) + goto restore_bank; + }/* read registers minimizing bank switches. */ for (ibank =0 ; ibank < ec->nr_banks; ibank++) {@@ -1373,6 +1428,7 @@ restore_select:break ; } +restore_bank: restore_status =asus_ec_bank_switch (prev_bank,NULL );if (!status) status = restore_status;
drivers/hwmon/asus-ec-sensors.c static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type, · line 1565
Quoted 7 lines
drivers/hwmon/asus-ec-sensors.c +4
-0@@ -1503,8 +1559,11 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,return ret; sensor_info =get_sensor_info (state, sidx); + ec_sensor =get_ec_sensor_type (state, sidx); +if (state->ext_fan_enabled && ec_sensor >= ec_sensor_fan_ext_1 && + ec_sensor <= ec_sensor_fan_ext_3 && value <ASUS_EC_EXT_FAN_RPM_MIN ) + value =0 ;
What is this for?
Quoted 38 lines
drivers/hwmon/asus-ec-sensors.c +10
-3if (sensor_info->type == hwmon_temp) { - ec_sensor =get_ec_sensor_type (state, sidx);if ((environment_temp_sensors &BIT (ec_sensor)) &&is_blank_temperature_value (value))return -ENODATA ;@@ -1601,6 +1660,12 @@ static int asus_ec_probe(struct platform_device *pdev) ec_data->next_update =INITIAL_JIFFIES ;dev_set_drvdata (dev, ec_data); ec_data->board_info = pboard_info; + ec_data->sensor_mask = pboard_info->sensors; + ec_data->ext_fan_enabled = pboard_info->ext_fan_capable && + enable_ext_fan; +if (ec_data->ext_fan_enabled) + ec_data->sensor_mask |=SENSOR_FAN_EXT_1 | +SENSOR_FAN_EXT_2 |SENSOR_FAN_EXT_3 ;switch (ec_data->board_info->family) {case family_amd_400_series:@@ -1645,7 +1710,7 @@ static int asus_ec_probe(struct platform_device *pdev)return -EINVAL ; } - ec_data->nr_sensors =hweight_long (ec_data->board_info->sensors); + ec_data->nr_sensors =hweight_long (ec_data->sensor_mask); ec_data->sensors = devm_kzalloc_objs(dev, struct ec_sensor, ec_data->nr_sensors);if (!ec_data->sensors)@@ -1745,6 +1810,9 @@ module_exit(asus_ec_exit);module_param_named (mutex_path, mutex_path_override, charp,0 );MODULE_PARM_DESC (mutex_path,"Override ACPI mutex path used to guard access to hardware" ); +module_param (enable_ext_fan, bool,0 ); +MODULE_PARM_DESC (enable_ext_fan, +"Enable Fan Extension Card sensors on ROG MAXIMUS XI HERO" );MODULE_AUTHOR ("Eugene Shalygin <[email protected]>" ); MODULE_DESCRIPTION( --
Quoted 2 lines
2.54.0 (Apple Git-157)
Cheers,
Eugene
Eugene Shalygin
maintainerRe: [RFC PATCH v3 3/3] hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors
In reply to John den HeijerHi!
Quoted 58 lines · John den Heijer
BIOS 2004 maps the three optional Fan Extension Card thermistors to EC bank-0 registers
0x60,0x61and0x62. Its getter writes 0x68=0x07 immediately before each read.Reproduce that sequence only for the opted-in non-WiFi XI HERO and return
-ENODATAfor firmware-invalid values. The bit-level meaning of0x68is not established.Signed-off-by John den Heijer <[email protected]>--- drivers/hwmon/asus-ec-sensors.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)drivers/hwmon/asus-ec-sensors.c +18
-0@@ -49,6 +49,8 @@ static bool enable_ext_fan;#define ASUS_EC_EXT_FAN_RPM_MIN 0xa5#define ASUS_EC_EXT_FAN_ENABLE_REGISTER 0xd4#define ASUS_EC_EXT_FAN_CHANNEL_REGISTER 0x89 +#define ASUS_EC_EXT_TEMP_PREPARE_REGISTER 0x68 +#define ASUS_EC_EXT_TEMP_PREPARE_VALUE 0x07#define SENSOR_LABEL_LEN 16/* @@ -413,6 +415,13 @@ static const struct ec_sensor_info sensors_family_intel_300[] = { [ec_sensor_temp_t_sensor] = EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x3d), [ec_sensor_temp_vrm] = EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e), +/* BIOS 2004 properties 0x06030032, 0x06030034, 0x06030036 */ + [ec_sensor_temp_sensor_extra_1] = + EC_SENSOR("EXT_Sensor1", hwmon_temp, 1, 0x00, 0x60), + [ec_sensor_temp_sensor_extra_2] = + EC_SENSOR("EXT_Sensor2", hwmon_temp, 1, 0x00, 0x61), + [ec_sensor_temp_sensor_extra_3] = + EC_SENSOR("EXT_Sensor3", hwmon_temp, 1, 0x00, 0x62), [ec_sensor_fan_cpu_opt] = EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0), [ec_sensor_fan_vrm_hs] = EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2),@@ -1411,6 +1420,15 @@ static int asus_ec_block_read(const struct device *dev,if (status) goto restore_select; } +/* BIOS 2004 performs this write before each EXT probe read. */ +if (ec->ext_fan_enabled && !bank && +register_index (ec->registers[ireg]) >=0x60 && +register_index (ec->registers[ireg]) <=0x62 ) { + status =ec_write (ASUS_EC_EXT_TEMP_PREPARE_REGISTER , +ASUS_EC_EXT_TEMP_PREPARE_VALUE ); +if (status) + goto restore_select; + } status =ec_read (register_index (ec->registers[ireg]), ec->read_buffer + ireg);if (status)
drivers/hwmon/asus-ec-sensors.c static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type, · line 1587
Quoted 6 lines
drivers/hwmon/asus-ec-sensors.c +3
-0@@ -1564,6 +1582,10 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type, ec_sensor <= ec_sensor_fan_ext_3 && value < ASUS_EC_EXT_FAN_RPM_MIN) value =0 ;if (sensor_info->type == hwmon_temp) { +if (state->ext_fan_enabled && + ec_sensor >= ec_sensor_temp_sensor_extra_1 && + ec_sensor <= ec_sensor_temp_sensor_extra_3 && value <-50 )
Have you tried temperature_blank_values?
Quoted 17 lines
drivers/hwmon/asus-ec-sensors.c +5
-2+return -ENODATA ;if ((environment_temp_sensors &BIT (ec_sensor)) &&is_blank_temperature_value (value))return -ENODATA ;@@ -1665,7 +1687,10 @@ static int asus_ec_probe(struct platform_device *pdev) enable_ext_fan;if (ec_data->ext_fan_enabled) ec_data->sensor_mask |=SENSOR_FAN_EXT_1 | -SENSOR_FAN_EXT_2 |SENSOR_FAN_EXT_3 ; +SENSOR_FAN_EXT_2 |SENSOR_FAN_EXT_3 | +SENSOR_TEMP_SENSOR_EXTRA_1 | +SENSOR_TEMP_SENSOR_EXTRA_2 | +SENSOR_TEMP_SENSOR_EXTRA_3 ;switch (ec_data->board_info->family) {case family_amd_400_series: --
Quoted 2 lines
2.54.0 (Apple Git-157)
Cheers,
Eugene
Re: [RFC PATCH v3 2/3] hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM
In reply to Eugene ShalyginHi Eugene,
I agree about the board names. The Wi-Fi entry can use board_info_maximus_xi_hero_wifi, leaving board_info_maximus_xi_hero for the non-Wi-Fi board.
The second mask was meant to keep the static board data immutable and leave the optional channels off by default. A simpler approach would be to select a board profile once at probe, using the extended profile only for the exact non-Wi-Fi board with enable_ext_fan=1. Counting and enumerating sensors could then both use board_info->sensors.
Quoted 1 line
If we need only bit 7, why combining it with garbage in
enabled?
BIOS 2004 reads bank 0 register 0xd4, ORs the byte with 0x80 and writes it back (PEbiosinterfaceDXE, RVAs 0x40f8 and 0x411d..0x4128). Writing a literal 0x80 would also write zeros to bits 0..6. I don't know what those bits mean or whether they are safe to clear; the read-modify-write follows what the firmware actually does.
Quoted 1 line
What is this for?
The same getter combines the two RPM bytes and compares the result with 0x00a5 at RVA 0x41b3..0x41be. It reports zero below 165 RPM and keeps 165 itself. This reproduces the BIOS reading for the three EXT fans. It is a reporting cutoff; I have no evidence that a fan cannot physically turn below that speed.
Thanks,
John
Quoted 241 lines · Eugene Shalygin
Hi!
Quoted 98 lines · John den Heijer
BIOS 2004 reads the three optional extension fan tachometers by writing selector
0x0a,0x0bor0x0cto EC bank-0 register0x43and reading the high and low RPM bytes from 0x57/0x58.Before the first read, or after a lost latch, the BIOS getter sets bit 7 of
0xd4and bits 0-2 of0x89. Reuse the upstream MAXIMUS IX EXTREME selector path, but add this initialization only for the exact non-WiFi MAXIMUS XI HERO DMI name. Keep the optional-card support default-off:
a reliable live card-presence detector has not been established.Enable the sensors with enable_ext_fan=1 only with the card installed. Match BIOS 2004 by reporting extension readings below 165 RPM (
0xa5) as zero. If reinitialization fails, retry the whole sequence on the next refresh even if the enable bit is already set.Signed-off-by John den Heijer <[email protected]>--- Documentation/hwmon/asus_ec_sensors.rst | 7 +++ drivers/hwmon/asus-ec-sensors.c | 78 +++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 5 deletions(-)Documentation/hwmon/asus_ec_sensors.rst +7
-0@@ -108,3 +108,10 @@ Module Parameters the stored in the driver value until it gets updated. A special string ":GLOBAL_LOCK" can be passed to use the ACPI global lock instead of a dedicated mutex. + + * enable_ext_fan: bool + Enable monitoring of the optional ASUS Fan Extension Card on the + ROG MAXIMUS XI HERO (non-WiFi). The default is false. Set + ``enable_ext_fan=1`` when loading the module only if the card is + installed. The driver cannot detect its presence. Reading any + hwmon input can trigger the EC writes that prepare the card.drivers/hwmon/asus-ec-sensors.c +21
-0@@ -37,6 +37,7 @@#include <linux/unaligned.h> static char *mutex_path_override; +static bool enable_ext_fan;/* Writing to this EC register switches EC bank */ #define ASUS_EC_BANK_REGISTER 0xff@@ -45,6 +46,9 @@ static char *mutex_path_override;* group of registers reports (e.g. one of the fans of the fan extension card). */ #define ASUS_EC_SELECT_REGISTER 0x43 +#define ASUS_EC_EXT_FAN_RPM_MIN 0xa5 +#define ASUS_EC_EXT_FAN_ENABLE_REGISTER 0xd4 +#define ASUS_EC_EXT_FAN_CHANNEL_REGISTER 0x89#define SENSOR_LABEL_LEN 16/* @@ -414,6 +418,12 @@ static const struct ec_sensor_info sensors_family_intel_300[] = { [ec_sensor_fan_vrm_hs] = EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2), [ec_sensor_fan_water_flow] = EC_SENSOR("Water_Flow", hwmon_fan, 2, 0x00, 0xbc), + [ec_sensor_fan_ext_1] = + EC_SENSOR_SELECT("EXT_FAN1", hwmon_fan, 2, 0x00, 0x57, 0x0a), + [ec_sensor_fan_ext_2] = + EC_SENSOR_SELECT("EXT_FAN2", hwmon_fan, 2, 0x00, 0x57, 0x0b), + [ec_sensor_fan_ext_3] = + EC_SENSOR_SELECT("EXT_FAN3", hwmon_fan, 2, 0x00, 0x57, 0x0c), [ec_sensor_temp_water_in] = EC_SENSOR("Water_In", hwmon_temp, 1, 0x01, 0x00), [ec_sensor_temp_water_out] =@@ -484,6 +494,7 @@ static const struct ec_sensor_info sensors_family_intel_700[] = {struct ec_board_info {unsigned long sensors; +bool ext_fan_capable;/* * Defines which mutex to use for guarding access to the state and the * hardware. Can be either a full path to an AML mutex or the @@ -593,6 +604,16 @@ static const struct ec_board_info board_info_maximus_xi_hero = { .family = family_intel_300_series, }; +static const struct ec_board_info board_info_maximus_xi_hero_ext = { + .sensors =SENSOR_SET_TEMP_CHIPSET_CPU_MB | +SENSOR_TEMP_T_SENSOR | +SENSOR_TEMP_VRM |SENSOR_SET_TEMP_WATER | +SENSOR_FAN_CPU_OPT |SENSOR_FAN_WATER_FLOW , + .ext_fan_capable = true, + .mutex_path =ASUS_HW_ACCESS_MUTEX_ASMX , + .family = family_intel_300_series, +}; +static const struct ec_board_info board_info_maximus_z690_formula = { .sensors =SENSOR_TEMP_T_SENSOR |SENSOR_TEMP_VRM |SENSOR_SET_TEMP_WATER |SENSOR_FAN_WATER_FLOW ,drivers/hwmon/asus-ec-sensors.c static const struct dmi_system_id dmi_table[] = { · line 1030
Quoted 7 lines
drivers/hwmon/asus-ec-sensors.c +1
-1@@ -1004,7 +1025,7 @@ static const struct dmi_system_id dmi_table[] = {DMI_EXACT_MATCH_ASUS_BOARD_NAME ("ROG CROSSHAIR X870E HERO" , &board_info_crosshair_x870e_hero),DMI_EXACT_MATCH_ASUS_BOARD_NAME ("ROG MAXIMUS XI HERO" , - &board_info_maximus_xi_hero), + &board_info_maximus_xi_hero_ext),DMI_EXACT_MATCH_ASUS_BOARD_NAME ("ROG MAXIMUS XI HERO (WI-FI)" , &board_info_maximus_xi_hero),Now these last two records read illogical. Maybe rename the one for WiFI to
board_info_maximus_xi_hero_wifi?drivers/hwmon/asus-ec-sensors.c static bool unlock_global_acpi_lock(struct lock_data *data) · line 1159
Quoted 6 lines
drivers/hwmon/asus-ec-sensors.c +1
-0DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG MAXIMUS X HERO",@@ -1135,6 +1156,9 @@ static bool unlock_global_acpi_lock(struct lock_data *data)struct ec_sensors_data {const struct ec_board_info *board_info;const struct ec_sensor_info *sensors_info; +unsigned long sensor_mask;I don't like how the sensors in the board into and the final mask are separated.
Quoted 24 lines
drivers/hwmon/asus-ec-sensors.c +8
-2+bool ext_fan_enabled; +bool ext_fan_initialized;struct ec_sensor *sensors;/* * EC registers to read from: (select << 16) + (bank << 8) + index, @@ -1224,8 +1248,8 @@ static void setup_sensor_data(struct ec_sensors_data *ec) ec->nr_banks =0 ; ec->nr_registers =0 ; -for_each_set_bit (i, &ec->board_info->sensors, -BITS_PER_TYPE (ec->board_info->sensors)) { +for_each_set_bit (i, &ec->sensor_mask, +BITS_PER_TYPE (ec->sensor_mask)) { s->info_index = i; s->cached_value =0 ; ec->nr_registers +=@@ -1306,6 +1330,32 @@ static int asus_ec_bank_switch(u8 bank, u8 *old)return ec_write (ASUS_EC_BANK_REGISTER , bank); } +static int asus_ec_prepare_ext_fans (struct ec_sensors_data *ec) +{ +u8 enabled, channels; +int status;drivers/hwmon/asus-ec-sensors.c static int asus_ec_bank_switch(u8 bank, u8 *old) · line 1346
Quoted 10 lines
drivers/hwmon/asus-ec-sensors.c +10
-0+ + status =ec_read (ASUS_EC_EXT_FAN_ENABLE_REGISTER , &enabled); +if (status) +return status; +if (ec->ext_fan_initialized && (enabled &BIT (7 ))) +return 0 ; + +/* Retry both setup writes if reinitialization fails partway. */ + ec->ext_fan_initialized = false; + status =ec_write (ASUS_EC_EXT_FAN_ENABLE_REGISTER , enabled |BIT (7 ));If we need only bit 7, why combining it with garbage in
enabled?Quoted 36 lines
drivers/hwmon/asus-ec-sensors.c +18
-0+if (status) +return status; + status =ec_read (ASUS_EC_EXT_FAN_CHANNEL_REGISTER , &channels); +if (status) +return status; + status =ec_write (ASUS_EC_EXT_FAN_CHANNEL_REGISTER , + channels |GENMASK (2 ,0 )); +if (!status) + ec->ext_fan_initialized = true; +return status; +} +static int asus_ec_block_read (const struct device *dev,struct ec_sensors_data *ec) {@@ -1325,6 +1375,11 @@ static int asus_ec_block_read(const struct device *dev,dev_warn (dev,"Concurrent access to the ACPI EC detected.\nRace condition possible." ); } +if (ec->ext_fan_enabled) { + status =asus_ec_prepare_ext_fans (ec); +if (status) + goto restore_bank; + }/* read registers minimizing bank switches. */ for (ibank =0 ; ibank < ec->nr_banks; ibank++) {@@ -1373,6 +1428,7 @@ restore_select:break ; } +restore_bank: restore_status =asus_ec_bank_switch (prev_bank,NULL );if (!status) status = restore_status;drivers/hwmon/asus-ec-sensors.c static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type, · line 1565
Quoted 7 lines
drivers/hwmon/asus-ec-sensors.c +4
-0@@ -1503,8 +1559,11 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,return ret; sensor_info =get_sensor_info (state, sidx); + ec_sensor =get_ec_sensor_type (state, sidx); +if (state->ext_fan_enabled && ec_sensor >= ec_sensor_fan_ext_1 && + ec_sensor <= ec_sensor_fan_ext_3 && value <ASUS_EC_EXT_FAN_RPM_MIN ) + value =0 ;What is this for?
Quoted 38 lines
drivers/hwmon/asus-ec-sensors.c +10
-3if (sensor_info->type == hwmon_temp) { - ec_sensor =get_ec_sensor_type (state, sidx);if ((environment_temp_sensors &BIT (ec_sensor)) &&is_blank_temperature_value (value))return -ENODATA ;@@ -1601,6 +1660,12 @@ static int asus_ec_probe(struct platform_device *pdev) ec_data->next_update =INITIAL_JIFFIES ;dev_set_drvdata (dev, ec_data); ec_data->board_info = pboard_info; + ec_data->sensor_mask = pboard_info->sensors; + ec_data->ext_fan_enabled = pboard_info->ext_fan_capable && + enable_ext_fan; +if (ec_data->ext_fan_enabled) + ec_data->sensor_mask |=SENSOR_FAN_EXT_1 | +SENSOR_FAN_EXT_2 |SENSOR_FAN_EXT_3 ;switch (ec_data->board_info->family) {case family_amd_400_series:@@ -1645,7 +1710,7 @@ static int asus_ec_probe(struct platform_device *pdev)return -EINVAL ; } - ec_data->nr_sensors =hweight_long (ec_data->board_info->sensors); + ec_data->nr_sensors =hweight_long (ec_data->sensor_mask); ec_data->sensors = devm_kzalloc_objs(dev, struct ec_sensor, ec_data->nr_sensors);if (!ec_data->sensors)@@ -1745,6 +1810,9 @@ module_exit(asus_ec_exit);module_param_named (mutex_path, mutex_path_override, charp,0 );MODULE_PARM_DESC (mutex_path,"Override ACPI mutex path used to guard access to hardware" ); +module_param (enable_ext_fan, bool,0 ); +MODULE_PARM_DESC (enable_ext_fan, +"Enable Fan Extension Card sensors on ROG MAXIMUS XI HERO" );MODULE_AUTHOR ("Eugene Shalygin <[email protected]>" ); MODULE_DESCRIPTION( --Quoted 2 lines
2.54.0 (Apple Git-157)
Cheers,
Eugene
Re: [RFC PATCH v3 3/3] hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors
In reply to Eugene ShalyginHi Eugene,
Quoted 1 line
Have you tried
temperature_blank_values?
Yes, I checked it on the v3 base. All three EXT thermistors are already in environment_temp_sensors. The common check catches -62, -60 and -40, including the explicit BIOS sentinel 0xd8 (-40).
The remaining difference is a range check. The BIOS 2004 getter (PEbiosinterfaceDXE, RVAs 0x46a2..0x46d3) also treats every signed byte below -50 as invalid. For example, 0xcd (-51) is invalid but is absent from the common list; 0xce (-50) is valid.
I compared all 256 possible input bytes for each EXT channel in a host-side check. The common list alone misses 76 byte values that the BIOS rejects. The v3 range check plus the common list matches all 256. This was a software comparison; I haven't measured which code a disconnected probe produces. I'd keep the common list as it is and scope the extra range check to the XI HERO EXT thermistors.
Thanks,
John
Quoted 90 lines · Eugene Shalygin
Hi!
Quoted 58 lines · John den Heijer
BIOS 2004 maps the three optional Fan Extension Card thermistors to EC bank-0 registers
0x60,0x61and0x62. Its getter writes 0x68=0x07 immediately before each read.Reproduce that sequence only for the opted-in non-WiFi XI HERO and return
-ENODATAfor firmware-invalid values. The bit-level meaning of0x68is not established.Signed-off-by John den Heijer <[email protected]>--- drivers/hwmon/asus-ec-sensors.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)drivers/hwmon/asus-ec-sensors.c +18
-0@@ -49,6 +49,8 @@ static bool enable_ext_fan;#define ASUS_EC_EXT_FAN_RPM_MIN 0xa5#define ASUS_EC_EXT_FAN_ENABLE_REGISTER 0xd4#define ASUS_EC_EXT_FAN_CHANNEL_REGISTER 0x89 +#define ASUS_EC_EXT_TEMP_PREPARE_REGISTER 0x68 +#define ASUS_EC_EXT_TEMP_PREPARE_VALUE 0x07#define SENSOR_LABEL_LEN 16/* @@ -413,6 +415,13 @@ static const struct ec_sensor_info sensors_family_intel_300[] = { [ec_sensor_temp_t_sensor] = EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x3d), [ec_sensor_temp_vrm] = EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x3e), +/* BIOS 2004 properties 0x06030032, 0x06030034, 0x06030036 */ + [ec_sensor_temp_sensor_extra_1] = + EC_SENSOR("EXT_Sensor1", hwmon_temp, 1, 0x00, 0x60), + [ec_sensor_temp_sensor_extra_2] = + EC_SENSOR("EXT_Sensor2", hwmon_temp, 1, 0x00, 0x61), + [ec_sensor_temp_sensor_extra_3] = + EC_SENSOR("EXT_Sensor3", hwmon_temp, 1, 0x00, 0x62), [ec_sensor_fan_cpu_opt] = EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0), [ec_sensor_fan_vrm_hs] = EC_SENSOR("VRM HS", hwmon_fan, 2, 0x00, 0xb2),@@ -1411,6 +1420,15 @@ static int asus_ec_block_read(const struct device *dev,if (status) goto restore_select; } +/* BIOS 2004 performs this write before each EXT probe read. */ +if (ec->ext_fan_enabled && !bank && +register_index (ec->registers[ireg]) >=0x60 && +register_index (ec->registers[ireg]) <=0x62 ) { + status =ec_write (ASUS_EC_EXT_TEMP_PREPARE_REGISTER , +ASUS_EC_EXT_TEMP_PREPARE_VALUE ); +if (status) + goto restore_select; + } status =ec_read (register_index (ec->registers[ireg]), ec->read_buffer + ireg);if (status)drivers/hwmon/asus-ec-sensors.c static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type, · line 1587
Quoted 6 lines
drivers/hwmon/asus-ec-sensors.c +3
-0@@ -1564,6 +1582,10 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type, ec_sensor <= ec_sensor_fan_ext_3 && value < ASUS_EC_EXT_FAN_RPM_MIN) value =0 ;if (sensor_info->type == hwmon_temp) { +if (state->ext_fan_enabled && + ec_sensor >= ec_sensor_temp_sensor_extra_1 && + ec_sensor <= ec_sensor_temp_sensor_extra_3 && value <-50 )Have you tried
temperature_blank_values?Quoted 17 lines
drivers/hwmon/asus-ec-sensors.c +5
-2+return -ENODATA ;if ((environment_temp_sensors &BIT (ec_sensor)) &&is_blank_temperature_value (value))return -ENODATA ;@@ -1665,7 +1687,10 @@ static int asus_ec_probe(struct platform_device *pdev) enable_ext_fan;if (ec_data->ext_fan_enabled) ec_data->sensor_mask |=SENSOR_FAN_EXT_1 | -SENSOR_FAN_EXT_2 |SENSOR_FAN_EXT_3 ; +SENSOR_FAN_EXT_2 |SENSOR_FAN_EXT_3 | +SENSOR_TEMP_SENSOR_EXTRA_1 | +SENSOR_TEMP_SENSOR_EXTRA_2 | +SENSOR_TEMP_SENSOR_EXTRA_3 ;switch (ec_data->board_info->family) {case family_amd_400_series: --Quoted 2 lines
2.54.0 (Apple Git-157)
Cheers,
Eugene
Eugene Shalygin
maintainerRe: [RFC PATCH v3 3/3] hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors
Hi John,
Quoted 14 lines · John den Heijer
Hi Eugene,
Quoted 1 line
Have you tried
temperature_blank_values?Yes, I checked it on the v3 base. All three EXT thermistors are already in
environment_temp_sensors. The common check catches -62, -60 and -40, including the explicit BIOS sentinel0xd8(-40).The remaining difference is a range check. The BIOS 2004 getter (PEbiosinterfaceDXE, RVAs 0x46a2..0x46d3) also treats every signed byte below -50 as invalid. For example,
0xcd(-51) is invalid but is absent from the common list;0xce(-50) is valid.
Quoted 4 lines
I compared all 256 possible input bytes for each EXT channel in a host-side check. The common list alone misses 76 byte values that the BIOS rejects. The v3 range check plus the common list matches all 256.
Why do you want to mirror BIOS behaviour so closely?
Quoted 2 lines
This was a software comparison; I haven't measured which code a disconnected probe produces.
Is it hard to do that?
Quoted 1 line
and scope the extra range check to the XI HERO EXT thermistors.
I'd rather let the driver report negative temperature than maintain dedicated blank check for each model. Please don't.
Thanks,
Eugene
Guenter Roeck
maintainerRe: [RFC PATCH v3 3/3] hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors
Quoted 23 lines · Eugene Shalygin
Hi John,
Quoted 14 lines · John den Heijer
Hi Eugene,
Quoted 1 line
Have you tried
temperature_blank_values?Yes, I checked it on the v3 base. All three EXT thermistors are already in
environment_temp_sensors. The common check catches -62, -60 and -40, including the explicit BIOS sentinel0xd8(-40).The remaining difference is a range check. The BIOS 2004 getter (PEbiosinterfaceDXE, RVAs 0x46a2..0x46d3) also treats every signed byte below -50 as invalid. For example,
0xcd(-51) is invalid but is absent from the common list;0xce(-50) is valid.Quoted 4 lines
I compared all 256 possible input bytes for each EXT channel in a host-side check. The common list alone misses 76 byte values that the BIOS rejects. The v3 range check plus the common list matches all 256.
Why do you want to mirror BIOS behaviour so closely?
Quoted 9 lines
Quoted 2 lines
This was a software comparison; I haven't measured which code a disconnected probe produces.
Is it hard to do that?
Quoted 1 line
and scope the extra range check to the XI HERO EXT thermistors.
I'd rather let the driver report negative temperature than maintain dedicated blank check for each model. Please don't.
I agree. Disconnected sensors can be handled with sensors3.conf. That is what it is for.
Guenter
Guenter Roeck
maintainerHi,
Quoted 86 lines · John den Heijer
This is a request for design and safety feedback, not a request to merge the series as-is. It adds opt-in monitoring of the three fan tachometers and three thermistors on an ASUS Fan Extension Card attached to a ROG MAXIMUS XI HERO (non-WiFi), BIOS 2004.
The pinned base is Guenter Roeck's hwmon-next at
8d0f79f49fb10c9f07fee6720551113272a1812b. It already contains the MAXIMUS IX EXTREME selector-based extension fan path and EC 00:60..62 temperature descriptors, but does not select these sensors on XI HERO.The BIOS 2004 image (SHA-256
034e6c688ca41cf448745398ce3ccfa184dfae217287ee7b72039498ff5aa812) provides the following property and transaction evidence:EXT_FAN1/2/3: properties 0x060400e2/e3/e4; write EC 00:43 with selector 0x0a/0x0b/0x0c, then read high/low RPM bytes at 00:57/58. The getter checks EC 00:d4 on every call and performs first-use or lost-latch read-modify-writes d4 |=
0x80and 89 |=0x07.EXT_Sensor1/2/3: properties 0x06030032/34/36; after a firmware card property check, write EC 00:68 =
0x07immediately before each read of 00:60/61/62. The exact meaning of0x68is not established.BIOS 2203 has the same relevant fan mapping and getter control flow. The BIOS presence property, IsEXTFanCardExist (
0x06060050), reads the EXTFanCard UEFI/Setup variable; we have not established a reliable live electrical card-presence signal. Accordingly, the XI HERO extension sensors remain disabled by default and are enabled only by an explicit module parameter on the exact non-WiFi DMI name. The WiFi entry is not changed. With the option enabled, the first read of any hwmon input may trigger a full refresh and the extension setup writes, even if the user did not request an EXT_* attribute.Patch 1 changes generic EC/selector error propagation so a failed block read cannot publish a partial sensor cache. This affects failure paths on all supported boards, not only XI HERO. Patches 2 and 3 add the board opt-in, RPM path and thermistor path. Patch 2 currently relies on the restore/error path introduced by patch 1; we would rebase or reshape the series if the generic change should be reviewed separately.
The new transactions use the driver's configured ACPI EC mutex, normally \AMW0.ASMX on XI HERO. They do not add PWM, fan-control, NCT, direct EC-port or WMI accesses. They do write the EC bank selector, the BIOS observed d4/89 setup registers, the fan selector and
0x68. We do not claim that these writes are harmless when the optional card is absent.A different, locally maintained asus-ec-sensors module for Unraid 7.4.1 / 6.18.64-Unraid has returned all six channels on a physical XI HERO with the card installed, including after one reboot. The binaries and some error/selector handling differ; that test is not a runtime test of this upstream RFC. All three v2 increments compiled with W=1 on both
x86_64and i386. For v3 we fault-injected the actual initialization helper on a host with memory-backed EC stubs. After a lost latch, v2 skipped the retry when either the read or write at0x89failed; v3 repeated both setup writes. The driver object compiled with W=1 and no warnings after each v3 patch onx86_64and i386 with GCC 15.2.0. Onx86_64the v3 module also linked with W=1 against a freshly built vmlinux; modpost completed without diagnostics. We have not run v3 on hardware.Questions for maintainers:
1. Is a default-off, exact-DMI opt-in acceptable when firmware exposes only a Setup-variable-backed card property, or is another presence mechanism required before these EC writes can be accepted?
2. Should the driver preserve the BIOS first-use d4/89 writes even when d4 bit 7 is already set? We have not isolated their necessity and do not want to replace a working BIOS sequence with an untested shortcut.
3. Is reproducing the BIOS's 68=07 write before every thermistor read an acceptable basis while its bit semantics remain unknown? A separate BIOS Extension control initialization path also writes 68=07.
4. Would you prefer patch 1 as a separate bugfix before the board support, and what fault-path regression evidence would be useful?
5. Is the separate non-WiFi board profile and module parameter an appropriate interface, or should the board/card policy be expressed differently?Changes since v2:
- Add Fixes tags for the original block-read and selector error paths.
- Clear the cached initialization flag before attempting either setup write, so a partial recovery can be retried.
- Documentenable_ext_fanand explain the BIOS cutoff of 165 RPM.
- Keep the thermistor patch functionally unchanged.
Quoted 9 lines
John den Heijer (3):
hwmon: (asus-ec-sensors) propagate EC read and selector errors
hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM
hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistorsDocumentation/hwmon/asus_ec_sensors.rst | 7 ++ drivers/hwmon/asus-ec-sensors.c | 142 +++++++++++++++++++++--- 2 files changed, 131 insertions(+), 18 deletions(-)
I asked Sashiko to do a design review on this series. Results are below. This is experimental functionality; it looks valuable to me, but take it with a grain of salt.
Guenter
---
Findings:
Critical: 0 High: 0 Medium: 0 Low: 1
--- Patch [1] hwmon: (asus-ec-sensors) propagate EC read and selector errors --- [Low] hwmon: (asus-ec-sensors) invalid SHA daa4896813b2 in Fixes trailer
Design Assessment (experimental): much_better_alternative
Problem: In the ASUS EC hardware monitoring driver (drivers/hwmon/asus-ec-sensors.c), asus_ec_block_read() ignores return codes from individual EC register reads, selector register reads/writes, and intermediate bank switches, overwriting its return status with the final bank restoration result. Consequently, when an EC read, selector access, or bank switch fails while the final bank switch succeeds, update_ec_sensors() treats the block read as successful and updates cached sensor readings from a partially populated or stale buffer. Additionally, the driver lacks support for reading the three fan tachometer inputs and three thermistor inputs of the optional ASUS Fan Extension Card on the ROG MAXIMUS XI HERO (non-WiFi) motherboard, where firmware requires specific EC register initialization before reading fan channels (which report values below 165 RPM as zero) and a preparatory EC write before reading each thermistor register (which reports unconnected or invalid probes as values below -50 C), and where card presence cannot be reliably auto-detected at runtime.
- [IMPORTANT | better_alternative] Patch 3: asus_ec_block_read() hardcodes a board-specific !bank && register_index(ec->registers[ireg]) >= 0x60 && register_index(ec->registers[ireg]) <= 0x62 check in the inner register read loop to issue ec_write(0x68, 0x07), instead of driving preparatory register writes from sensor or board metadata.
Request: Encode per-register preparatory write requirements or extension-sensor descriptors in the sensor/board metadata (or sensor_address) rather than hardcoding bank 0 and register range 0x60..0x62 inside asus_ec_block_read().
Anchor (baseline_file drivers/hwmon/asus-ec-sensors.c:1254-1262): for (i = 0; i < ec->nr_sensors; ++i) {
si = get_sensor_info(ec, i);
for (j = 0; j < si->addr.components.size; ++j, ++register_idx) {
ec->registers[register_idx] =
(si->addr.components.select << 16) +
(si->addr.components.bank << 8) +
si->addr.components.index + j;
}
}
- [IMPORTANT | implementation_idiom] Patch 3: Patch 3 adds a special-case `value < -50` check in `asus_ec_hwmon_read()` for `ec_sensor_temp_sensor_extra_1..3`, duplicating the existing `environment_temp_sensors` and `is_blank_temperature_value()` mechanism immediately below it (which already includes `SENSOR_TEMP_SENSOR_EXTRA_1..3` and checks `temperature_blank_values[]`).
Request: Use the existing `environment_temp_sensors` and `is_blank_temperature_value()` mechanism (adding the specific blank value to `temperature_blank_values[]` if BIOS 2004 reports a value other than -62, -60, or -40) instead of adding a parallel `value < -50` branch in `asus_ec_hwmon_read()`.
Anchor (baseline_file drivers/hwmon/asus-ec-sensors.c:217-225): static const s32 temperature_blank_values[] = {-62, -60, -40};static const s32 environment_temp_sensors =
SENSOR_TEMP_T_SENSOR | SENSOR_TEMP_T_SENSOR_ALT1 |
SENSOR_TEMP_WATER_IN | SENSOR_TEMP_WATER_OUT |
SENSOR_TEMP_WATER_BLOCK_IN | SENSOR_TEMP_WATER_BLOCK_OUT |
SENSOR_TEMP_T_SENSOR_2 | SENSOR_TEMP_SENSOR_EXTRA_1 |
SENSOR_TEMP_SENSOR_EXTRA_2 | SENSOR_TEMP_SENSOR_EXTRA_3;
Anchor (commit c5ec607bb2165): The MAXIMUS IX EXTREME supports three additional thermistor inputs,
EXT_Sensor1-3, located on the optional ASUS fan extension card. The
EC reports them at bank 0, registers 0x60-0x62, as signed degrees
Celsius, with -60 when no probe is connected (already handled as a
blank value).
- [IMPORTANT | interface] Patch 3: Patch 3 labels ec_sensor_temp_sensor_extra_1..3 as "EXT_Sensor1..3" in sensors_family_intel_300, whereas the driver defines those enum entries and labels the exact same Fan Extension Card thermistors at bank 0 registers 0x60..0x62 in sensors_family_intel_200 (commit c5ec607bb2165) and sensors_family_amd_500 as "Extra_1..3".
Request: Use the established labels "Extra_1", "Extra_2", and "Extra_3" for `ec_sensor_temp_sensor_extra_1..3` to match `sensors_family_intel_200` and `sensors_family_amd_500`, and update `Documentation/hwmon/asus_ec_sensors.rst` (and `MODULE_PARM_DESC`) so users know `enable_ext_fan` also enables the extension card's thermistor inputs and preparatory EC writes.
Anchor (baseline_file drivers/hwmon/asus-ec-sensors.c:169-174): /* "Extra_1" temperature sensor reading [℃] */
ec_sensor_temp_sensor_extra_1,
/* "Extra_2" temperature sensor reading [℃] */
ec_sensor_temp_sensor_extra_2,
/* "Extra_3" temperature sensor reading [℃] */
ec_sensor_temp_sensor_extra_3,
Anchor (baseline_file drivers/hwmon/asus-ec-sensors.c:387-392): [ec_sensor_temp_sensor_extra_1] =
EC_SENSOR("Extra_1", hwmon_temp, 1, 0x00, 0x60),
[ec_sensor_temp_sensor_extra_2] =
EC_SENSOR("Extra_2", hwmon_temp, 1, 0x00, 0x61),
[ec_sensor_temp_sensor_extra_3] =
EC_SENSOR("Extra_3", hwmon_temp, 1, 0x00, 0x62),- [MINOR | convention] Patch 2: In sensors_family_intel_300, ec_sensor_fan_ext_1..3 (bank 0x00, index 0x57) are placed after registers 0x0060..0x0062 and 0x00b0..0x00bc, violating the driver's documented requirement (drivers/hwmon/asus-ec-sensors.c:243-245, commit 0bf08f9e358d3) that sensors_family_* arrays be sorted by ((bank << 8) + index).
Request: Place ec_sensor_fan_ext_1, ec_sensor_fan_ext_2, and ec_sensor_fan_ext_3 (bank 0x00, index 0x57) in ascending ((bank << 8) + index) order in sensors_family_intel_300—right after ec_sensor_temp_vrm (0x00, 0x3e) and before ec_sensor_temp_sensor_extra_1 (0x00, 0x60) and ec_sensor_fan_cpu_opt (0x00, 0xb0). Anchor (baseline_file drivers/hwmon/asus-ec-sensors.c:243-245): All the known sensors for ASUS EC controllers. These arrays have to be sorted
* by the full ((bank << 8) + index) register index (see asus_ec_block_read() as
* to why).
Anchor (commit 0bf08f9e358d3): The arrays have to be sorted by the sensor register bank and index
because this is what the sensor reading function expects. So sort them
and leave a comment for future contributors.
- [MINOR | evidence] Patch 3: Patch 3 does not document what raw EC value is returned when an extension thermistor probe is disconnected on ROG MAXIMUS XI HERO, or why a < -50 threshold is needed instead of the existing sentinel values in temperature_blank_values[] (-62, -60, -40).
Request: Document the actual raw EC register value(s) returned on ROG MAXIMUS XI HERO when an extension thermistor probe is disconnected, and explain why a < -50 threshold is used instead of matching the specific sentinel value in temperature_blank_values[].
Anchor (commit 71a6c1950fa57): When there is no physical sensor connected to the motherboard
socket,reading EC register returns one of the special values
(-62, -60, -40). Test for them and return -ENODATA to hwmon.
Inline Review:
--- Patch [1]: hwmon: (asus-ec-sensors) propagate EC read and selector errors --- commit a5a88f040065c7f33c954cdeea9eec14ea124d1e
Author: John den Heijer <[email protected]>
Quoted 6 lines
hwmon: (asus-ec-sensors) propagate EC read and selector errors
On an EC or selector failure,
asus_ec_block_read()can continue with a partial buffer. A successful final bank restore then reports success, soupdate_ec_sensors()publishes stale bytes.
Quoted 8 lines
Propagate the first error. Attempt selector restoration in its bank, then restore the original bank. A failed restore also rejects the update. This changes the failure path for all supported boards.
Fixes d0ddfd241e57 ("hwmon: (asus-ec-sensors) add driver for ASUS EC")Fixes daa4896813b2 ("hwmon: (asus-ec-sensors) add fan extension card fans for MAXIMUS IX EXTREME")Signed-off-by John den Heijer <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
[Severity: Low]
The second Fixes: trailer cites daa4896813b2, which does not exist in the repository history. Should this reference a88044f4bf74 ("hwmon:
(asus-ec-sensors) add fan extension card fans for MAXIMUS IX EXTREME") instead?
Tokens: 4383691 in / 63370 out / 3365139 cached