public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: nishit.sharma@intel.com
To: igt-dev@lists.freedesktop.org, matthew.brost@intel.com
Subject: [PATCH i-g-t] tests/intel/xe_wedged: Add subtest to validate device behaviour
Date: Mon, 13 Apr 2026 14:37:17 +0000	[thread overview]
Message-ID: <20260413143717.5323-1-nishit.sharma@intel.com> (raw)

From: Nishit Sharma <nishit.sharma@intel.com>

This test:
- Forces the device into "wedged-at-any-timeout" mode via debugfs.
- Submits a hang job and waits for the hang to be detected.
- Verifies that all subsequent ioctls return -ECANCELED,
  indicating the device is wedged.
- Reloads the driver and checks that normal operation is
  restored on all engines.

Signed-off-by: Nishit Sharma <nishit.sharma@intel.com>
---
 tests/intel/xe_wedged.c | 94 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/tests/intel/xe_wedged.c b/tests/intel/xe_wedged.c
index e1ac629ca..fe6468cc6 100644
--- a/tests/intel/xe_wedged.c
+++ b/tests/intel/xe_wedged.c
@@ -193,6 +193,51 @@ simple_hang(int fd, struct drm_xe_sync *sync)
 	} while (err && errno == ENOMEM);
 }
 
+static void
+submit_job(int fd, uint32_t vm, uint32_t exec_queue, void *userptr,
+	   size_t size, uint32_t syncobj)
+{
+	uint64_t addr = 0x1a0000;
+	struct drm_xe_sync sync = {
+		.type = DRM_XE_SYNC_TYPE_SYNCOBJ,
+		.flags = DRM_XE_SYNC_FLAG_SIGNAL,
+		.handle = syncobj,
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 1,
+		.syncs = to_user_pointer(&sync),
+	};
+	uint32_t bo = 0;
+	uint32_t *batch;
+	size_t bo_size = 4096;
+	uint64_t batch_addr = addr;
+	int b = 0;
+
+	bo = xe_bo_create(fd, vm, bo_size,
+			  vram_if_possible(fd, 0),
+			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+	batch = xe_bo_map(fd, bo, bo_size);
+
+	batch[b++] = MI_BATCH_BUFFER_START;
+	batch[b++] = MI_PRT_BATCH_BUFFER_START;
+	batch[b++] = batch_addr;
+	batch[b++] = batch_addr >> 32;
+	batch[b++] = MI_BATCH_BUFFER_END;
+	igt_assert(b <= (bo_size / sizeof(uint32_t)));
+
+	xe_vm_bind_userptr_async(fd, vm, 0, to_user_pointer(userptr),
+				 addr + 0x10000, size, NULL, 0);
+
+	xe_vm_bind_async(fd, vm, 0, bo, 0, batch_addr, bo_size, NULL, 0);
+
+	exec.exec_queue_id = exec_queue;
+	exec.address = batch_addr;
+
+	syncobj_reset(fd, &syncobj, 1);
+	xe_exec(fd, &exec);
+}
+
 /**
  * SUBTEST: basic-wedged
  * Description: Force Xe device wedged after injecting a failure in GT reset
@@ -209,6 +254,10 @@ simple_hang(int fd, struct drm_xe_sync *sync)
  * SUBTEST: basic-wedged-read
  * Description: Read wedged_mode debugfs
  */
+/**
+ * SUBTEST: userptr-wedge-fence-signal
+ * Description: Submits a long-running job using a userptr buffer, force-wedges the device
+ */
 int igt_main()
 {
 	struct drm_xe_engine_class_instance *hwe;
@@ -310,6 +359,51 @@ int igt_main()
 		igt_assert_f(str[0] != '\0', "Failed to read wedged_mode from debugfs!\n");
 	}
 
+	igt_subtest("userptr-wedge-fence-signal") {
+		struct drm_xe_engine_class_instance inst = {
+			.engine_class = DRM_XE_ENGINE_CLASS_COPY,
+			};
+
+		size_t size;
+		void *userptr;
+		uint32_t vm, exec_queue, syncobj;
+		int ret;
+
+		size = 128 * 1024 * 1024;
+		igt_require(igt_debugfs_exists(fd, "fail_gt_reset/probability",
+					       O_RDWR));
+		igt_debugfs_write(fd, "fail_gt_reset/verbose", "1");
+
+		igt_assert_eq(simple_ioctl(fd), 0);
+		ignore_wedged_in_dmesg();
+
+		userptr = mmap(NULL, size, PROT_READ | PROT_WRITE,
+			       MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+		igt_assert(userptr != MAP_FAILED);
+
+		vm = xe_vm_create(fd, 0, 0);
+		exec_queue = xe_exec_queue_create(fd, vm, &inst, 0);
+		syncobj = syncobj_create(fd, 0);
+
+		submit_job(fd, vm, exec_queue, userptr, size, syncobj);
+
+		force_wedged(fd);
+		munmap(userptr, size);
+
+		ret = syncobj_wait_err(fd, &syncobj, 1, INT64_MAX, 0);
+		if (ret)
+			igt_assert_eq(ret, -ECANCELED);
+
+		drm_close_driver(fd);
+		igt_kmod_rebind("xe", pci_slot);
+		system("modprobe -r xe && modprobe xe");
+		fd = drm_open_driver(DRIVER_XE);
+
+		igt_assert_eq(simple_ioctl(fd), 0);
+		xe_for_each_engine(fd, hwe)
+			simple_exec(fd, hwe);
+	}
+
 	igt_fixture() {
 		if (igt_debugfs_exists(fd, "fail_gt_reset/probability", O_RDWR)) {
 			igt_debugfs_write(fd, "fail_gt_reset/probability", "0");
-- 
2.43.0


             reply	other threads:[~2026-04-13 14:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13 14:37 nishit.sharma [this message]
2026-04-14  0:17 ` ✓ i915.CI.BAT: success for tests/intel/xe_wedged: Add subtest to validate device behaviour Patchwork
2026-04-14  0:46 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-14  3:10 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-04-14  6:54 ` ✗ i915.CI.Full: " Patchwork
2026-04-14 17:40 ` [PATCH i-g-t] " Kamil Konieczny
2026-04-15  2:37   ` Sharma, Nishit

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=20260413143717.5323-1-nishit.sharma@intel.com \
    --to=nishit.sharma@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=matthew.brost@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