diff mbox series

[04/10] p9chip: implement SMT state thread state

Message ID 20220531091457.2208488-5-npiggin@gmail.com
State New
Headers show
Series [01/10] sbefifo: correct typo in thread target name | expand

Commit Message

Nicholas Piggin May 31, 2022, 9:14 a.m. UTC
The PC registers involved are the same as P10.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 libpdbg/p9chip.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c
index 0ac53542..0040402c 100644
--- a/libpdbg/p9chip.c
+++ b/libpdbg/p9chip.c
@@ -94,6 +94,7 @@  struct thread_state p9_thread_state(struct thread *thread)
 {
 	uint64_t value;
 	struct thread_state thread_state;
+	uint8_t smt_mode;
 
 	thread_read(thread, P9_RAS_STATUS, &value);
 
@@ -102,14 +103,31 @@  struct thread_state p9_thread_state(struct thread *thread)
 	thread_read(thread, P9_THREAD_INFO, &value);
 	thread_state.active = !!(value & PPC_BIT(thread->id));
 
+	smt_mode = GETFIELD(PPC_BITMASK(8,9), value);
+	switch (smt_mode) {
+	case 0:
+		thread_state.smt_state = PDBG_SMT_1;
+		break;
+
+	case 2:
+		thread_state.smt_state = PDBG_SMT_2;
+		break;
+
+	case 3:
+		thread_state.smt_state = PDBG_SMT_4;
+		break;
+
+	default:
+		thread_state.smt_state = PDBG_SMT_UNKNOWN;
+		break;
+	}
+
 	thread_read(thread, P9_CORE_THREAD_STATE, &value);
 	if (value & PPC_BIT(56 + thread->id))
 		thread_state.sleep_state = PDBG_THREAD_STATE_STOP;
 	else
 		thread_state.sleep_state = PDBG_THREAD_STATE_RUN;
 
-	thread_state.smt_state = PDBG_SMT_UNKNOWN;
-
 	return thread_state;
 }