diff mbox series

[2/2] sensors: occ: Skip power sensors with zero sample value

Message ID 1516340157-27298-2-git-send-email-shilpa.bhat@linux.vnet.ibm.com
State Accepted
Headers show
Series [1/2] sensors: occ: Skip GPU sensors for non-gpu systems | expand

Commit Message

Shilpasri G Bhat Jan. 19, 2018, 5:35 a.m. UTC
APSS is not avialable on platforms like Zaius, Romulus where OCC
can only measure Vdd (core) and Vdn (nest) power from the AVSbus
reading. So all the sensors for APSS channels will be populated
with 0. Different component power sensors like system, memory
which point to the APSS channels will also be 0.

As per OCC team (Martha Broyles) zero'ed power sensor means that the
system doesnot have it. So this patch filters out these sensors.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
 hw/occ-sensor.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c
index 72c8964..1e103cb 100644
--- a/hw/occ-sensor.c
+++ b/hw/occ-sensor.c
@@ -548,6 +548,23 @@  static const char *get_sensor_loc_string(enum occ_sensor_location loc)
 	return "unknown";
 }
 
+/*
+ * Power sensors can be 0 valued in few platforms like Zaius, Romulus
+ * which do not have APSS. At the moment there is no HDAT/DT property
+ * to indicate if APSS is present. So for now skip zero valued power
+ * sensors.
+ */
+static bool check_sensor_sample(struct occ_sensor_data_header *hb, u32 offset)
+{
+	struct occ_sensor_record *ping, *pong;
+
+	ping = (struct occ_sensor_record *)((u64)hb + hb->reading_ping_offset
+					     + offset);
+	pong = (struct occ_sensor_record *)((u64)hb + hb->reading_pong_offset
+					     + offset);
+	return ping->sample || pong->sample;
+}
+
 void occ_sensors_init(void)
 {
 	struct proc_chip *chip;
@@ -611,6 +628,10 @@  void occ_sensors_init(void)
 			if (md[i].location == OCC_SENSOR_LOC_GPU && !has_gpu)
 				continue;
 
+			if (md[i].type == OCC_SENSOR_TYPE_POWER &&
+			    !check_sensor_sample(hb, md[i].reading_offset))
+				continue;
+
 			if (md[i].location == OCC_SENSOR_LOC_CORE) {
 				int num = parse_entity(md[i].name, NULL);