Skip to contentSkip to conversation

tests/gem_ctx_freq: Fix frequency restoration in exit handler

PATCH Superseded Sk Anirban 1 participant 1 message Oct 14, 2025

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Sk Anirban

author
#0 lore raw

PATCH 1/1 tests/gem_ctx_freq: Fix frequency restoration in exit handler

The exit handler was failing to restore frequencies as it was being called after the driver was closed. Reopen the driver in the exit handler to ensure proper frequency restoration.

---
 tests/intel/gem_ctx_freq.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
tests/intel/gem_ctx_freq.c +13 -3
index 29fdf89cb..a9bc9a017 100644
@@ -214,10 +214,18 @@ static void __restore_sysfs_freq(int dirfd)
 
 static void restore_sysfs_freq(int sig)
 {
-	int dirfd, gt;
+	int sysfs_restore, dirfd, gt, fd;
 
-	for_each_sysfs_gt_dirfd(i915, dirfd, gt)
+	fd = drm_open_driver(DRIVER_INTEL);
+	igt_require_gem(fd);
+	sysfs_restore = igt_sysfs_open(fd);
+	igt_assert(sysfs_restore != -1);
+
+	for_each_sysfs_gt_dirfd(fd, dirfd, gt)
 		__restore_sysfs_freq(dirfd);
+
+	close(sysfs_restore);
+	drm_close_driver(fd);
 }
 
 static void __disable_boost(int dirfd)
@@ -262,6 +270,8 @@ igt_main
 				sysfs_range(dirfd, gt);
 	}
 
-	igt_fixture
+	igt_fixture {
+		close(sysfs);
 		drm_close_driver(i915);
+	}
 }
Signature · 1 line
2.43.0