From: Jeevan B <jeevan.b@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: jani.nikula@intel.com, pranay.samala@intel.com,
karthik.b.s@intel.com, Jeevan B <jeevan.b@intel.com>
Subject: [PATCH i-g-t 6/8] tests/intel: Add intel_display_module_load test
Date: Wed, 18 Nov 2026 21:14:21 +0530 [thread overview]
Message-ID: <20261118154426.345883-7-jeevan.b@intel.com> (raw)
In-Reply-To: <20261118154426.345883-1-jeevan.b@intel.com>
Add a driver-agnostic test for the dedicated intel_display module, which
is shared by i915 and xe. Each subtest runs as a dynamic subtest for every
GPU driver module available on the system:
- display-load-no-gpu-driver: load intel_display standalone
- display-unload-no-gpu-driver: unloading it with no driver is harmless
- display-load-then-gpu-driver: intel_display first, then the driver
- display-unload-order: driver first, then intel_display
- display-reverse-order: the driver pulls in intel_display, which is then
unloaded first
The test skips before touching the driver when intel_display is not a
separate module, and reloads the driver on exit.
Signed-off-by: Jeevan B <jeevan.b@intel.com>
---
tests/intel/intel_display_module_load.c | 221 ++++++++++++++++++++++++
tests/meson.build | 1 +
2 files changed, 222 insertions(+)
create mode 100644 tests/intel/intel_display_module_load.c
diff --git a/tests/intel/intel_display_module_load.c b/tests/intel/intel_display_module_load.c
new file mode 100644
index 000000000..53ebba810
--- /dev/null
+++ b/tests/intel/intel_display_module_load.c
@@ -0,0 +1,221 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+/**
+ * TEST: Tests loading and unloading of the intel_display module
+ * Category: Core
+ * Mega feature: General Core features
+ * Sub-category: driver
+ * Functionality: module load
+ * Test category: functionality test
+ *
+ * SUBTEST: display-load-no-gpu-driver
+ * Description: Verify that intel_display can be loaded standalone, without i915 or xe.
+ *
+ * SUBTEST: display-unload-no-gpu-driver
+ * Description: Verify unloading intel_display with no GPU driver loaded is harmless.
+ *
+ * SUBTEST: display-load-then-gpu-driver
+ * Description: Load intel_display first, then the GPU driver, and verify the driver binds.
+ *
+ * SUBTEST: display-unload-order
+ * Description: Verify the GPU driver, then intel_display, unload cleanly in order.
+ *
+ * SUBTEST: display-reverse-order
+ * Description: Load the GPU driver alone, then unload intel_display first.
+ */
+
+#include "igt.h"
+#include "igt_kmod.h"
+
+struct gpu_driver {
+ const char *name;
+ int drm_driver;
+ int (*load)(const char *opts);
+ int (*unload)(void);
+};
+
+static const struct gpu_driver drivers[] = {
+ { "i915", DRIVER_INTEL, igt_i915_driver_load, igt_i915_driver_unload },
+ { "xe", DRIVER_XE, igt_xe_driver_load, igt_xe_driver_unload },
+};
+
+static const struct gpu_driver *cur;
+
+/*
+ * intel_display is only a separate module on kernels where the display code
+ * has been split out of the GPU drivers. Detect that before touching anything.
+ */
+static bool module_available(const char *name)
+{
+ char cmd[64];
+
+ if (igt_kmod_is_loaded(name))
+ return true;
+
+ snprintf(cmd, sizeof(cmd), "modinfo -n %s >/dev/null 2>&1", name);
+ return system(cmd) == 0;
+}
+
+static int unload_display(void)
+{
+ int err = igt_kmod_unload("intel_display");
+
+ return err == -ENOENT ? 0 : err;
+}
+
+static void unload_all(void)
+{
+ for (int i = 0; i < ARRAY_SIZE(drivers); i++) {
+ if (!igt_kmod_is_loaded(drivers[i].name))
+ continue;
+ igt_assert_eq(drivers[i].unload(), 0);
+ igt_assert_f(!igt_kmod_is_loaded(drivers[i].name),
+ "%s failed to unload\n", drivers[i].name);
+ }
+
+ igt_assert_eq(unload_display(), 0);
+ igt_assert_f(!igt_kmod_is_loaded("intel_display"),
+ "intel_display failed to unload\n");
+}
+
+static void load_display_only(void)
+{
+ igt_assert_eq(igt_kmod_load("intel_display", NULL), 0);
+ igt_assert(igt_kmod_is_loaded("intel_display"));
+
+ for (int i = 0; i < ARRAY_SIZE(drivers); i++)
+ igt_assert(!igt_kmod_is_loaded(drivers[i].name));
+}
+
+static void load_and_check_driver(void)
+{
+ int fd;
+
+ igt_assert_eq(cur->load(NULL), 0);
+
+ fd = __drm_open_driver(cur->drm_driver);
+ igt_fail_on_f(fd < 0, "Cannot open the %s DRM driver after modprobing it.\n",
+ cur->name);
+ drm_close_driver(fd);
+}
+
+static void exit_handler(int sig)
+{
+ /* Leave the machine with the driver loaded, default params */
+ if (cur && !igt_kmod_is_loaded(cur->name))
+ cur->load(NULL);
+}
+
+static void test_load_no_gpu_driver(void)
+{
+ unload_all();
+ load_display_only();
+ unload_all();
+}
+
+static void test_unload_no_gpu_driver(void)
+{
+ unload_all();
+
+ /* Unloading an absent module must be a harmless no-op */
+ igt_assert_eq(unload_display(), 0);
+
+ /* ... and the module must still be loadable afterwards */
+ load_display_only();
+ igt_assert_eq(unload_display(), 0);
+ igt_assert(!igt_kmod_is_loaded("intel_display"));
+}
+
+static void test_load_then_gpu_driver(void)
+{
+ unload_all();
+ load_display_only();
+
+ load_and_check_driver();
+ igt_assert(igt_kmod_is_loaded("intel_display"));
+ igt_assert(igt_kmod_is_loaded(cur->name));
+}
+
+static void test_unload_order(void)
+{
+ unload_all();
+ load_display_only();
+ load_and_check_driver();
+
+ /*
+ * The GPU driver depends on intel_display, so unload it first. Remove
+ * only the driver module: the unload helpers also remove intel_display.
+ */
+ igt_assert_eq(igt_kmod_unload(cur->name), 0);
+ igt_assert(!igt_kmod_is_loaded(cur->name));
+
+ igt_assert_eq(unload_display(), 0);
+ igt_assert(!igt_kmod_is_loaded("intel_display"));
+}
+
+static void test_reverse_order(void)
+{
+ unload_all();
+
+ /* The driver loaded first must bring intel_display in as a dependency */
+ load_and_check_driver();
+ igt_assert_f(igt_kmod_is_loaded("intel_display"),
+ "intel_display was not loaded as a %s dependency\n", cur->name);
+
+ /*
+ * Reverse of the normal teardown: unload intel_display first. As it
+ * is in use by the driver, its holders must be removed with it.
+ */
+ igt_assert_eq(unload_display(), 0);
+ igt_assert(!igt_kmod_is_loaded("intel_display"));
+ igt_assert(!igt_kmod_is_loaded(cur->name));
+}
+
+static void run_for_each_driver(void (*fn)(void))
+{
+ bool ran = false;
+
+ for (int i = 0; i < ARRAY_SIZE(drivers); i++) {
+ if (!module_available(drivers[i].name))
+ continue;
+
+ cur = &drivers[i];
+ igt_dynamic(cur->name)
+ fn();
+ ran = true;
+ }
+
+ igt_skip_on_f(!ran, "No supported GPU driver module found\n");
+}
+
+int igt_main()
+{
+ igt_fixture() {
+ igt_require_f(module_available("intel_display"),
+ "intel_display is not a separate module on this kernel\n");
+ igt_install_exit_handler(exit_handler);
+ }
+
+ igt_describe("Verify intel_display can be loaded without a GPU driver.");
+ igt_subtest_with_dynamic("display-load-no-gpu-driver")
+ run_for_each_driver(test_load_no_gpu_driver);
+
+ igt_describe("Verify unloading intel_display with no GPU driver is harmless.");
+ igt_subtest_with_dynamic("display-unload-no-gpu-driver")
+ run_for_each_driver(test_unload_no_gpu_driver);
+
+ igt_describe("Load intel_display, then the GPU driver, and check it binds.");
+ igt_subtest_with_dynamic("display-load-then-gpu-driver")
+ run_for_each_driver(test_load_then_gpu_driver);
+
+ igt_describe("Unload the GPU driver then intel_display after loading them in order.");
+ igt_subtest_with_dynamic("display-unload-order")
+ run_for_each_driver(test_unload_order);
+
+ igt_describe("Load the GPU driver first (pulling intel_display), then unload intel_display first.");
+ igt_subtest_with_dynamic("display-reverse-order")
+ run_for_each_driver(test_reverse_order);
+}
diff --git a/tests/meson.build b/tests/meson.build
index 806320a82..c981921a4 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -88,6 +88,7 @@ test_progs = [
intel_i915_xe_progs = [
'api_intel_allocator',
+ 'intel_display_module_load',
'intel_hwmon',
]
--
2.43.0
next prev parent reply other threads:[~2026-11-18 15:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 15:44 [PATCH i-g-t 0/8] RFC: Add intel_display module support to module load tests Jeevan B
2026-11-18 15:44 ` [PATCH i-g-t 1/8] lib/igt_params: Fall back to intel_display module parameters Jeevan B
2026-11-18 15:44 ` [PATCH i-g-t 2/8] tests/kms_panel_fitting: Find fastboot param with a dedicated display module Jeevan B
2026-11-19 9:13 ` Jani Nikula
2026-11-18 15:44 ` [PATCH i-g-t 3/8] tests/intel/i915_module_load: Check intel_display in load subtest Jeevan B
2026-11-18 15:44 ` [PATCH i-g-t 4/8] tests/intel/xe_module_load: Check intel_display in load subtests Jeevan B
2026-11-18 15:44 ` [PATCH i-g-t 5/8] lib/igt_kmod: Unload intel_display together with the GPU driver Jeevan B
2026-11-18 15:44 ` Jeevan B [this message]
2026-11-18 15:44 ` [PATCH i-g-t 7/8] tests/intel/xe_module_load: Verify driver unload result Jeevan B
2026-11-18 15:44 ` [PATCH i-g-t 8/8] tests/intel/i915_module_load: " Jeevan B
2026-11-19 3:40 ` ✓ Xe.CI.BAT: success for RFC: Add intel_display module support to module load tests Patchwork
2026-11-19 12:46 ` ✗ i915.CI.BAT: failure " Patchwork
2026-11-20 3:40 ` ✗ Xe.CI.FULL: " 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=20261118154426.345883-7-jeevan.b@intel.com \
--to=jeevan.b@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=karthik.b.s@intel.com \
--cc=pranay.samala@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