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: [RESEND PATCH i-g-t v2 1/5] igt_aux: Add igt_set_autoresume_delay()
Date: Fri, 20 Jan 2017 13:58:20 -0500	[thread overview]
Message-ID: <20170120185824.12692-2-lyude@redhat.com> (raw)
In-Reply-To: <20170120185824.12692-1-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.

Cc: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Signed-off-by: Lyude <lyude@redhat.com>

Changes since v1:
- Use igt_require, not assert
---
 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 f323f6a..763e997 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -786,6 +786,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_require((delay_fd = open("/sys/module/suspend/parameters/pm_test_delay",
+				    O_WRONLY)) >= 0);
+
+	snprintf(delay_str, sizeof(delay_str), "%d", original_autoresume_delay);
+	igt_require(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_require((delay_fd = open("/sys/module/suspend/parameters/pm_test_delay",
+				    O_RDWR)) >= 0);
+
+	if (!original_autoresume_delay) {
+		igt_require(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_require(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 30f914b..cb54ca5 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -183,6 +183,7 @@ enum igt_suspend_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.9.3

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

  reply	other threads:[~2017-01-20 18:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 18:58 [RESEND PATCH i-g-t v4 0/5] Add support for the Chamelium Lyude
2017-01-20 18:58 ` Lyude [this message]
2017-01-20 18:58 ` [RESEND PATCH i-g-t v3 2/5] igt_kms: Add helpers for watching for sysfs hotplug events Lyude
2017-01-20 18:58 ` [RESEND PATCH i-g-t 3/5] igt_kms: Add igt_output_from_connector Lyude
2017-01-20 18:58 ` [RESEND PATCH i-g-t 4/5] igt_kms: Add kmstest_set_connector_broadcast_rgb() Lyude
2017-01-20 18:58 ` [RESEND PATCH i-g-t v4 5/5] Add support for hotplug testing with the Chamelium Lyude

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=20170120185824.12692-2-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).