All of lore.kernel.org
 help / color / mirror / Atom feed
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 5/8] lib/igt_kmod: Unload intel_display together with the GPU driver
Date: Wed, 18 Nov 2026 21:14:20 +0530	[thread overview]
Message-ID: <20261118154426.345883-6-jeevan.b@intel.com> (raw)
In-Reply-To: <20261118154426.345883-1-jeevan.b@intel.com>

With display split into a dedicated intel_display module, it stays loaded
after i915 or xe is removed and keeps its module parameters, so a driver
unload followed by a load with display parameters (e.g. disable_display=1)
is not a real reload.

Make __igt_intel_driver_unload() and igt_xe_driver_unload() also unload
intel_display. It is left alone when another GPU driver still holds it,
since igt_kmod_unload() would otherwise remove the holders as well. No
change on kernels where display is built into the GPU driver.

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

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 76680fca5..4161d3c8d 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -585,6 +585,38 @@ int igt_audio_driver_load(char **who)
 	return ret;
 }
 
+/*
+ * With display split into a dedicated intel_display module, it stays loaded
+ * after the GPU driver is removed and keeps its module parameters. Unload it
+ * as well so that a driver unload is a full unload.
+ *
+ * It is left alone when still in use by another GPU driver, as
+ * igt_kmod_unload() would otherwise unload the holders too. Does nothing on
+ * kernels where display is built into the GPU driver.
+ */
+static int intel_display_unload_if_unused(void)
+{
+	DIR *d;
+	struct dirent *de;
+	bool in_use = false;
+
+	if (!igt_kmod_is_loaded("intel_display"))
+		return 0;
+
+	d = opendir("/sys/module/intel_display/holders");
+	if (d) {
+		while ((de = readdir(d))) {
+			if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
+				in_use = true;
+				break;
+			}
+		}
+		closedir(d);
+	}
+
+	return in_use ? 0 : igt_kmod_unload("intel_display");
+}
+
 int __igt_intel_driver_unload(char **who, const char *driver)
 {
 	int ret;
@@ -624,6 +656,16 @@ int __igt_intel_driver_unload(char **who, const char *driver)
 		}
 	}
 
+	if (strcmp(driver, "intel_display")) {
+		ret = intel_display_unload_if_unused();
+		if (ret) {
+			if (who)
+				*who = strdup_realloc(*who, "intel_display");
+
+			return ret;
+		}
+	}
+
 	return 0;
 }
 
@@ -763,6 +805,9 @@ int igt_xe_driver_unload(void)
 	if (igt_kmod_is_loaded("xe"))
 		return IGT_EXIT_FAILURE;
 
+	if (intel_display_unload_if_unused())
+		return IGT_EXIT_FAILURE;
+
 	return IGT_EXIT_SUCCESS;
 }
 
-- 
2.43.0


  parent reply	other threads:[~2026-11-18 15:49 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 ` Jeevan B [this message]
2026-11-18 15:44 ` [PATCH i-g-t 6/8] tests/intel: Add intel_display_module_load test Jeevan B
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-6-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.