diff mbox series

[i-g-t,1/2] igt/pm_rpm: Close local fd before trying to unload module

Message ID 20180815205924.6949-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [i-g-t,1/2] igt/pm_rpm: Close local fd before trying to unload module | expand

Commit Message

Chris Wilson Aug. 15, 2018, 8:59 p.m. UTC
Make sure everything we open in setup_environment() is paired to
teardown_environment().

Fixes: d8e78990aa2b ("igt/pm_rpm: Test reaquisition of runtime-pm after module reload")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/pm_rpm.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index 65489bcdb..c0212ed70 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -717,21 +717,23 @@  out:
 	return wait_for_suspended();
 }
 
-static void restore_environment(void)
+static void teardown_environment(void)
 {
+	close(msr_fd);
+	if (has_pc8)
+		close(pc8_status_fd);
+
+	igt_restore_runtime_pm();
+
 	igt_pm_restore_sata_link_power_management(pm_data);
 	free(pm_data);
-}
 
-static void teardown_environment(void)
-{
-	restore_environment();
 	fini_mode_set_data(&ms_data);
+
 	close(debugfs);
-	drmClose(drm_fd);
-	close(msr_fd);
-	if (has_pc8)
-		close(pc8_status_fd);
+	close(drm_fd);
+
+	has_runtime_pm = false;
 }
 
 static void basic_subtest(void)