[Skiboot] [PATCH v8 7/7] Add OPAL call to enable/disable nest pmu

Madhavan Srinivasan maddy at linux.vnet.ibm.com
Mon Mar 14 15:02:03 AEDT 2016


Add a new opal call to start and stop pore_slw_ima microcode
for nest pmu counter collection. Also creates a opal-api doc for this call.

Signed-off-by: Madhavan Srinivasan <maddy at linux.vnet.ibm.com>
---
 doc/opal-api/opal-nest-counters.txt | 37 +++++++++++++++++++++++++++++++++++++
 hw/nest.c                           | 37 +++++++++++++++++++++++++++++++++++++
 include/opal-api.h                  |  3 ++-
 3 files changed, 76 insertions(+), 1 deletion(-)
 create mode 100644 doc/opal-api/opal-nest-counters.txt

diff --git a/doc/opal-api/opal-nest-counters.txt b/doc/opal-api/opal-nest-counters.txt
new file mode 100644
index 000000000000..3eba14a718df
--- /dev/null
+++ b/doc/opal-api/opal-nest-counters.txt
@@ -0,0 +1,37 @@
+OPAL_NEST_COUNTERS_CONTROL
+----------------------
+
+OPAL call interface for nest instrumentation support.
+Currently, the interface supports start and stop of pore slw ima
+(Power On Reset Engine SLeep Wink In Memory Accumulator) engine for
+nest instrumentation from Host OS. But it can be extended.
+
+OPAL_NEST_COUNTERS_CONTROL call accepts four parameters:
+
+	Mode (uint64_t):
+		Currently, only production mode is supported.
+		The "IMA_CHIP_PRODUCTION_MODE" macro defined in "nest.h"
+		is used for this.
+
+	Value_1 (uint64_t):
+		-For "IMA_CHIP_PRODUCTION_MODE" mode, this parameter is used
+		to start and stop the pore_slw_ima engine.
+		0x0 -- Stop
+		0x1 -- Start
+
+		-For other modes, this parameter is undefined for now.
+
+	Value_2 (uint64_t):
+		- For "IMA_CHIP_PRODUCTION_MODE" mode, this parameter should be
+		  zero.
+
+		-For other modes, this parameter is undefined for now.
+
+	Value_3 (uint64_t):
+		- For "IMA_CHIP_PRODUCTION_MODE" mode, this parameter should be
+		  zero.
+
+		-For other modes, this parameter is undefined for now.
+
+OPAL_NEST_COUNTERS_CONTROL will return:
+	OPAL_SUCCESS on success and IMA_PTS_ERROR on failure.
diff --git a/hw/nest.c b/hw/nest.c
index 4e1866f66853..fe8213c82af1 100644
--- a/hw/nest.c
+++ b/hw/nest.c
@@ -57,6 +57,23 @@ struct catalog_grp_to_dt_node dev_grp_map[NEST_DT_DEVICE_MAX];
  */
 struct nest_catalog_page_0 *page0_desc;
 
+static bool is_P8_proc(void)
+{
+	struct proc_chip *chip;
+
+	chip = get_chip(this_cpu()->chip_id);
+	switch(chip->type) {
+	case PROC_CHIP_P8_MURANO:
+	case PROC_CHIP_P8_VENICE:
+	case PROC_CHIP_P8_NAPLES:
+		return true;
+	default:
+		break;
+	}
+
+	return false;
+}
+
 static struct dt_node *
 dt_add_device_node(struct dt_node *ptr, const char *name)
 {
@@ -426,3 +443,23 @@ fail:
 	dt_free(dev);
 	return;
 }
+
+static int64_t opal_nest_counters_control(uint64_t mode, uint64_t value_1,
+					uint64_t value_2, uint64_t value_3)
+{
+	struct proc_chip *chip;
+	u64 op;
+
+	chip = get_chip(this_cpu()->chip_id);
+	if (mode == IMA_CHIP_PRODUCTION_MODE &&
+		!value_2 && !value_3) {
+		op = value_1 ? IMA_PTS_ENABLE: IMA_PTS_DISABLE;
+		if (is_P8_proc())
+			return OPAL_SUCCESS;
+		xscom_write(chip->id, IMA_PTS_SCOM, op);
+		return OPAL_SUCCESS;
+	}
+
+	return OPAL_UNSUPPORTED;
+}
+opal_call(OPAL_NEST_COUNTERS_CONTROL, opal_nest_counters_control, 4);
diff --git a/include/opal-api.h b/include/opal-api.h
index 369aa93276fb..8a8978a6ce47 100644
--- a/include/opal-api.h
+++ b/include/opal-api.h
@@ -163,7 +163,8 @@
 #define OPAL_LEDS_SET_INDICATOR			115
 #define OPAL_CEC_REBOOT2			116
 #define OPAL_CONSOLE_FLUSH			117
-#define OPAL_LAST				117
+#define OPAL_NEST_COUNTERS_CONTROL		118
+#define OPAL_LAST				118
 
 /* Device tree flags */
 
-- 
1.9.1



More information about the Skiboot mailing list