diff mbox series

[13/18] htm: Toggle debug bit so trace actually starts

Message ID 20180619052535.24043-13-mikey@neuling.org
State Accepted
Headers show
Series [01/18] Make -a the default for probe | expand

Commit Message

Michael Neuling June 19, 2018, 5:25 a.m. UTC
Without this the trace doesn't actually run.

In the past, it was only running once the user did another htm command
which toggled this bit during the probe.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 libpdbg/htm.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index 790ca4feef..4003ac3b35 100644
--- a/libpdbg/htm.c
+++ b/libpdbg/htm.c
@@ -720,6 +720,31 @@  static int do_htm_reset(struct htm *htm)
 	return 1;
 }
 
+/* Stolen from p8chip.c */
+#define RAS_MODE_REG			0x1
+#define  MR_THREAD_IN_DEBUG		PPC_BIT(43)
+static int htm_toggle_debug_bit(struct htm *htm)
+{
+	struct pdbg_target *target;
+	uint64_t reg;
+
+	/* FIXME: this is a hack for P8 */
+	if (!dt_node_is_compatible(htm->target.parent, "ibm,power8-core")) {
+		PR_ERROR("HTM is POWER8 only currently\n");
+		return -1;
+	}
+
+	pdbg_for_each_target("thread", htm->target.parent, target) {
+		if (pdbg_target_index(target) == 0) {
+			/* Need to set this bit to ensure HTM starts */
+			pib_read (target, RAS_MODE_REG, &reg);
+			pib_write(target, RAS_MODE_REG, reg | MR_THREAD_IN_DEBUG);
+			pib_write(target, RAS_MODE_REG, reg);
+		}
+	}
+	return 0;
+}
+
 static int do_htm_start(struct htm *htm)
 {
 	struct htm_status status;
@@ -742,6 +767,9 @@  static int do_htm_start(struct htm *htm)
 	if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_START)))
 		return -1;
 
+	if (htm_toggle_debug_bit(htm))
+		return -1;
+
 	/*
 	 * Instead of the HTM_TRIG_START, this is where you might want
 	 * to call do_adu_magic()