[Skiboot] [PATCH v2 06/11] Nest MCS unit support

Madhavan Srinivasan maddy at linux.vnet.ibm.com
Tue Jul 21 16:38:46 AEST 2015


Patch adds support for Nest Memory Control (MCS) unit. Power8
has four MCS per chip. Both unit and scale information for each mcs
event passed as DT entry to kernel.

Signed-off-by: Madhavan Srinivasan <maddy at linux.vnet.ibm.com>
---
 hw/nest.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/hw/nest.c b/hw/nest.c
index 46a60f3168e2..01f5a6348f0f 100644
--- a/hw/nest.c
+++ b/hw/nest.c
@@ -25,6 +25,8 @@
 #include <opal-api.h>
 #include <io.h>
 
+#define MAX_NAME_SIZE	64
+
 /*
  * Pointer holding the Catalogue file in memory
  */
@@ -38,6 +40,66 @@ struct nest_catalogue_ptr *c_ptr;
  */
 struct nest_catalog_page_0 *page0_ptr;
 
+static u32 get_chip_event_offset (int idx )
+{
+	char *marker = CHIP_EVENT_ENTRY(c_ptr);
+	struct nest_catalogue_event_data *ev;
+	int i;
+
+	ev = (struct nest_catalogue_event_data *) marker;
+	for (i=0; i < idx ; i++) {
+		marker += ev->length;
+		ev = (struct nest_catalogue_event_data *) marker;
+	}
+
+	return (ev->event_group_record_offs + ev->event_counter_offs);
+}
+
+int dt_create_nest_chip_mcs_event(struct dt_node *ima, int idx, u32 offset)
+{
+	char ev_name[MAX_NAME_SIZE];
+	const char *unit = "MiB", *scale = "1.2207e-4";
+
+	snprintf(ev_name, MAX_NAME_SIZE, "MCS_0%d", idx);
+	dt_add_property_cells(ima, ev_name, offset);
+
+	/* Unit for the Event */
+	snprintf(ev_name, MAX_NAME_SIZE, "unit.MCS_0%d.unit", idx);
+	dt_add_property_string(ima, ev_name, unit);
+
+	/* Scale for the Event */
+	snprintf(ev_name, MAX_NAME_SIZE, "scale.MCS_0%d.scale", idx);
+	dt_add_property_string(ima, ev_name, scale);
+
+	return 0;
+}
+
+int dt_create_nest_chip_mcs_type( struct dt_node *ima,
+		struct nest_catalogue_group_data *gptr, char *name)
+{
+	struct dt_node *type;
+	int idx;
+	u32 offset;
+
+	type = dt_new(ima, name);
+	if (!type) {
+		prlog(PR_DEBUG, "nest_ima %s type creation failed \n", name);
+		return -1;
+	}
+
+	/*
+	 *  Create DT entry for only first 4 events in this group
+	 *  Looks like each group as repeated same events.
+	 */
+	dt_add_property_string(type, "device_type", "nest-ima-unit");
+	for (idx=0; idx < (gptr->event_count / 2); idx++) {
+		offset = get_chip_event_offset( gptr->event_index[idx]);
+		dt_create_nest_chip_mcs_event(type, idx, offset);
+	}
+
+	return 0;
+}
+
 /*
  * Wrapper Function to call Corresponding Nest unit functions
  * for event dt creation. Not all the Chip Groups in the Catalog are
@@ -46,8 +108,24 @@ struct nest_catalog_page_0 *page0_ptr;
 int dt_create_nest_chip_type (struct dt_node *ima,
                 struct nest_catalogue_group_data *gptr)
 {
+	char *name;
+
+	name = malloc(gptr->group_name_len);
+	if (!name)
+		return OPAL_NO_MEM;
+
+	memcpy((void *)name, (void *)gptr->remainder, gptr->group_name_len);
+	if (strstr(name, "MCS_")) {
+		if (dt_create_nest_chip_mcs_type(ima, gptr,name))
+			goto out;
+	} else
+		goto out;
 
 	return OPAL_SUCCESS;
+
+out:
+	free(name);
+	return OPAL_RESOURCE;
 }
 
 int dt_create_nest_chip_types(struct dt_node *ima)
-- 
1.9.1



More information about the Skiboot mailing list