Skip to contentSkip to conversation

hwmon: (pmbus) Improve fan detection

PATCH In review Guenter Roeck 2 participants 5 messages Jun 30, 2011 – Jul 3, 2011 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 hwmon: (pmbus) Improve fan detection

Some PMBus devices return no error when reading fan speed registers, but don't really support fans. Strengthen fan detection by also checking if fan configuration registers exist.

---
 drivers/hwmon/pmbus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus.c +4 -2
index 98e2e28..b0ea00b 100644
@@ -47,12 +47,14 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
 	if (info->func[0]
 	    && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT))
 		info->func[0] |= PMBUS_HAVE_STATUS_INPUT;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) &&
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
 		info->func[0] |= PMBUS_HAVE_FAN12;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN12;
 	}
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) &&
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
 		info->func[0] |= PMBUS_HAVE_FAN34;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN34;
Signature · 7 lines
1.7.3.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw

Hi Guenter,

Quoted 20 lines · Guenter Roeck

Some PMBus devices return no error when reading fan speed registers, but don't really support fans. Strengthen fan detection by also checking if fan configuration registers exist.

---
 drivers/hwmon/pmbus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus.c +2 -1
index 98e2e28..b0ea00b 100644
@@ -47,12 +47,14 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
 	if (info->func[0]
 	    && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT))
 		info->func[0] |= PMBUS_HAVE_STATUS_INPUT;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) &&
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {

drivers/hwmon/pmbus.c static void pmbus_find_sensor_groups(struct i2c_client *client, · line 60

Quoted 10 lines
drivers/hwmon/pmbus.c +2 -1
 		info->func[0] |= PMBUS_HAVE_FAN12;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN12;
 	}
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) &&
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
 		info->func[0] |= PMBUS_HAVE_FAN34;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN34;

Then wouldn't it be sufficient to only test PMBUS_FAN_CONFIG_12 and PMBUS_FAN_CONFIG_34, respectively? This would make the function somewhat faster.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Guenter Roeck

Hi Jean,

Quoted 29 lines · Jean Delvare

Hi Guenter,

Quoted 26 lines · Guenter Roeck

Some PMBus devices return no error when reading fan speed registers, but don't really support fans. Strengthen fan detection by also checking if fan configuration registers exist.

---
 drivers/hwmon/pmbus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus.c +3 -2
index 98e2e28..b0ea00b 100644
@@ -47,12 +47,14 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
 	if (info->func[0]
 	    && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT))
 		info->func[0] |= PMBUS_HAVE_STATUS_INPUT;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) &&
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
 		info->func[0] |= PMBUS_HAVE_FAN12;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN12;
 	}
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) &&
Quoted 8 lines

drivers/hwmon/pmbus.c static void pmbus_find_sensor_groups(struct i2c_client *client, · line 60

Quoted 4 lines
drivers/hwmon/pmbus.c +1 -0
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
 		info->func[0] |= PMBUS_HAVE_FAN34;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN34;

Then wouldn't it be sufficient to only test PMBUS_FAN_CONFIG_12 and PMBUS_FAN_CONFIG_34, respectively? This would make the function somewhat faster.

I'd rather keep both. Devices should not return a valid value or should at least set the command error flag in the status register if they don't support fans and the fan speed register is read. If I can't trust that (and I can't because Intersil devices do just that), I can not trust the configuration register either.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw
In reply to Guenter Roeck
Quoted 41 lines · Guenter Roeck

Hi Jean,

Quoted 29 lines · Jean Delvare

Hi Guenter,

Quoted 26 lines · Guenter Roeck

Some PMBus devices return no error when reading fan speed registers, but don't really support fans. Strengthen fan detection by also checking if fan configuration registers exist.

---
 drivers/hwmon/pmbus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus.c +3 -2
index 98e2e28..b0ea00b 100644
@@ -47,12 +47,14 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
 	if (info->func[0]
 	    && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT))
 		info->func[0] |= PMBUS_HAVE_STATUS_INPUT;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) &&
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
 		info->func[0] |= PMBUS_HAVE_FAN12;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN12;
 	}
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) &&
Quoted 8 lines

drivers/hwmon/pmbus.c static void pmbus_find_sensor_groups(struct i2c_client *client, · line 60

Quoted 4 lines
drivers/hwmon/pmbus.c +1 -0
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
 		info->func[0] |= PMBUS_HAVE_FAN34;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN34;

Then wouldn't it be sufficient to only test PMBUS_FAN_CONFIG_12 and PMBUS_FAN_CONFIG_34, respectively? This would make the function somewhat faster.

Quoted 4 lines

I'd rather keep both. Devices should not return a valid value or should at least set the command error flag in the status register if they don't support fans and the fan speed register is read. If I can't trust that (and I can't because Intersil devices do just that), I can not trust the configuration register either.

I think that what worries me is the asymmetry. Is it not possible for a device to have FAN_SPEED_2 and not FAN_SPEED_1? If not then your code is fine, I agree. But if it is possible, then we need smarter code.

But also note that I don't know a thing about PMBus, so there may be nothing to worry about.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#4 lore raw
In reply to Guenter Roeck
Quoted 42 lines · Jean Delvare
Quoted 41 lines · Guenter Roeck

Hi Jean,

Quoted 37 lines · Jean Delvare

Hi Guenter,

Quoted 20 lines · Guenter Roeck

Some PMBus devices return no error when reading fan speed registers, but don't really support fans. Strengthen fan detection by also checking if fan configuration registers exist.

---
 drivers/hwmon/pmbus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus.c +2 -1
index 98e2e28..b0ea00b 100644
@@ -47,12 +47,14 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
 	if (info->func[0]
 	    && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT))
 		info->func[0] |= PMBUS_HAVE_STATUS_INPUT;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) &&
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {

drivers/hwmon/pmbus.c static void pmbus_find_sensor_groups(struct i2c_client *client, · line 60

Quoted 10 lines
drivers/hwmon/pmbus.c +2 -1
 		info->func[0] |= PMBUS_HAVE_FAN12;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN12;
 	}
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
+	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) &&
+	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) {
 		info->func[0] |= PMBUS_HAVE_FAN34;
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN34;

Then wouldn't it be sufficient to only test PMBUS_FAN_CONFIG_12 and PMBUS_FAN_CONFIG_34, respectively? This would make the function somewhat faster.

Quoted 9 lines
Quoted 4 lines

I'd rather keep both. Devices should not return a valid value or should at least set the command error flag in the status register if they don't support fans and the fan speed register is read. If I can't trust that (and I can't because Intersil devices do just that), I can not trust the configuration register either.

I think that what worries me is the asymmetry. Is it not possible for a device to have FAN_SPEED_2 and not FAN_SPEED_1? If not then your code is fine, I agree. But if it is possible, then we need smarter code.

With PMBus, everything is possible ;). It is pretty much impossible to cover all possible variants. Who would have thought that the fan speed register would return a value even though the device doesn't support fans ?

My approach is to get my hand on as many PMBus devices as possible and improve the code whenever I find something new. So far the manufacturers have almost never failed to surprise me - it is almost as if there is a competition to find as many interpretations of the standard as possible.

I have some work to do to improve fan support anyway, so I'll keep this in mind. I think for the time being we are good.

Quoted 3 lines

But also note that I don't know a thing about PMBus, so there may be nothing to worry about.

Not even sure if it is _possible_ to completely understand PMBus ...

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors