Skip to contentSkip to conversation

hwmon: (asus-ec-sensors) add ROG STRIX X870E-E GAMING WIFI7 R2

PATCH Applied Eugene Shalygin 3 participants 12 messages Jul 9 – Jul 11

Subsystems (3)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore

Eugene Shalygin

author maintainer
#0 lore raw

cover hwmon: (asus-ec-sensors) add ROG STRIX X870E-E GAMING WIFI7 R2

Add ROG STRIX X870E-E GAMING WIFI7 R2, which is a copy of ROG STRIX X870E-E GAMING WIFI7 sensor-wise, and thus enable discovered T_Sensor for the original board as well.

Vishaal Saraiya (2):
hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING
WIFI
hwmon: (asus-ec-sensors) add ROG STRIX X870E-E GAMING WIFI7 R2

 Documentation/hwmon/asus_ec_sensors.rst | 1 +
 drivers/hwmon/asus-ec-sensors.c         | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.55.0
author maintainer
#1 lore raw

PATCH 1/2 hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

From: Vishaal Saraiya <[email protected]>

Enable T_Sensor for ROG STRIX X870E-E GAMING WIFI. Board specs list the sensor, reading return -62, which is one of the blank values for temperature sensors in the ASUS EC.

---
 drivers/hwmon/asus-ec-sensors.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/asus-ec-sensors.c +1 -1
index 29a23484cbe7..742520c485ca 100644
@@ -743,7 +743,7 @@ static const struct ec_board_info board_info_strix_x870_i_gaming_wifi = {
 
 static const struct ec_board_info board_info_strix_x870e_e_gaming_wifi = {
 	.sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE |
-		SENSOR_TEMP_MB | SENSOR_TEMP_VRM |
+		SENSOR_TEMP_MB | SENSOR_TEMP_VRM | SENSOR_TEMP_T_SENSOR |
 		SENSOR_FAN_CPU_OPT,
 	.mutex_path = ASUS_HW_ACCESS_MUTEX_SB_PCI0_SBRG_SIO1_MUT0,
 	.family = family_amd_800_series,
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH 1/2] hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] The patch enables a sensor that returns a specific 'blank' value (-62) without filtering it, resulting in a bogus temperature being reported to userspace.

Pre-existing issues:
- [High] Missing bounds check in asus_ec_block_read() causes unintended reads of EC registers from the wrong bank. --

--- Patch [1]: [PATCH 1/2] hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI --- commit 65789a63d90e6f671eaa090793abd6eb2ac05064
Author: Vishaal Saraiya <[email protected]>

hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

Enable T_Sensor for ROG STRIX X870E-E GAMING WIFI. Board specs list the sensor, reading return -62, which is one of the blank values for temperature sensors in the ASUS EC.

