Skip to contentSkip to conversation

hwmon (occ): Add temp sensor value check

PATCH Applied Joel Stanley 3 participants 3 messages Jul 10, 2019 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon (occ): Add temp sensor value check

From: Alexander Soldatov <[email protected]>

The occ driver supports two formats for the temp sensor value.

The OCC firmware for P8 supports only the first format, for which no range checking or error processing is performed in the driver. Inspecting the OCC sources for P8 reveals that OCC may send a special value 0xFFFF to indicate that a sensor read timeout has occurred, see

https://github.com/open-power/occ/blob/master_p8/src/occ/cmdh/cmdh_fsp_cmds.c#L395

That situation wasn't handled in the driver. This patch adds invalid temp value check for the sensor data format 1 and handles it the same way as it is done for the format 2, where EREMOTEIO is reported for this case.

Fixes 54076cb3b5ff ("hwmon (occ): Add sensor attributes and register hwmon device")
---
 drivers/hwmon/occ/common.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/hwmon/occ/common.c +6 -0
index cccf91742c1a..a7d2b16dd702 100644
@@ -241,6 +241,12 @@ static ssize_t occ_show_temp_1(struct device *dev,
 		val = get_unaligned_be16(&temp->sensor_id);
 		break;
 	case 1:
+		/*
+		 * If a sensor reading has expired and couldn't be refreshed,
+		 * OCC returns 0xFFFF for that sensor.
+		 */
+		if (temp->value == 0xFFFF)
+			return -EREMOTEIO;
 		val = get_unaligned_be16(&temp->value) * 1000;
 		break;
 	default:
Signature · 1 line
2.20.1
#1 lore raw

Thanks, Joel!

JFYI, Alexander Soldatov has left the YADRO team some time ago, so his e-mail @yadro.com isn't valid anymore.

Should anyone have any questions regarding this patch, feel free to email me.

With best regards,
Alexander Amelkin,
Leading BMC Software Engineer, YADRO
https://yadro.com

Quoted 44 lines · Joel Stanley

From: Alexander Soldatov <[email protected]>

The occ driver supports two formats for the temp sensor value.

The OCC firmware for P8 supports only the first format, for which no range checking or error processing is performed in the driver. Inspecting the OCC sources for P8 reveals that OCC may send a special value 0xFFFF to indicate that a sensor read timeout has occurred, see

https://github.com/open-power/occ/blob/master_p8/src/occ/cmdh/cmdh_fsp_cmds.c#L395

That situation wasn't handled in the driver. This patch adds invalid temp value check for the sensor data format 1 and handles it the same way as it is done for the format 2, where EREMOTEIO is reported for this case.

Fixes 54076cb3b5ff ("hwmon (occ): Add sensor attributes and register hwmon device")
---
 drivers/hwmon/occ/common.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/hwmon/occ/common.c +6 -0
index cccf91742c1a..a7d2b16dd702 100644
@@ -241,6 +241,12 @@ static ssize_t occ_show_temp_1(struct device *dev,
 		val = get_unaligned_be16(&temp->sensor_id);
 		break;
 	case 1:
+		/*
+		 * If a sensor reading has expired and couldn't be refreshed,
+		 * OCC returns 0xFFFF for that sensor.
+		 */
+		if (temp->value == 0xFFFF)
+			return -EREMOTEIO;
 		val = get_unaligned_be16(&temp->value) * 1000;
 		break;
 	default:
maintainer Applied
#2 lore raw
In reply to Joel Stanley
Quoted 17 lines · Joel Stanley

From: Alexander Soldatov <[email protected]>

The occ driver supports two formats for the temp sensor value.

The OCC firmware for P8 supports only the first format, for which no range checking or error processing is performed in the driver. Inspecting the OCC sources for P8 reveals that OCC may send a special value 0xFFFF to indicate that a sensor read timeout has occurred, see

https://github.com/open-power/occ/blob/master_p8/src/occ/cmdh/cmdh_fsp_cmds.c#L395

That situation wasn't handled in the driver. This patch adds invalid temp value check for the sensor data format 1 and handles it the same way as it is done for the format 2, where EREMOTEIO is reported for this case.

Quoted 6 lines
Fixes 54076cb3b5ff ("hwmon (occ): Add sensor attributes and register hwmon device")

Applied.

Thanks,
Guenter

Quoted 21 lines
---
 drivers/hwmon/occ/common.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/hwmon/occ/common.c +6 -0
index cccf91742c1a..a7d2b16dd702 100644
@@ -241,6 +241,12 @@ static ssize_t occ_show_temp_1(struct device *dev,
 		val = get_unaligned_be16(&temp->sensor_id);
 		break;
 	case 1:
+		/*
+		 * If a sensor reading has expired and couldn't be refreshed,
+		 * OCC returns 0xFFFF for that sensor.
+		 */
+		if (temp->value == 0xFFFF)
+			return -EREMOTEIO;
 		val = get_unaligned_be16(&temp->value) * 1000;
 		break;
 	default: