[PATCH i-g-t v2 23/66] lib/xe_eudebug: Allow debugger to wait for client
Christoph Manszewski
christoph.manszewski at intel.com
Tue Jul 30 11:44:40 UTC 2024
In some tests, we need to pause the debugger at a certain stage as
the point at which the client performs certain activities, determines
the executed code path in the driver.
Add a possibility to pause debugger and to signal continuation by
the client.
Signed-off-by: Christoph Manszewski <christoph.manszewski at intel.com>
Cc: Karolina Stolarek <karolina.stolarek at intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
---
lib/xe/xe_eudebug.c | 37 +++++++++++++++++++++++++++++++++++++
lib/xe/xe_eudebug.h | 2 ++
2 files changed, 39 insertions(+)
diff --git a/lib/xe/xe_eudebug.c b/lib/xe/xe_eudebug.c
index 36eef25c7..ed1e382c7 100644
--- a/lib/xe/xe_eudebug.c
+++ b/lib/xe/xe_eudebug.c
@@ -45,6 +45,7 @@ struct match_dto {
#define CLIENT_FINI 3
#define CLIENT_STOP 4
#define CLIENT_STAGE 5
+#define DEBUGGER_STAGE 6
#define DEBUGGER_WORKER_INACTIVE 0
#define DEBUGGER_WORKER_ACTIVE 1
@@ -1250,6 +1251,29 @@ void xe_eudebug_debugger_signal_stage(struct xe_eudebug_debugger *d, uint64_t st
token_signal(d->p_client, CLIENT_STAGE, stage);
}
+/**
+ * xe_eudebug_debugger_wait_stage:
+ * @s: pointer to xe_eudebug_debugger structure
+ * @stage: stage to wait on
+ *
+ * Pauses debugger until the client has signalled the corresponding stage with
+ * xe_eudebug_client_signal_stage. This is only for situatuons where the actual
+ * event flow is not enough to coordinate between client/debugger and extra sync
+ * mechanism is needed.
+ */
+void xe_eudebug_debugger_wait_stage(struct xe_eudebug_session *s, uint64_t stage)
+{
+ u64 stage_in;
+
+ igt_debug("debugger xe client fd: %d pausing for stage %lu\n", s->d->master_fd, stage);
+
+ stage_in = wait_from_client(s->c, DEBUGGER_STAGE);
+ igt_debug("debugger xe client fd: %d stage %lu, expected %lu, stage\n", s->d->master_fd,
+ stage_in, stage);
+
+ igt_assert_eq(stage_in, stage);
+}
+
/**
* xe_eudebug_client_create:
* @master_fd: xe client used to open the debugger connection
@@ -1397,6 +1421,19 @@ void xe_eudebug_client_wait_done(struct xe_eudebug_client *c)
}
}
+/**
+ * xe_eudebug_client_signal_stage:
+ * @c: pointer to the client
+ * @stage: stage to signal
+ *
+ * Signals to debugger, waiting in xe_eudebug_debugger_wait_stage(),
+ * releasing it to proceed.
+ */
+void xe_eudebug_client_signal_stage(struct xe_eudebug_client *c, uint64_t stage)
+{
+ token_signal(c->p_out, DEBUGGER_STAGE, stage);
+}
+
/**
* xe_eudebug_client_wait_stage:
* @c: pointer to xe_eudebug_client structure
diff --git a/lib/xe/xe_eudebug.h b/lib/xe/xe_eudebug.h
index 1343cb25c..81c33417f 100644
--- a/lib/xe/xe_eudebug.h
+++ b/lib/xe/xe_eudebug.h
@@ -135,6 +135,7 @@ void xe_eudebug_debugger_set_data(struct xe_eudebug_debugger *c, void *ptr);
void xe_eudebug_debugger_add_trigger(struct xe_eudebug_debugger *d, int type,
xe_eudebug_trigger_fn fn);
void xe_eudebug_debugger_signal_stage(struct xe_eudebug_debugger *d, uint64_t stage);
+void xe_eudebug_debugger_wait_stage(struct xe_eudebug_session *s, uint64_t stage);
struct xe_eudebug_client *
xe_eudebug_client_create(int xe, xe_eudebug_client_work_fn work, uint64_t flags, void *data);
@@ -142,6 +143,7 @@ void xe_eudebug_client_destroy(struct xe_eudebug_client *c);
void xe_eudebug_client_start(struct xe_eudebug_client *c);
void xe_eudebug_client_stop(struct xe_eudebug_client *c);
void xe_eudebug_client_wait_done(struct xe_eudebug_client *c);
+void xe_eudebug_client_signal_stage(struct xe_eudebug_client *c, uint64_t stage);
void xe_eudebug_client_wait_stage(struct xe_eudebug_client *c, uint64_t stage);
uint64_t xe_eudebug_client_get_seqno(struct xe_eudebug_client *c);
--
2.34.1
More information about the igt-dev
mailing list