public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Michal Mrozek" <michal.mrozek@intel.com>,
	"John Falkowski" <john.falkowski@intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Lahtinen Joonas" <joonas.lahtinen@intel.com>
Subject: [RFC PATCH i-g-t 2/2] tests/intel/xe_exec_compute_mode: Add a listener for file events
Date: Wed,  4 Mar 2026 13:17:25 +0100	[thread overview]
Message-ID: <20260304121725.161213-3-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260304121725.161213-1-thomas.hellstrom@linux.intel.com>

Using the new xe_watch library functionality, add a listener
for file events. The listener gets notified on

* File close,
* Lost event,
* Rebind worker error.

But doesn't take any action.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 tests/intel/xe_exec_compute_mode.c | 59 +++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/tests/intel/xe_exec_compute_mode.c b/tests/intel/xe_exec_compute_mode.c
index 438ea163f..0784f3a31 100644
--- a/tests/intel/xe_exec_compute_mode.c
+++ b/tests/intel/xe_exec_compute_mode.c
@@ -22,6 +22,7 @@
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
 #include "xe/xe_spin.h"
+#include "xe/xe_watch.h"
 #include <string.h>
 
 #define MAX_N_EXECQUEUES 	16
@@ -35,6 +36,52 @@
 #define FREE_MAPPPING			(0x1 << 7)
 #define UNMAP_MAPPPING			(0x1 << 8)
 
+static void xe_event_fn(struct xe_watch_event *event)
+{
+	const struct watch_notification *notif = event->notif;
+	const struct drm_xe_watch_notification_vm_err *err_event =
+		igt_container_of(notif, err_event, base);
+
+	switch (notif->type) {
+	case WATCH_TYPE_META:
+		switch (notif->subtype) {
+		case WATCH_META_REMOVAL_NOTIFICATION:
+			igt_info("The device file was closed.\n");
+			break;
+		case WATCH_META_LOSS_NOTIFICATION:
+			igt_warn("The listener lost a message.\n");
+			break;
+		default:
+			igt_warn("Unknown META subtype.\n");
+			break;
+		}
+		break;
+
+	case WATCH_TYPE_DRM_XE_NOTIFY:
+		switch (notif->subtype) {
+		case DRM_XE_WATCH_EVENT_VM_ERR:
+			igt_info("VM with id %u saw an error: %d\n",
+				 (unsigned int) err_event->vm_id,
+				 (int) err_event->error_code);
+			break;
+		default:
+			igt_warn("Unknown XE watch subtype %u\n",
+				 (unsigned int) notif->subtype);
+			break;
+		}
+
+		break;
+
+	default:
+		igt_warn("Unknown watch type %u.\n", notif->type);
+		break;
+	}
+}
+
+const struct xe_watch_event_ops event_ops = {
+	.event_deliver = xe_event_fn,
+};
+
 /**
  * SUBTEST: twice-%s
  * Description: Run %arg[1] compute machine test twice
@@ -430,9 +477,15 @@ int igt_main()
 		{ NULL },
 	};
 	int fd;
+	struct xe_watch_event watch_event = {
+		.ops = &event_ops,
+	};
+	struct xe_watch_listener *listener;
 
-	igt_fixture()
+	igt_fixture() {
 		fd = drm_open_driver(DRIVER_XE);
+		listener = xe_watch_listener_create(fd, &watch_event);
+	}
 
 	for (const struct section *s = sections; s->name; s++) {
 		igt_subtest_f("once-%s", s->name)
@@ -465,6 +518,8 @@ int igt_main()
 		lr_mode_workload(fd);
 
 
-	igt_fixture()
+	igt_fixture() {
 		drm_close_driver(fd);
+		xe_watch_listener_destroy(listener);
+	}
 }
-- 
2.53.0


      parent reply	other threads:[~2026-03-04 12:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04 12:17 [RFC PATCH i-g-t 0/2] Xe driver watch-queue implementation and example Thomas Hellström
2026-03-04 12:17 ` [RFC PATCH i-g-t 1/2] lib/xe: add xe_watch listener for watch queue events Thomas Hellström
2026-03-04 12:17 ` Thomas Hellström [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260304121725.161213-3-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=john.falkowski@intel.com \
    --cc=joonas.lahtinen@intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.brost@intel.com \
    --cc=michal.mrozek@intel.com \
    --cc=rodrigo.vivi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox