Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jeevan B <jeevan.b@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: karthik.b.s@intel.com, jani.nikula@intel.com,
	Jeevan B <jeevan.b@intel.com>
Subject: [PATCH i-g-t 4/4] tests/intel/xe_module_load: Add intel_display module subtests
Date: Tue, 24 Nov 2026 10:15:59 +0530	[thread overview]
Message-ID: <20261124044559.897167-5-jeevan.b@intel.com> (raw)
In-Reply-To: <20261124044559.897167-1-jeevan.b@intel.com>

Treat a leftover intel_display as an unwanted driver for the "load"
subtest and add the same intel_display ordering subtests as for i915
(load-xe-then-display, unload-display-with-xe,
unload-xe-also-unloads-display, reload-display-only). They skip when the
module does not exist.

Signed-off-by: Jeevan B <jeevan.b@intel.com>
---
 tests/intel/xe_module_load.c | 100 +++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)

diff --git a/tests/intel/xe_module_load.c b/tests/intel/xe_module_load.c
index 0c75c4ebc..4cefba09d 100644
--- a/tests/intel/xe_module_load.c
+++ b/tests/intel/xe_module_load.c
@@ -94,9 +94,18 @@ static void load_and_check_xe(const char *opts)
 static const char * const unwanted_drivers[] = {
 	"xe",
 	"i915",
+	"intel_display",
 	NULL
 };
 
+/* Start from a clean slate and skip if there is no dedicated display module */
+static void display_module_setup(void)
+{
+	igt_require_f(!igt_xe_driver_unload(), "Could not unload xe\n");
+
+	igt_intel_display_prepare_alone();
+}
+
 /**
  * SUBTEST: force-load
  * Description: Load the Xe driver passing ``force_probe=*`` parameter
@@ -115,6 +124,22 @@ static const char * const unwanted_drivers[] = {
  *
  * SUBTEST: many-reload
  * Description: Reload the Xe driver many times
+ *
+ * SUBTEST: load-xe-then-display
+ * Description: Load the Xe driver and check that the intel_display module it
+ *		depends on is loaded as well.
+ *
+ * SUBTEST: unload-display-with-xe
+ * Description: Check that intel_display cannot be removed while Xe holds it,
+ *		then unload both and load Xe again.
+ *
+ * SUBTEST: unload-xe-also-unloads-display
+ * Description: Check that unloading Xe also removes the intel_display module
+ *		once nothing else holds it.
+ *
+ * SUBTEST: reload-display-only
+ * Description: Unload and reload the intel_display module and then bring Xe
+ *		back up on top of it.
  */
 int igt_main()
 {
@@ -165,5 +190,80 @@ int igt_main()
 		/* only default modparams, can leave module loaded */
 	}
 
+	igt_describe("Load xe and check that intel_display is pulled in as a dependency.");
+	igt_subtest("load-xe-then-display") {
+		display_module_setup();
+		igt_assert_eq(igt_intel_display_unload(), 0);
+		igt_assert_intel_driver_and_display_unloaded("xe");
+
+		load_and_check_xe(NULL);
+		igt_assert(igt_kmod_is_loaded("intel_display"));
+	}
+
+	igt_describe("Check intel_display is held by xe, then unload both and reload xe.");
+	igt_subtest("unload-display-with-xe") {
+		int ret;
+
+		/* modprobe intel_display: loads alone, nothing uses it yet */
+		display_module_setup();
+		igt_assert(igt_kmod_is_loaded("intel_display"));
+		igt_assert_f(!igt_kmod_is_loaded("xe"), "xe loaded with display only\n");
+		igt_assert_f(!igt_intel_display_has_holders(),
+			     "intel_display held before xe was loaded\n");
+
+		/* modprobe xe: display is now used by it */
+		load_and_check_xe(NULL);
+		igt_assert(igt_kmod_is_loaded("xe"));
+		igt_assert_f(igt_intel_display_has_holders(),
+			     "intel_display not held by xe\n");
+
+		/*
+		 * rmmod intel_display: refused, xe calls into display. The
+		 * kernel reports -EWOULDBLOCK while other modules depend on the
+		 * target (libkmod removes non-blocking), -EBUSY otherwise.
+		 */
+		ret = igt_intel_display_try_unload();
+		igt_assert_f(ret == -EWOULDBLOCK || ret == -EBUSY,
+			     "intel_display removed or unexpected error while xe holds it: %d\n", ret);
+		igt_assert(igt_kmod_is_loaded("xe"));
+		igt_assert(igt_kmod_is_loaded("intel_display"));
+
+		/* rmmod xe: goes first, intel_display stays behind, unused */
+		igt_assert_eq(igt_intel_driver_unload_keep_display("xe"), 0);
+		igt_assert_f(!igt_kmod_is_loaded("xe"), "xe still loaded\n");
+		igt_assert_f(igt_kmod_is_loaded("intel_display"),
+			     "intel_display disappeared with xe\n");
+		igt_assert_f(!igt_intel_display_has_holders(),
+			     "intel_display still held after xe was removed\n");
+
+		/* rmmod intel_display: now it works */
+		igt_assert_eq(igt_intel_display_unload(), 0);
+		igt_assert_intel_driver_and_display_unloaded("xe");
+
+		load_and_check_xe(NULL);
+	}
+
+	igt_describe("Check that unloading xe also removes the intel_display it no longer uses.");
+	igt_subtest("unload-xe-also-unloads-display") {
+		display_module_setup();
+		load_and_check_xe(NULL);
+		igt_assert(igt_kmod_is_loaded("intel_display"));
+
+		igt_assert_eq(igt_xe_driver_unload(), 0);
+		igt_assert_intel_driver_and_display_unloaded("xe");
+
+		load_and_check_xe(NULL);
+	}
+
+	igt_describe("Reload only the display module, then reload xe on top of it.");
+	igt_subtest("reload-display-only") {
+		display_module_setup();
+		igt_assert_eq(igt_intel_display_unload(), 0);
+		igt_assert_intel_driver_and_display_unloaded("xe");
+
+		igt_assert_eq(igt_intel_display_load(NULL), 0);
+		load_and_check_xe(NULL);
+	}
+
 	/* Subtests should unload the module themselves if they use modparams */
 }
-- 
2.43.0


  parent reply	other threads:[~2026-11-24  4:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  4:45 [PATCH i-g-t 0/4] RFC: Add intel_display module support to module load tests Jeevan B
2026-11-24  4:45 ` [PATCH i-g-t 1/4] lib/igt_params: Fall back to intel_display module parameters Jeevan B
2026-11-24  4:45 ` [PATCH i-g-t 2/4] lib/igt_kmod: Handle the dedicated intel_display module Jeevan B
2026-11-24  4:45 ` [PATCH i-g-t 3/4] tests/intel/i915_module_load: Add intel_display module subtests Jeevan B
2026-11-24  4:45 ` Jeevan B [this message]
2026-11-24  5:28 ` ✓ Xe.CI.BAT: success for RFC: Add intel_display module support to module load tests (rev2) Patchwork
2026-11-24  5:47 ` ✗ i915.CI.BAT: 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=20261124044559.897167-5-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 \
    /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