From patchwork Fri Jan 20 18:58:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lyude Paul X-Patchwork-Id: 9529279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E913F60434 for ; Fri, 20 Jan 2017 18:58:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1A572868F for ; Fri, 20 Jan 2017 18:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4497286B3; Fri, 20 Jan 2017 18:58:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4EA0C2868F for ; Fri, 20 Jan 2017 18:58:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 879786EC5B; Fri, 20 Jan 2017 18:58:45 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BFD96EC5B for ; Fri, 20 Jan 2017 18:58:45 +0000 (UTC) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0F083A7683; Fri, 20 Jan 2017 18:58:45 +0000 (UTC) Received: from meerkat.redhat.com (vpn-60-143.rdu2.redhat.com [10.10.60.143]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0KIwhqb012414; Fri, 20 Jan 2017 13:58:45 -0500 From: Lyude To: intel-gfx@lists.freedesktop.org Date: Fri, 20 Jan 2017 13:58:20 -0500 Message-Id: <20170120185824.12692-2-lyude@redhat.com> In-Reply-To: <20170120185824.12692-1-lyude@redhat.com> References: <20170120185824.12692-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 20 Jan 2017 18:58:45 +0000 (UTC) Cc: Lyude Subject: [Intel-gfx] [RESEND PATCH i-g-t v2 1/5] igt_aux: Add igt_set_autoresume_delay() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Lyude 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);