diff mbox

[V8,7/8] sensors: occ: Skip the deconfigured core sensors

Message ID 1500635680-26245-8-git-send-email-shilpa.bhat@linux.vnet.ibm.com
State Superseded
Headers show

Commit Message

Shilpasri G Bhat July 21, 2017, 11:14 a.m. UTC
This patch skips the deconfigured cores from the core sensors while
parsing the sensor names in the main memory.

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

Comments

Stewart Smith July 27, 2017, 8:57 a.m. UTC | #1
Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> writes:
> This patch skips the deconfigured cores from the core sensors while
> parsing the sensor names in the main memory.

Are the sensors for deconfigured cores incorrect or non-functional?

If we can read them, I'd say we should include them.
Shilpasri G Bhat July 27, 2017, 9:38 a.m. UTC | #2
On 07/27/2017 02:27 PM, Stewart Smith wrote:
> Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> writes:
>> This patch skips the deconfigured cores from the core sensors while
>> parsing the sensor names in the main memory.
> 
> Are the sensors for deconfigured cores incorrect or non-functional?
> 
> If we can read them, I'd say we should include them.
> 

The sensor values corresponding to deconfigured cores are zero and are not
updated by OCC.
diff mbox

Patch

diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c
index c6e02aa..15b6031 100644
--- a/hw/occ-sensor.c
+++ b/hw/occ-sensor.c
@@ -19,6 +19,7 @@ 
 #include <chip.h>
 #include <sensor.h>
 #include <device.h>
+#include <cpu.h>
 
 /*
  * OCC Sensor Data
@@ -466,9 +467,11 @@  static void add_sensor_label(struct dt_node *node, struct occ_sensor_name *md,
 		if (!strncmp(str_maps[i].occ_str, md->name,
 			     strlen(str_maps[i].occ_str))) {
 			char *end;
-			int num;
+			int num = -1;
+
+			if (md->location != OCC_SENSOR_LOC_CORE)
+				num = parse_entity(md->name, &end);
 
-			num = parse_entity(md->name, &end);
 			if (num != -1) {
 				snprintf(sname, sizeof(sname), "%s%s %d %s",
 					 prefix, str_maps[i].opal_str, num,
@@ -565,11 +568,22 @@  void occ_sensors_init(void)
 			char name[30];
 			const char *type, *loc;
 			struct dt_node *node;
+			struct cpu_thread *c = NULL;
 			u32 handler;
 
 			if (!(md[i].type & HWMON_SENSORS_MASK))
 				continue;
 
+			if (md[i].location == OCC_SENSOR_LOC_CORE) {
+				int num = parse_entity(md[i].name, NULL);
+
+				for_each_available_core_in_chip(c, chip->id)
+					if (pir_to_core_id(c->pir) == num)
+						break;
+				if (!c)
+					continue;
+			}
+
 			type = get_sensor_type_string(md[i].type);
 			loc = get_sensor_loc_string(md[i].location);
 			snprintf(name, sizeof(name), "%s-%s", loc, type);
@@ -590,6 +604,9 @@  void occ_sensors_init(void)
 					       "ibm,opal-sensor");
 			dt_add_property_string(node, "occ_label", md[i].name);
 			add_sensor_label(node, &md[i], chip->id);
+
+			if (md[i].location == OCC_SENSOR_LOC_CORE)
+				dt_add_property_cells(node, "ibm,pir", c->pir);
 		}
 		occ_num++;
 	}