[igt-dev] [PATCH i-g-t 1/1] igt_aux: Skip hibernation attempts if hibernation is not configured

Petri Latvala petri.latvala at intel.com
Thu Dec 21 12:53:41 UTC 2017


rtcwake doesn't give us meaningful ways of differentiating different
reasons for hibernation failing. CI doesn't configure hibernation to
work at this time, and hibernation attempts will always fail. Check
for the configuration in the form of resume= appearing on the kernel
command line, which is what swsusp uses to find the resume device to
hibernate to.

Hibernation failures have dug up a couple of bugs in the past, but
finding actual bugs in the swamp of "rtcwake failed with 1" results is
difficult enough to overweigh that benefit.

Note that this only makes full hibernation to skip on unconfigured
systems. Limiting the suspend level in igt_system_suspend_autoresume
to anything other than full level still suspends.

References: https://bugs.freedesktop.org/show_bug.cgi?id=103375
Signed-off-by: Petri Latvala <petri.latvala at intel.com>
Cc: Marta Lofstedt <marta.lofstedt at intel.com>
Cc: Tomi Sarvela <tomi.p.sarvela at intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
 lib/igt_aux.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 8ca0b60d..86d9c5b9 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -775,6 +775,29 @@ static void set_suspend_test(int power_dir, enum igt_suspend_test test)
 	igt_assert(igt_sysfs_set(power_dir, "pm_test", suspend_test_name[test]));
 }
 
+static bool hibernate_configured(void)
+{
+	FILE *file;
+	size_t n = 0;
+	char *line = NULL;
+	bool matched = false;
+
+	file = fopen("/proc/cmdline", "r");
+	if (!file) {
+		/* Cannot check. Assume the best. */
+		return true;
+	}
+
+	if (getline(&line, &n, file) >= 0) {
+		matched = strstr(line, "resume=") != NULL;
+	}
+
+	free(line);
+	fclose(file);
+
+	return matched;
+}
+
 #define SQUELCH ">/dev/null 2>&1"
 
 static void suspend_via_rtcwake(enum igt_suspend_state state)
@@ -798,6 +821,15 @@ static void suspend_via_rtcwake(enum igt_suspend_state state)
 		     "the rtcwake tool or how your distro is set up.\n",
 		      ret);
 
+	/*
+	 * Skip if attempting to suspend to disk and hibernation is
+	 * not configured.
+	 */
+	if (state == SUSPEND_STATE_DISK) {
+		igt_require_f(hibernate_configured(),
+			      "Cannot suspend to disk; Hibernation device not configured.\n");
+	}
+
 	snprintf(cmd, sizeof(cmd), "rtcwake -s %d -m %s ",
 		 delay, suspend_state_name[state]);
 	ret = igt_system(cmd);
-- 
2.14.1



More information about the igt-dev mailing list