[Skiboot] [RESEND PATCH v1 06/11]ibm-fsp/firenze: Nest MCS unit support

Madhavan Srinivasan maddy at linux.vnet.ibm.com
Mon Jul 6 02:55:28 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      | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 include/nest.h |  3 +++
 2 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/hw/nest.c b/hw/nest.c
index dd03c3a..2d5a331 100644
--- a/hw/nest.c
+++ b/hw/nest.c
@@ -26,12 +26,78 @@
 #include <opal-api.h>
 #include <io.h>
 
+#define MAX_NAME_SIZE   64
+
 /*
  * Optimize different array/index
  */
 struct ima_catalog_page_0 *page0_ptr;
 struct page0_offsets *pg0_offsets;
 
+static u32 get_chip_event_offset (int idx )
+{
+	char *marker = CHIP_EVENT_ENTRY(pg0_offsets);
+	struct ima_catalogue_event_data *ev;
+	int i;
+
+	ev = (struct ima_catalogue_event_data *) marker;
+	for (i=0; i < idx ; i++) {
+		marker += ev->length;
+		ev = (struct ima_catalogue_event_data *) marker;
+	}
+
+	return (ev->event_group_record_offs+ev->event_counter_offs);
+}
+
+int dt_create_ima_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";
+
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	snprintf(ev_name, MAX_NAME_SIZE, "MCS_0%d", idx);
+	dt_add_property_cells(ima, ev_name, offset);
+
+	/* Unit for the Event */
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	snprintf(ev_name, MAX_NAME_SIZE, "unit.MCS_0%d.unit", idx);
+	dt_add_property_string(ima, ev_name, unit);
+
+	/* Scale for the Event */
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	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_ima_chip_mcs_type( struct dt_node *ima,
+		struct ima_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 twice.
+	 */
+	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_ima_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
@@ -40,9 +106,24 @@ struct page0_offsets *pg0_offsets;
 int dt_create_ima_chip_type (struct dt_node *ima,
 		struct ima_catalogue_group_data *gptr)
 {
-	int rc;
+	char *name;
+	int rc = -EINVAL;
 
+	name = (char *)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_ima_chip_mcs_type(ima, gptr,name))
+			goto out;
+	} else
+		goto out;
+
+	return rc;
 
+out:
+	free(name);
 	return rc;
 }
 
diff --git a/include/nest.h b/include/nest.h
index 413a89e..89b6eff 100644
--- a/include/nest.h
+++ b/include/nest.h
@@ -227,6 +227,9 @@ int load_catalogue_lid(void);
 int dt_create_ima_chip_types(struct dt_node *);
 int dt_create_ima_chip_type (struct dt_node *,
 				struct ima_catalogue_group_data *);
+int dt_create_ima_chip_mcs_type(struct dt_node *,
+				struct ima_catalogue_group_data *,char *);
+int dt_create_ima_chip_mcs_event(struct dt_node *,int,u32);
 void nest_ima_init(void);
 
 #endif	/* __NEST_H__ */
-- 
1.9.3



More information about the Skiboot mailing list