From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: janusz.krzysztofik@linux.intel.com, lukasz.laguna@intel.com,
matthew.brost@intel.com, michal.wajdeczko@intel.com,
stuart.summers@intel.com,
Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Subject: [PATCH i-g-t 2/2] tests/core_hotunplug: Add exec-fork-unbind-rebind subtest
Date: Thu, 11 Jun 2026 16:24:38 +0200 [thread overview]
Message-ID: <20260611142438.260647-3-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20260611142438.260647-1-marcin.bernatowicz@linux.intel.com>
Add coverage for unbind/rebind with live child-process GPU handles.
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Cc: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Stuart Summers <stuart.summers@intel.com>
---
tests/core_hotunplug.c | 98 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 7c9dae1bf..2e5aa8d5c 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -605,6 +605,92 @@ static void hotunbind_rebind(struct hotunplug *priv)
igt_assert_f(healthcheck(priv, false), "%s\n", priv->failure);
}
+/*
+ * Start a spinner in a child process, then end it while keeping child-side
+ * handles alive. Verifies the parent can unbind and rebind the driver while
+ * those child handles are still open.
+ */
+static void exec_fork_unbind_rebind_run(struct hotunplug *priv)
+{
+ struct igt_helper_process child = {};
+ int ready_pipe[2], stop_pipe[2];
+ char msg = 0;
+
+ igt_assert_eq(pipe(ready_pipe), 0);
+ igt_assert_eq(pipe(stop_pipe), 0);
+
+ igt_fork_helper(&child) {
+ const intel_ctx_t *ctx = NULL;
+ uint64_t ahnd = 0;
+ igt_spin_t *spin;
+ int fd;
+
+ close(ready_pipe[0]);
+ close(stop_pipe[1]);
+
+ fd = local_drm_open_driver(false, "", " for spinner workload child");
+
+ if (is_i915_device(fd)) {
+ ctx = intel_ctx_create_all_physical(fd);
+ ahnd = get_reloc_ahnd(fd, ctx->id);
+ spin = igt_spin_new(fd, .ahnd = ahnd, .ctx = ctx,
+ .flags = IGT_SPIN_POLL_RUN);
+ } else {
+ ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_RELOC);
+ spin = igt_spin_new(fd, .ahnd = ahnd);
+ }
+
+ igt_spin_busywait_until_started(spin);
+ igt_spin_end(spin);
+
+ msg = 1;
+ igt_assert_eq(write(ready_pipe[1], &msg, sizeof(msg)), sizeof(msg));
+ close(ready_pipe[1]);
+
+ /*
+ * Block until parent completes the driver unbind.
+ * Intentionally skip spinner teardown: we want handles (ex. exec_queue) to
+ * remain alive until fd close.
+ */
+ read(stop_pipe[0], &msg, sizeof(msg));
+ close(stop_pipe[0]);
+
+ if (ahnd)
+ put_ahnd(ahnd);
+ fd = close_device(fd, "child late ", "rebound ");
+ igt_assert_eq(fd, -1);
+ }
+
+ close(ready_pipe[1]);
+ close(stop_pipe[0]);
+
+ igt_assert_eq(read(ready_pipe[0], &msg, sizeof(msg)), sizeof(msg));
+ close(ready_pipe[0]);
+
+ driver_unbind(priv, "", 0);
+
+ close(stop_pipe[1]);
+ igt_wait_helper(&child);
+
+ driver_bind(priv, 0);
+}
+
+/**
+ * SUBTEST: exec-fork-unbind-rebind
+ * Description: Check if the driver can be cleanly unbound and rebound while
+ * child-process handles remain open
+ */
+static void exec_fork_unbind_rebind(struct hotunplug *priv)
+{
+ igt_require(priv->chipset == DRIVER_INTEL || priv->chipset == DRIVER_XE);
+
+ pre_check(priv);
+
+ exec_fork_unbind_rebind_run(priv);
+
+ igt_assert_f(healthcheck(priv, false), "%s\n", priv->failure);
+}
+
static void hotunplug_rescan(struct hotunplug *priv)
{
pre_check(priv);
@@ -757,6 +843,18 @@ int igt_main()
recover(&priv);
}
+ igt_fixture()
+ post_healthcheck(&priv);
+
+ igt_subtest_group() {
+ igt_describe("Check if the driver can be cleanly unbound and rebound while child-process handles remain open");
+ igt_subtest("exec-fork-unbind-rebind")
+ exec_fork_unbind_rebind(&priv);
+
+ igt_fixture()
+ recover(&priv);
+ }
+
igt_fixture()
post_healthcheck(&priv);
--
2.43.0
next prev parent reply other threads:[~2026-06-11 14:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 14:24 [PATCH i-g-t 0/2] Extend core_hotunplug coverage with open-handles unbind/rebind scenario Marcin Bernatowicz
2026-06-11 14:24 ` [PATCH i-g-t 1/2] lib/igt_dummyload: Adapt helpers for Xe Marcin Bernatowicz
2026-06-11 14:24 ` Marcin Bernatowicz [this message]
2026-06-11 15:26 ` [PATCH i-g-t 2/2] tests/core_hotunplug: Add exec-fork-unbind-rebind subtest Kamil Konieczny
2026-06-12 7:13 ` Bernatowicz, Marcin
2026-06-11 18:45 ` ✓ i915.CI.BAT: success for Extend core_hotunplug coverage with open-handles unbind/rebind scenario Patchwork
2026-06-11 19:14 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-12 9:33 ` ✗ Xe.CI.FULL: failure " 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=20260611142438.260647-3-marcin.bernatowicz@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=lukasz.laguna@intel.com \
--cc=matthew.brost@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=stuart.summers@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