From patchwork Tue Feb 24 20:29:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Herbert X-Patchwork-Id: 5875181 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 8561EBF440 for ; Tue, 24 Feb 2015 20:30:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B425C20259 for ; Tue, 24 Feb 2015 20:30:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DD90B20256 for ; Tue, 24 Feb 2015 20:30:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 775116E5C2; Tue, 24 Feb 2015 12:30:05 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 950CD6E5C2 for ; Tue, 24 Feb 2015 12:30:04 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 24 Feb 2015 12:30:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,641,1418112000"; d="scan'208";a="690216933" Received: from mherber2-mobl.jf.intel.com ([10.7.202.94]) by orsmga002.jf.intel.com with ESMTP; 24 Feb 2015 12:30:04 -0800 From: Marc Herbert To: intel-gfx@lists.freedesktop.org Date: Tue, 24 Feb 2015 12:29:22 -0800 Message-Id: <1424809762-30621-1-git-send-email-marc.herbert@intel.com> X-Mailer: git-send-email 1.9.3 Cc: Marc Herbert Subject: [Intel-gfx] [PATCH v2] 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 --- Changes from v1: - igt_debug() instead of igt_warn() - return KD_GRAPHICS instead of -1UL - print previous mode in debug statements. Among others this help a tiny bit with the now confusing debug output ("cannot change" immediately followed by a misleading "mode changed"). Note: a naive "mv /dev/tty0 /dev/tty0.orig" is typically enough to test this patch. lib/igt_kms.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index d0c3690..9c131f0 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -299,12 +299,26 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id) return pfci.pipe; } +/* + * Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was + * found and nothing was done. + */ 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_debug("VT: %s: %s, cannot change its mode\n", + TTY0, strerror(errno)); + return KD_GRAPHICS; + } - fd = open("/dev/tty0", O_RDONLY); + fd = open(TTY0, O_RDONLY); if (fd < 0) return -errno; @@ -336,10 +350,10 @@ void kmstest_restore_vt_mode(void) if (orig_vt_mode != -1UL) { ret = set_vt_mode(orig_vt_mode); - orig_vt_mode = -1UL; igt_assert(ret >= 0); - igt_debug("VT: original mode restored\n"); + igt_debug("VT: original mode 0x%lx restored\n", orig_vt_mode); + orig_vt_mode = -1UL; } } @@ -366,7 +380,7 @@ void kmstest_set_vt_graphics_mode(void) igt_assert(ret >= 0); orig_vt_mode = ret; - igt_debug("VT: graphics mode set\n"); + igt_debug("VT: graphics mode set (mode was 0x%lx)\n", ret); }