From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: <igt-dev@lists.freedesktop.org>
Cc: <intel-xe@lists.freedesktop.org>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Subject: [PATCH i-g-t 3/3] tests/intel/xe_wedged: Introduce a new test for Xe device wedged state
Date: Wed, 3 Apr 2024 11:14:09 -0400 [thread overview]
Message-ID: <20240403151411.113159-3-rodrigo.vivi@intel.com> (raw)
In-Reply-To: <20240403151411.113159-1-rodrigo.vivi@intel.com>
Let's inject a gt_reset failure that will put Xe device in the
new wedged state, then we confirm the IOCTL is blocked and we
reload the driver to get back to a clean state for other test
execution, since wedged state in Xe is a final state that can only
be cleared with a module reload.
This new test case is entirely based on xe_uevent provided by
Himal.
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
tests/intel/xe_wedged.c | 91 +++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 1 +
2 files changed, 92 insertions(+)
create mode 100644 tests/intel/xe_wedged.c
diff --git a/tests/intel/xe_wedged.c b/tests/intel/xe_wedged.c
new file mode 100644
index 000000000..f767e2511
--- /dev/null
+++ b/tests/intel/xe_wedged.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2024 Intel Corporation
+ */
+
+/**
+ * TEST: cause fake gt reset failure which put Xe device in wedged state
+ * Category: Software building block
+ * Sub-category: driver
+ * Functionality: wedged
+ * Test category: functionality test
+ */
+
+#include "igt.h"
+#include "igt_kmod.h"
+
+#include "xe/xe_ioctl.h"
+
+static void force_wedged(int fd)
+{
+ igt_debugfs_write(fd, "fail_gt_reset/probability", "100");
+ igt_debugfs_write(fd, "fail_gt_reset/times", "2");
+
+ xe_force_gt_reset(fd, 0);
+ sleep(1);
+}
+
+static int reload_xe(int fd)
+{
+ int error;
+
+ drm_close_driver(fd);
+ igt_xe_driver_unload();
+
+ error = igt_xe_driver_load(NULL);
+
+ igt_assert_eq(error, 0);
+
+ /* driver is ready, check if it's bound */
+ fd = __drm_open_driver(DRIVER_XE);
+ igt_fail_on_f(fd < 0, "Cannot open the xe DRM driver while reloading xe after wedged\n");
+ return fd;
+}
+
+static int simple_ioctl(int fd)
+{
+ int ret;
+
+ struct drm_xe_vm_create create = {
+ .extensions = 0,
+ .flags = 0,
+ };
+
+ ret = igt_ioctl(fd, DRM_IOCTL_XE_VM_CREATE, &create);
+
+ if (ret == 0)
+ xe_vm_destroy(fd, create.vm_id);
+
+ return ret;
+}
+
+/**
+ * SUBTEST: basic-wedged
+ * Description: Force Xe device wedged after injecting a failure in GT reset
+ */
+igt_main
+{
+ int fd;
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_XE);
+ igt_require(igt_debugfs_exists(fd, "fail_gt_reset/probability",
+ O_RDWR));
+ }
+
+ igt_subtest("basic-wedged") {
+ igt_assert_eq(simple_ioctl(fd), 0);
+ force_wedged(fd);
+ igt_assert_neq(simple_ioctl(fd), 0);
+ fd = reload_xe(fd);
+ igt_assert_eq(simple_ioctl(fd), 0);
+ }
+
+ igt_fixture {
+ if (igt_debugfs_exists(fd, "fail_gt_reset/probability", O_RDWR)) {
+ igt_debugfs_write(fd, "fail_gt_reset/probability", "0");
+ igt_debugfs_write(fd, "fail_gt_reset/times", "1");
+ }
+ drm_close_driver(fd);
+ }
+}
diff --git a/tests/meson.build b/tests/meson.build
index 02cbc3780..12dd2c16e 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -311,6 +311,7 @@ intel_xe_progs = [
'xe_query',
'xe_vm',
'xe_waitfence',
+ 'xe_wedged',
'xe_spin_batch',
'xe_sysfs_defaults',
'xe_sysfs_scheduler',
--
2.44.0
next prev parent reply other threads:[~2024-04-03 15:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 15:14 [PATCH i-g-t 1/3] tests/intel/xe_pm: Fix runtime_pm tests Rodrigo Vivi
2024-04-03 15:14 ` [PATCH i-g-t 2/3] lib/igt_kmod: drop devcoredump before a PCI module unload Rodrigo Vivi
2024-04-05 17:36 ` Lucas De Marchi
2024-04-05 17:42 ` Souza, Jose
2024-04-03 15:14 ` Rodrigo Vivi [this message]
2024-04-03 17:21 ` ✗ CI.Patch_applied: failure for series starting with [i-g-t,1/3] tests/intel/xe_pm: Fix runtime_pm tests Patchwork
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=20240403151411.113159-3-rodrigo.vivi@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
/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