[Pdbg] [PATCH v2 7/8] libpdbg/htm: Enable NCU and set single dispatch/instruction mode

Cyril Bur cyrilbur at gmail.com
Tue Mar 27 11:30:25 AEDT 2018


It isn't clear if chtm needs to be enabled before or after setting
single dispatch single instruction mode in the core. It also isn't
clear if the NCU enable should be done before of after core enable.

This fixes problems related with chtm being stuck in "INIT" state and
failing to become "READY".

Signed-off-by: Cyril Bur <cyrilbur at gmail.com>
---
 libpdbg/htm.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index 4c1ee01..a2428f0 100644
--- a/libpdbg/htm.c
+++ b/libpdbg/htm.c
@@ -45,6 +45,24 @@
 #define DEBUGFS_MEMTRACE DEBUGFS_POWERPC"/memtrace"
 #define DEBUGFS_MEMTRACE_ENABLE DEBUGFS_MEMTRACE"/enable"
 
+/*
+ * This is a CORE register not a HTM register, don't pass the HTM
+ * target to it.
+ */
+#define HID0_REGISTER			0x1329C
+#define  HID0_ONE_PER_GROUP		PPC_BIT(0)
+#define  HID0_DO_SINGLE			PPC_BIT(1)
+#define  HID0_SINGLE_DECODE		PPC_BIT(4)
+#define  HID0_EN_INST_TRACE		PPC_BIT(17)
+#define  HID0_TRACE_EN			PPC_BIT(23)
+
+/*
+ * This is a CORE register not a HTM register, don't pass the HTM
+ * target to it.
+ */
+#define NCU_MODE_REGISTER		0x10C0A
+#define NCU_MODE_HTM_ENABLE		PPC_BIT(0)
+
 #define HTM_COLLECTION_MODE		0
 #define	  HTM_MODE_ENABLE		PPC_BIT(0)
 #define	  HTM_MODE_CONTENT_SEL		PPC_BITMASK(1,2)
@@ -446,12 +464,33 @@ static int configure_debugfs_memtrace(struct htm *htm)
 
 static int configure_chtm(struct htm *htm)
 {
+	uint64_t hid0, ncu;
+
 	if (HTM_ERR(configure_debugfs_memtrace(htm)))
 		return -1;
 
 	if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE,
-					HTM_MODE_ENABLE |
-					CHTM_MODE_NO_ASSERT_LLAT_L3)))
+		HTM_MODE_ENABLE | HTM_MODE_WRAP)))
+		return -1;
+	/* Not great to assume the core is the parent of the htm. */
+	if (HTM_ERR(pib_read(htm->target.dn->parent->target, HID0_REGISTER, &hid0)))
+		return -1;
+
+	hid0 |= (HID0_DO_SINGLE | HID0_SINGLE_DECODE | HID0_EN_INST_TRACE |
+		 HID0_TRACE_EN | HID0_ONE_PER_GROUP);
+
+	/* Not great to assume the core is the parent of the htm. */
+	if (HTM_ERR(pib_write(htm->target.dn->parent->target, HID0_REGISTER, hid0)))
+		return -1;
+
+	/* Not great to assume the core is the parent of the htm. */
+	if (HTM_ERR(pib_read(htm->target.dn->parent->target, NCU_MODE_REGISTER, &ncu)))
+		return -1;
+
+	ncu |= NCU_MODE_HTM_ENABLE;
+
+	/* Not great to assume the core is the parent of the htm. */
+	if (HTM_ERR(pib_write(htm->target.dn->parent->target, NCU_MODE_REGISTER, ncu)))
 		return -1;
 
 	return 0;
-- 
2.16.3



More information about the Pdbg mailing list