[igt-dev] [RFC PATCH i-g-t 2/4] lib/drmtest : add function to call exit handler to unload i915 module

Riana Tauro riana.tauro at intel.com
Thu Mar 24 10:18:50 UTC 2022


From: "Tauro, Riana" <riana.tauro at intel.com>

Unload of i915 module needs closing of  at_exit_drm_fd.
Add a function that calls the exit handler of at_exit_drm_fd
to unload module successfully

Signed-off-by: Tauro, Riana <riana.tauro at intel.com>
---
 lib/drmtest.c | 17 +++++++++++++++++
 lib/drmtest.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 09a9a229..2dafb4f7 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -588,6 +588,23 @@ int drm_open_driver(int chipset)
 	return fd;
 }
 
+/**
+ * drm_cancel_work_at_exit:
+ *
+ * calls __cancel_work_at_exit and closes
+ * at_exit_drm_fd to allow unloading of the module.
+ */
+void drm_cancel_work_at_exit(void)
+{
+	if (at_exit_drm_fd < 0)
+		return;
+	__cancel_work_at_exit(at_exit_drm_fd);
+
+	close(at_exit_drm_fd);
+	at_exit_drm_fd = -1;
+}
+
+
 /**
  * drm_open_driver_master:
  * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
diff --git a/lib/drmtest.h b/lib/drmtest.h
index b5debd44..95248f56 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -89,6 +89,7 @@ void __set_forced_driver(const char *name);
 #define ALIGN_DOWN(x, a)	ALIGN((x) - ((a) - 1), (a))
 
 void drm_load_module(unsigned int chipset);
+void drm_cancel_work_at_exit(void);
 int drm_open_driver(int chipset);
 int drm_open_driver_master(int chipset);
 int drm_open_driver_render(int chipset);
-- 
2.25.1



More information about the igt-dev mailing list