From patchwork Fri Feb 20 00:38:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Herbert X-Patchwork-Id: 5854251 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 858D9BF440 for ; Fri, 20 Feb 2015 00:38:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 449DF20351 for ; Fri, 20 Feb 2015 00:38:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5A6C62034E for ; Fri, 20 Feb 2015 00:38:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE12389AC0; Thu, 19 Feb 2015 16:38:55 -0800 (PST) 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 ESMTP id E96B789AF3 for ; Thu, 19 Feb 2015 16:38:53 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 19 Feb 2015 16:33:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,611,1418112000"; d="scan'208";a="654628302" Received: from mherber2-mobl.jf.intel.com ([10.7.202.94]) by orsmga001.jf.intel.com with ESMTP; 19 Feb 2015 16:38:53 -0800 From: Marc Herbert To: intel-gfx@lists.freedesktop.org Date: Thu, 19 Feb 2015 16:38:43 -0800 Message-Id: <1424392723-21741-2-git-send-email-marc.herbert@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1424392723-21741-1-git-send-email-marc.herbert@intel.com> References: <1424392723-21741-1-git-send-email-marc.herbert@intel.com> Cc: Marc Herbert Subject: [Intel-gfx] [PATCH i-g-t] lib/igt_kms.c: remove tests dependency on VT /dev/tty0 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Required to run on any recent, freon-based and X11-free ChromeOS release. Signed-off-by: Marc Herbert --- lib/igt_kms.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index d0c3690..27cff86 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -299,12 +299,24 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id) return pfci.pipe; } +static unsigned long orig_vt_mode = -1UL; + static signed long set_vt_mode(unsigned long mode) { int fd; unsigned long prev_mode; + static const char TTY0[] = "/dev/tty0"; + + if (access(TTY0, F_OK)) { + /* errno message should be "No such file". Do not + hardcode but ask strerror() in the very unlikely + case something else happened. */ + igt_warn("VT: %s: %s, cannot change its mode\n", + TTY0, strerror(errno)); + return orig_vt_mode; + } - fd = open("/dev/tty0", O_RDONLY); + fd = open(TTY0, O_RDONLY); if (fd < 0) return -errno; @@ -323,8 +335,6 @@ err: return -errno; } -static unsigned long orig_vt_mode = -1UL; - /** * kmstest_restore_vt_mode: * @@ -363,6 +373,10 @@ void kmstest_set_vt_graphics_mode(void) ret = set_vt_mode(KD_GRAPHICS); igt_enable_exit_handler(); + /* Return if set_vt_mode has successfully not changed anything */ + if (ret == orig_vt_mode) + return; + igt_assert(ret >= 0); orig_vt_mode = ret;