[igt-dev] [PATCH i-g-t 1/1] lib/igt_aux : Skip SUSPEND_STATE_S3 if mem_sleep deep state is not supported

Riana Tauro riana.tauro at intel.com
Wed Aug 10 09:40:27 UTC 2022


Forcing s3 by setting mem_sleep to deep fails if s3 is not
supported by platform

Skip the test by checking if s3 is not one of the supported mem_sleep
states

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/6531
Signed-off-by: Riana Tauro <riana.tauro at intel.com>
---
 lib/igt_aux.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index d80a1935..edb53425 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -882,6 +882,23 @@ static void set_mem_sleep(int power_dir, enum igt_mem_sleep sleep)
 				 mem_sleep_name[sleep]));
 }
 
+static bool is_mem_sleep_state_supported(int power_dir, enum igt_mem_sleep state)
+{
+	const char *str;
+	char *mem_sleep_states;
+
+	igt_assert((mem_sleep_states = igt_sysfs_get(power_dir, "mem_sleep")));
+
+	str = strstr(mem_sleep_states, mem_sleep_name[state]);
+
+	if (!str)
+		igt_info("mem_sleep state %s not supported.\nSupported mem_sleep states: %s\n",
+			 mem_sleep_name[state], mem_sleep_states);
+
+	free(mem_sleep_states);
+	return str;
+}
+
 /**
  * igt_system_suspend_autoresume:
  * @state: an #igt_suspend_state, the target suspend state
@@ -923,6 +940,8 @@ void igt_system_suspend_autoresume(enum igt_suspend_state state,
 
 	if (state == SUSPEND_STATE_S3) {
 		orig_mem_sleep = get_mem_sleep();
+		igt_skip_on_f(!is_mem_sleep_state_supported(power_dir, MEM_SLEEP_DEEP),
+			      "S3 not supported in this system.\n");
 		set_mem_sleep(power_dir, MEM_SLEEP_DEEP);
 		igt_skip_on_f(get_mem_sleep() != MEM_SLEEP_DEEP,
 			      "S3 not possible in this system.\n");
-- 
2.25.1



More information about the igt-dev mailing list