diff mbox series

[v2,01/39] libpdbg: fix p9chip and p10chip thread_stop

Message ID 20220420065013.222816-2-npiggin@gmail.com
State New
Headers show
Series gdbserver multi-threaded debugging and POWER9/10 support | expand

Commit Message

Nicholas Piggin April 20, 2022, 6:49 a.m. UTC
Have p9 and p10 thread_stop return 1 on failure, and have them set
thread->status to the status used when checking for quiesce, rather
than sampling it again on the way out.

This seems to improve some intermittent condition on POWER9 where
a thread was stopped successfuly but the subsequent status read
finds it no longer quiesced.

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

Patch

diff --git a/libpdbg/p10chip.c b/libpdbg/p10chip.c
index e0d9ee21..70481f1f 100644
--- a/libpdbg/p10chip.c
+++ b/libpdbg/p10chip.c
@@ -154,14 +154,14 @@  static int p10_thread_stop(struct thread *thread)
 	int i = 0;
 
 	thread_write(thread, P10_DIRECT_CONTROL, PPC_BIT(7 + 8*thread->id));
-	while (!(thread->state(thread).quiesced)) {
+	do {
 		usleep(1000);
 		if (i++ > RAS_STATUS_TIMEOUT) {
 			PR_ERROR("Unable to quiesce thread\n");
-			break;
+			return 1;
 		}
-	}
-	thread->status = thread->state(thread);
+		thread->status = thread->state(thread);
+	} while (!thread->status.quiesced);
 
 	return 0;
 }
diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c
index 9fddaf64..0ac53542 100644
--- a/libpdbg/p9chip.c
+++ b/libpdbg/p9chip.c
@@ -157,14 +157,14 @@  static int p9_thread_stop(struct thread *thread)
 	int i = 0;
 
 	thread_write(thread, P9_DIRECT_CONTROL, PPC_BIT(7 + 8*thread->id));
-	while (!(thread->state(thread).quiesced)) {
+	do {
 		usleep(1000);
 		if (i++ > RAS_STATUS_TIMEOUT) {
 			PR_ERROR("Unable to quiesce thread\n");
-			break;
+			return 1;
 		}
-	}
-	thread->status = thread->state(thread);
+		thread->status = thread->state(thread);
+	} while (!thread->status.quiesced);
 
 	return 0;
 }