[igt-dev] [PATCH i-g-t 1/3] lib/drmtest : add function to call exit handler to unload i915 module
Riana Tauro
riana.tauro at intel.com
Mon Mar 28 05:17:25 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..e84e0360 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..df551873 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -88,6 +88,7 @@ void __set_forced_driver(const char *name);
*/
#define ALIGN_DOWN(x, a) ALIGN((x) - ((a) - 1), (a))
+void drm_cancel_work_at_exit(void);
void drm_load_module(unsigned int chipset);
int drm_open_driver(int chipset);
int drm_open_driver_master(int chipset);
--
2.25.1
More information about the igt-dev
mailing list