[PATCH i-g-t 2/4] lib/igt_sysfs: Fix close when rebinding

Lucas De Marchi lucas.demarchi at intel.com
Wed Dec 18 05:13:22 UTC 2024


This function could be de-multiplexed and use single functions to each
action (e.g. igt_kmod_unbind already exists). However, with the aim of
simply fixing the bug, make sure the fd is closed with
__drm_close_driver(), otherwise the cached fd is not invalidated and
later drm_open_driver() fails because the driver is considered already
opened.

Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
 lib/igt_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index eaf8fd882..9427767b0 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -1530,7 +1530,7 @@ int xe_sysfs_driver_do(int xe_device, char pci_slot[], enum xe_sysfs_driver_acti
 		 * We need to close the client for a proper release, before
 		 * binding back again.
 		 */
-		close(xe_device);
+		__drm_close_driver(xe_device);
 
 		igt_assert(igt_sysfs_set(sysfs, "bind", pci_slot));
 		close(sysfs);
-- 
2.47.0



More information about the igt-dev mailing list