From patchwork Thu Dec 21 12:53:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Latvala X-Patchwork-Id: 10127633 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 1E5856019C for ; Thu, 21 Dec 2017 12:54:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 284142094F for ; Thu, 21 Dec 2017 12:54:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BC7729BD8; Thu, 21 Dec 2017 12:54:01 +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 1C4032094F for ; Thu, 21 Dec 2017 12:53:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 258B26E644; Thu, 21 Dec 2017 12:53:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E0A26E644; Thu, 21 Dec 2017 12:53:57 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Dec 2017 04:53:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,435,1508828400"; d="scan'208";a="188716552" Received: from thrakatuluk.fi.intel.com (HELO thrakatuluk) ([10.237.68.137]) by fmsmga005.fm.intel.com with ESMTP; 21 Dec 2017 04:53:55 -0800 Received: from platvala by thrakatuluk with local (Exim 4.89) (envelope-from ) id 1eS0ME-0007Yy-3r; Thu, 21 Dec 2017 14:53:54 +0200 From: Petri Latvala To: intel-gfx@lists.freedesktop.org Date: Thu, 21 Dec 2017 14:53:41 +0200 Message-Id: <20171221125341.29033-1-petri.latvala@intel.com> X-Mailer: git-send-email 2.14.1 Cc: igt-dev@lists.freedesktop.org, Tomi Sarvela Subject: [Intel-gfx] [PATCH i-g-t 1/1] igt_aux: Skip hibernation attempts if hibernation is not configured 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 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 Cc: Marta Lofstedt Cc: Tomi Sarvela Cc: Arkadiusz Hiler --- 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);