[igt-dev] [PATCH i-g-t v4 6/6] tests/fbcon_fbt: Do not keep opening debugfs_fd at every setup_drm() call

José Roberto de Souza jose.souza at intel.com
Fri Apr 12 17:21:36 UTC 2019


As debugfs_fd is used even after the teardown_drm(), it is not closed
in this function or in any other place. And then it gets worse as
every call to setup_drm() will open another file descriptor to
debugfs dir.

So lets move the opening of debugfs_fd to setup_environment() and only
open it once and close it before leave the test.

Reviewed-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
 tests/kms_fbcon_fbt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c
index 4a149104..acbb6d30 100644
--- a/tests/kms_fbcon_fbt.c
+++ b/tests/kms_fbcon_fbt.c
@@ -64,7 +64,6 @@ static void setup_drm(struct drm_info *drm)
 		return;
 
 	drm->fd = drm_open_driver_master(DRIVER_INTEL);
-	drm->debugfs_fd = igt_debugfs_dir(drm->fd);
 
 	drm->res = drmModeGetResources(drm->fd);
 	igt_require(drm->res);
@@ -299,12 +298,14 @@ static void subtest(struct drm_info *drm, struct feature *feature, bool suspend)
 	}
 }
 
-static void setup_environment(void)
+static void setup_environment(struct drm_info *drm)
 {
 	int drm_fd;
 
 	drm_fd = drm_open_driver_master(DRIVER_INTEL);
 	igt_require(drm_fd >= 0);
+	drm->debugfs_fd = igt_debugfs_dir(drm_fd);
+	igt_require(drm->debugfs_fd >= 0);
 	igt_assert(close(drm_fd) == 0);
 
 	/*
@@ -319,6 +320,8 @@ static void teardown_environment(struct drm_info *drm)
 {
 	if (drm->fd >= 0)
 		teardown_drm(drm);
+
+	close(drm->debugfs_fd);
 }
 
 igt_main
@@ -326,7 +329,7 @@ igt_main
 	struct drm_info drm = { .fd = -1 };
 
 	igt_fixture
-		setup_environment();
+		setup_environment(&drm);
 
 	igt_subtest("fbc")
 		subtest(&drm, &fbc, false);
-- 
2.21.0



More information about the igt-dev mailing list