intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Lyude <lyude@redhat.com>
To: intel-gfx@lists.freedesktop.org
Cc: Lyude <lyude@redhat.com>
Subject: [RFC i-g-t 2/4] igt_aux: Add igt_set_autoresume_delay()
Date: Mon,  7 Nov 2016 19:05:14 -0500	[thread overview]
Message-ID: <1478563516-23568-3-git-send-email-lyude@redhat.com> (raw)
In-Reply-To: <1478563516-23568-1-git-send-email-lyude@redhat.com>

The default autoresume delay is about 5 seconds. It's possible on a
system that's not very fast this might not be a long enough time, since
an asynchronous hotplug event we scheduled on the chamelium that was
intended to happen during suspend could happen before we actually manage
to suspend. So, add a function that allows us to increase the autoresume
time to ensure this never happens during suspend/resume tests with the
chamelium.

Signed-off-by: Lyude <lyude@redhat.com>
---
 lib/igt_aux.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_aux.h |  1 +
 2 files changed, 47 insertions(+)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 9754148..26d32fd 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -812,6 +812,52 @@ void igt_system_suspend_autoresume(enum igt_suspend_state state,
 	close(power_dir);
 }
 
+static int original_autoresume_delay;
+
+static void igt_restore_autoresume_delay(int sig)
+{
+	int delay_fd;
+	char delay_str[10];
+
+	igt_assert((delay_fd = open("/sys/module/suspend/parameters/pm_test_delay",
+				    O_WRONLY)) >= 0);
+
+	snprintf(delay_str, sizeof(delay_str), "%d", original_autoresume_delay);
+	igt_assert(write(delay_fd, delay_str, strlen(delay_str)));
+
+	close(delay_fd);
+}
+
+/**
+ * igt_set_autoresume_delay:
+ * @delay_secs: The delay in seconds before resuming the system
+ *
+ * Sets how long we wait to resume the system after suspending it, using the
+ * suspend.pm_test_delay variable. On exit, the original delay value is
+ * restored.
+ */
+void igt_set_autoresume_delay(int delay_secs)
+{
+	int delay_fd;
+	char delay_str[10];
+
+	igt_skip_on_simulation();
+
+	igt_assert((delay_fd = open("/sys/module/suspend/parameters/pm_test_delay",
+				    O_RDWR)) >= 0);
+
+	if (!original_autoresume_delay) {
+		igt_assert(read(delay_fd, delay_str, sizeof(delay_str)));
+		original_autoresume_delay = atoi(delay_str);
+		igt_install_exit_handler(igt_restore_autoresume_delay);
+	}
+
+	snprintf(delay_str, sizeof(delay_str), "%d", delay_secs);
+	igt_assert(write(delay_fd, delay_str, strlen(delay_str)));
+
+	close(delay_fd);
+}
+
 /**
  * igt_drop_root:
  *
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 973a9cd..7cee901 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -174,6 +174,7 @@ void igt_skip_without_suspend_support(enum igt_suspend_state state,
 				      enum igt_suspend_test test);
 void igt_system_suspend_autoresume(enum igt_suspend_state state,
 				   enum igt_suspend_test test);
+void igt_set_autoresume_delay(int delay_secs);
 
 /* dropping priviledges */
 void igt_drop_root(void);
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-11-08  0:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-08  0:05 [RFC i-g-t 0/4] intel-gpu-tools: Add support for the Chamelium Lyude
2016-11-08  0:05 ` [RFC i-g-t 1/4] igt_aux: Add igt_skip_without_suspend_support() Lyude
2016-11-08  0:05 ` Lyude [this message]
2016-11-08  9:39   ` [RFC i-g-t 2/4] igt_aux: Add igt_set_autoresume_delay() Chris Wilson
2016-11-08  0:05 ` [RFC i-g-t 3/4] igt_aux: Add some list helpers from wayland Lyude
2016-11-08  9:37   ` Chris Wilson
2016-11-08  0:05 ` [RFC i-g-t 4/4] Add support for hotplug testing with the Chamelium Lyude
2016-11-09 15:18   ` Tomeu Vizoso
2016-11-14  7:05   ` Daniel Vetter
2016-11-14 16:46     ` Lyude Paul
2016-11-09 15:09 ` [RFC i-g-t 0/4] intel-gpu-tools: Add support for " Tomeu Vizoso
2016-11-11 17:53   ` Lyude Paul
2016-11-15 11:44     ` Tomeu Vizoso
2016-11-15 21:44       ` Lyude Paul
2016-11-16 11:52         ` Tomeu Vizoso
2016-11-28 20:10           ` Lyude Paul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1478563516-23568-3-git-send-email-lyude@redhat.com \
    --to=lyude@redhat.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).