drivers/hwmon/asus-ec-sensors.c static const struct ec_board_info board_info_strix_x870_i_gaming_wifi = { · line 746

Quoted 10 lines
drivers/hwmon/asus-ec-sensors.c +1 -1
index 29a23484cbe7b..742520c485ca6 100644
@@ -743,7 +743,7 @@ static const struct ec_board_info board_info_strix_x870_i_gaming_wifi = {
 
 static const struct ec_board_info board_info_strix_x870e_e_gaming_wifi = {
 	.sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE |
-		SENSOR_TEMP_MB | SENSOR_TEMP_VRM |
+		SENSOR_TEMP_MB | SENSOR_TEMP_VRM | SENSOR_TEMP_T_SENSOR |

[Severity: Medium]
Since the commit message notes that an unpopulated T_Sensor returns a blank value of -62, will this regression result in reporting a bogus extreme negative temperature (-62000 mC) to userspace?

Looking at asus_ec_hwmon_read(), the driver does not appear to filter out this known blank value before scaling and returning it:

	ret = get_cached_value_or_update(dev, sidx, state, &value);
	if (!ret) {
		*val = scale_sensor_value(value,
					  get_sensor_info(state, sidx)->type);
	}

Could this bogus value confuse thermal daemons and cause them to incorrectly spin down fans?

drivers/hwmon/asus-ec-sensors.c static const struct ec_board_info board_info_strix_x870_i_gaming_wifi = { · line 749

Quoted 3 lines
drivers/hwmon/asus-ec-sensors.c +0 -0
 		SENSOR_FAN_CPU_OPT,
 	.mutex_path = ASUS_HW_ACCESS_MUTEX_SB_PCI0_SBRG_SIO1_MUT0,
 	.family = family_amd_800_series,

[ ... ]

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential missing bounds check in asus_ec_block_read() that might cause unintended reads of EC registers from the wrong bank:

drivers/hwmon/asus-ec-sensors.c:asus_ec_block_read() {
    ...
	reg_bank = register_bank(ec->registers[ireg]);
	if (reg_bank < bank) {
		continue;
	}
	ec_read(register_index(ec->registers[ireg]),
		ec->read_buffer + ireg);
    ...
}

Because the loop only skips registers where reg_bank < bank, will this issue reads for registers belonging to higher banks while the EC is still switched to a lower bank?

Could this read incorrect hardware registers and potentially cause hardware misbehavior due to side-effects, as well as trigger redundant, slow ACPI reads?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#3 lore raw

Re: [PATCH 1/2] hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

In reply to Eugene Shalygin
Quoted 6 lines · Eugene Shalygin

From: Vishaal Saraiya <[email protected]>

Enable T_Sensor for ROG STRIX X870E-E GAMING WIFI. Board specs list the sensor, reading return -62, which is one of the blank values for temperature sensors in the ASUS EC.

Just like Sashiko, I don't really understand this patch or, rather, its description. What is the point of adding a sensor which is expected to return -62 ?

Guenter

Quoted 19 lines
---
  drivers/hwmon/asus-ec-sensors.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/asus-ec-sensors.c +1 -1
index 29a23484cbe7..742520c485ca 100644
@@ -743,7 +743,7 @@ static const struct ec_board_info board_info_strix_x870_i_gaming_wifi = {
 
  static const struct ec_board_info board_info_strix_x870e_e_gaming_wifi = {
  	.sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE |
-		SENSOR_TEMP_MB | SENSOR_TEMP_VRM |
+		SENSOR_TEMP_MB | SENSOR_TEMP_VRM | SENSOR_TEMP_T_SENSOR |
  		SENSOR_FAN_CPU_OPT,
  	.mutex_path = ASUS_HW_ACCESS_MUTEX_SB_PCI0_SBRG_SIO1_MUT0,
  	.family = family_amd_800_series,
author maintainer
#4 lore raw

Re: [PATCH 1/2] hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

Hi Guenter,

Quoted 9 lines · Guenter Roeck
Quoted 5 lines

Enable T_Sensor for ROG STRIX X870E-E GAMING WIFI. Board specs list the sensor, reading return -62, which is one of the blank values for temperature sensors in the ASUS EC.

Just like Sashiko, I don't really understand this patch or, rather, its description. What is the point of adding a sensor which is expected to return -62 ?

The motherboard provides sockets where users can connect thermistors (T_Sensor, Water_In, Water_Out). When the socket is empty, readings the sensor value returns a special blank value, which is -40 for older board generations (maybe BIOSes?) and -62 for the newer ones. It is a good flag that the temperature sensor "exists" at the given EC registry index. Hope this clarifies the motivations behind the commit.

I should have noted those values and properly return -ENODATA, but now I'm not sure which board family uses which value. I will try to salvage this information from my notes and the Libre Hardware Monitor project (where I implemented blanks from the beginning and users fill that bit of information when adding support for their motherboards), but for now the driver returns those blank values as is when actual sensor is not connected. If that fails I will likely test for both for all the boards... Anyhow, this shortcomings will be addressed.

Cheers,
Eugene

maintainer
#5 lore raw

Re: [PATCH 1/2] hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

Eugene,

Quoted 20 lines · Eugene Shalygin

Hi Guenter,

Quoted 9 lines · Guenter Roeck
Quoted 5 lines

Enable T_Sensor for ROG STRIX X870E-E GAMING WIFI. Board specs list the sensor, reading return -62, which is one of the blank values for temperature sensors in the ASUS EC.

Just like Sashiko, I don't really understand this patch or, rather, its description. What is the point of adding a sensor which is expected to return -62 ?

The motherboard provides sockets where users can connect thermistors (T_Sensor, Water_In, Water_Out). When the socket is empty, readings the sensor value returns a special blank value, which is -40 for older board generations (maybe BIOSes?) and -62 for the newer ones. It is a good flag that the temperature sensor "exists" at the given EC registry index. Hope this clarifies the motivations behind the commit.

Quoted 9 lines

I should have noted those values and properly return -ENODATA, but now I'm not sure which board family uses which value. I will try to salvage this information from my notes and the Libre Hardware Monitor project (where I implemented blanks from the beginning and users fill that bit of information when adding support for their motherboards), but for now the driver returns those blank values as is when actual sensor is not connected. If that fails I will likely test for both for all the boards... Anyhow, this shortcomings will be addressed.

Do you expect me (or anyone else) to be able to deduct that from the patch description above ?

Guenter

author maintainer
#6 lore raw

Re: [PATCH 1/2] hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

Guenter,

Quoted 2 lines · Guenter Roeck

Do you expect me (or anyone else) to be able to deduct that from the patch description above ?

Would it be OK with you if I simply submit v2 with elaborated explanation, and add those blank value to the code later?

Eugene

maintainer
#7 lore raw

Re: [PATCH 1/2] hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

Quoted 9 lines · Eugene Shalygin

Guenter,

Quoted 2 lines · Guenter Roeck

Do you expect me (or anyone else) to be able to deduct that from the patch description above ?

Would it be OK with you if I simply submit v2 with elaborated explanation, and add those blank value to the code later?

Yes.

That makes me wonder, though: Are you sure that the negative temperature sensor values are not really error codes ?

Thanks,
Guenter

author maintainer
#8 lore raw

Re: [PATCH 1/2] hwmon: (asus-ec-sensors) add T_Sensor for ROG STRIX X870E-E GAMING WIFI

Quoted 2 lines · Guenter Roeck

That makes me wonder, though: Are you sure that the negative temperature sensor values are not really error codes ?

Does it matter? I know one of those two values (-40 or -62) are delivered by the EC when thermistor is not connected (i.e. the resistance is infinite). It allows us to detect EC registers with temperature sensors and the driver to detect whether the [hysical sensor is connected.

Eugene

author maintainer
#9 lore raw

PATCH 2/2 hwmon: (asus-ec-sensors) add ROG STRIX X870E-E GAMING WIFI7 R2

In reply to Eugene Shalygin

From: Vishaal Saraiya <[email protected]>

The board sensors is a copy of ROG STRIX X870E-E GAMING WIFI7, thus we simply reuse its board_info struct.

---
 Documentation/hwmon/asus_ec_sensors.rst | 1 +
 drivers/hwmon/asus-ec-sensors.c         | 2 ++
 2 files changed, 3 insertions(+)
Documentation/hwmon/asus_ec_sensors.rst +1 -0
index 77a709517437..e288f8ed6602 100644
@@ -47,6 +47,7 @@ Supported boards:
  * ROG STRIX X870-F GAMING WIFI
  * ROG STRIX X870-I GAMING WIFI
  * ROG STRIX X870E-E GAMING WIFI
+ * ROG STRIX X870E-E GAMING WIFI7 R2
  * ROG STRIX X870E-H GAMING WIFI7
  * ROG STRIX Z390-F GAMING
  * ROG STRIX Z490-F GAMING
drivers/hwmon/asus-ec-sensors.c +2 -0
index 742520c485ca..473157b5f739 100644
@@ -927,6 +927,8 @@ static const struct dmi_system_id dmi_table[] = {
 					&board_info_strix_x870_i_gaming_wifi),
 	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X870E-E GAMING WIFI",
 					&board_info_strix_x870e_e_gaming_wifi),
+	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X870E-E GAMING WIFI7 R2",
+					&board_info_strix_x870e_e_gaming_wifi),
 	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X870E-H GAMING WIFI7",
 					&board_info_strix_x870e_h_gaming_wifi7),
 	DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX Z390-F GAMING",
Signature · 1 line
2.55.0
#10 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines

From: Vishaal Saraiya <[email protected]>

The board sensors is a copy of ROG STRIX X870E-E GAMING WIFI7, thus we simply reuse its board_info struct.

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=2