[PATCH i-g-t] lib/xe/xe_eudebug: Deny unused triggers

Mika Kuoppala mika.kuoppala at linux.intel.com
Thu Oct 31 11:19:58 UTC 2024


Assert that if you add a trigger, it is used.

Cc: Jan Sokolowski <jan.sokolowski at intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Christoph Manszewski <christoph.manszewski at intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
---
 lib/xe/xe_eudebug.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/lib/xe/xe_eudebug.c b/lib/xe/xe_eudebug.c
index 74aa26024..97ed71838 100644
--- a/lib/xe/xe_eudebug.c
+++ b/lib/xe/xe_eudebug.c
@@ -20,6 +20,7 @@
 struct event_trigger {
 	xe_eudebug_trigger_fn fn;
 	int type;
+	unsigned int count;
 	struct igt_list_head link;
 };
 
@@ -1014,8 +1015,26 @@ static void debugger_run_triggers(struct xe_eudebug_debugger *d,
 	struct event_trigger *t;
 
 	igt_list_for_each_entry(t, &d->triggers, link) {
-		if (e->type == t->type)
-			t->fn(d, e);
+		if (e->type != t->type)
+			continue;
+
+		t->fn(d, e);
+		++t->count;
+
+		igt_debug("Trigger run for %s:%d %d times\n",
+			  type_to_str(t->type), t->type,
+			  t->count);
+	}
+}
+
+static void debugger_check_triggers(struct xe_eudebug_debugger *d)
+{
+	struct event_trigger *t;
+
+	igt_list_for_each_entry(t, &d->triggers, link) {
+		igt_assert_f(READ_ONCE(t->count),
+			     "Trigger %s(%d): was never invoked\n",
+			     type_to_str(t->type), t->type);
 	}
 }
 
@@ -1223,7 +1242,7 @@ void xe_eudebug_debugger_add_trigger(struct xe_eudebug_debugger *d,
 	t->fn = fn;
 
 	igt_list_add_tail(&t->link, &d->triggers);
-	igt_debug("added trigger %p\n", t);
+	igt_debug("Trigger added for %s:%d\n", type_to_str(t->type), t->type);
 }
 
 /**
@@ -1303,6 +1322,8 @@ void xe_eudebug_debugger_stop_worker(struct xe_eudebug_debugger *d,
 	igt_assert_f(ret == 0 || ret != ESRCH,
 		     "pthread join failed with error %d!\n", ret);
 
+	debugger_check_triggers(d);
+
 	event_log_sort(d->log);
 }
 
@@ -1603,6 +1624,8 @@ void xe_eudebug_session_run(struct xe_eudebug_session *s)
  */
 void xe_eudebug_session_check(struct xe_eudebug_session *s, bool match_opposite, uint32_t filter)
 {
+	debugger_check_triggers(s->debugger);
+
 	xe_eudebug_event_log_compare(s->client->log, s->debugger->log, filter);
 
 	if (match_opposite)
-- 
2.34.1



More information about the igt-dev mailing list