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: [PATCH i-g-t 3/4] tests/intel/xe_exec_compute_mode: Add a listener for file events
Date: Fri, 12 Jun 2026 13:06:18 +0200 [thread overview]
Message-ID: <20260612110619.103198-4-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260612110619.103198-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 | 63 +++++++++++++++++++++++++++++-
1 file changed, 61 insertions(+), 2 deletions(-)
diff --git a/tests/intel/xe_exec_compute_mode.c b/tests/intel/xe_exec_compute_mode.c
index 438ea163f..5bab971b0 100644
--- a/tests/intel/xe_exec_compute_mode.c
+++ b/tests/intel/xe_exec_compute_mode.c
@@ -19,9 +19,14 @@
#include <sys/ioctl.h>
#include "xe_drm.h"
+/* Don't include linux/fcntl.h since we already included <fcntl.h> */
+#define _LINUX_FCNTL_H
+#include "xe_drm_events.h"
+
#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 +40,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 +481,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 +522,8 @@ int igt_main()
lr_mode_workload(fd);
- igt_fixture()
+ igt_fixture() {
drm_close_driver(fd);
+ xe_watch_listener_destroy(listener);
+ }
}
--
2.54.0
next prev parent reply other threads:[~2026-06-12 11:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 11:06 [PATCH i-g-t 0/4] xe: watch queue event support and VM restart recovery Thomas Hellström
2026-06-12 11:06 ` [PATCH i-g-t 1/4] lib/xe: add xe_vm_restart ioctl helper Thomas Hellström
2026-06-12 14:38 ` Kamil Konieczny
2026-06-12 11:06 ` [PATCH i-g-t 2/4] lib/xe: add xe_watch listener for watch queue events Thomas Hellström
2026-06-12 11:06 ` Thomas Hellström [this message]
2026-06-12 11:06 ` [PATCH i-g-t 4/4] tests/intel/xe_exec_compute_mode: Restart VM on ENOMEM/ENOSPC errors Thomas Hellström
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=20260612110619.103198-4-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