summaryrefslogtreecommitdiffstats
path: root/libpdbg/htm.c
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2018-06-19 15:25:30 +1000
committerAlistair Popple <alistair@popple.id.au>2018-06-25 14:53:51 +1000
commit484f2950c1f0a5768e1f404e677e3f3d714b2872 (patch)
treecc1f43cbc76066fa4768df8ac4998c9eb9f2465f /libpdbg/htm.c
parentb64810d42d56f945aac73ecd97227da4b64e6b68 (diff)
downloadpdbg-484f2950c1f0a5768e1f404e677e3f3d714b2872.tar.gz
pdbg-484f2950c1f0a5768e1f404e677e3f3d714b2872.zip
htm: Toggle debug bit so trace actually starts
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>
Diffstat (limited to 'libpdbg/htm.c')
-rw-r--r--libpdbg/htm.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index 790ca4f..4003ac3 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()
OpenPOWER on IntegriCloud