[Intel-gfx] [PATCH i-g-t 3/4] lib/igt_pm: Export function to restore runtime PM status

Tvrtko Ursulin tursulin at ursulin.net
Mon Jul 23 11:46:57 UTC 2018


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

In cases when runtime PM is enabled only from individual subtests and not
whole tests it is usable to be able to restore the old runtime PM config
and so avoid running subsequent subtests in an unexpected environment.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 lib/igt_pm.c | 41 +++++++++++++++++++++++++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 42 insertions(+)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index a4c0cf335f6d..a861055d382b 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -106,6 +106,23 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	return 0;
 }
 
+static void igt_pm_audio_restore_runtime_pm(void)
+{
+	int ret;
+
+	if (!__igt_pm_audio_runtime_power_save[0])
+		return;
+
+	igt_debug("Restoring audio power management to '%s' and '%s'\n",
+		  __igt_pm_audio_runtime_power_save,
+		  __igt_pm_audio_runtime_control);
+
+	ret = __igt_pm_audio_restore_runtime_pm();
+	if (ret)
+		igt_warn("Failed to restore runtime audio PM! (errno=%d)\n",
+			 ret);
+}
+
 static void __igt_pm_audio_runtime_exit_handler(int sig)
 {
 	__igt_pm_audio_restore_runtime_pm();
@@ -393,6 +410,30 @@ static int __igt_restore_runtime_pm(void)
 	return 0;
 }
 
+/**
+ * igt_restore_runtime_pm:
+ *
+ * Restores the runtime PM configuration as it was before the call to
+ * igt_setup_runtime_pm.
+ */
+void igt_restore_runtime_pm(void)
+{
+	int ret;
+
+	if (pm_status_fd < 0)
+		return;
+
+	igt_debug("Restoring runtime PM management to '%s' and '%s'\n",
+		  __igt_pm_runtime_autosuspend,
+		  __igt_pm_runtime_control);
+
+	ret = __igt_restore_runtime_pm();
+	if (ret)
+		igt_warn("Failed to restore runtime PM! (errno=%d)\n", ret);
+
+	igt_pm_audio_restore_runtime_pm();
+}
+
 static void __igt_pm_runtime_exit_handler(int sig)
 {
 	__igt_restore_runtime_pm();
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index eced39f8801a..10cc6794e4e7 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -47,6 +47,7 @@ enum igt_runtime_pm_status {
 };
 
 bool igt_setup_runtime_pm(void);
+void igt_restore_runtime_pm(void);
 enum igt_runtime_pm_status igt_get_runtime_pm_status(void);
 bool igt_wait_for_pm_status(enum igt_runtime_pm_status status);
 
-- 
2.17.1



More information about the Intel-gfx mailing list