From: Daniel Vetter <daniel@ffwll.ch>
To: Marc Herbert <marc.herbert@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH i-g-t] lib/igt_kms.c: remove tests dependency on VT /dev/tty0
Date: Tue, 24 Feb 2015 01:03:36 +0100 [thread overview]
Message-ID: <20150224000336.GH24485@phenom.ffwll.local> (raw)
In-Reply-To: <1424392723-21741-2-git-send-email-marc.herbert@intel.com>
On Thu, Feb 19, 2015 at 04:38:43PM -0800, Marc Herbert wrote:
> Required to run on any recent, freon-based and X11-free ChromeOS release.
>
> Signed-off-by: Marc Herbert <marc.herbert@intel.com>
> ---
> 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;
-1 collides with the negative errno space. Imo it's clearer to just return
KD_GRAPHICS since a system without vt is kinda always in gfx mode. This
means we'll run the exit handler but that will again be a noop because
there's still no tty.
With that change the patch looks good I think.
-Daniel
> + }
>
> - 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;
>
> --
> 1.9.3
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-02-24 0:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 0:38 [PATCH i-g-t] remove tests dependency on VT /dev/tty0 Marc Herbert
2015-02-20 0:38 ` [PATCH i-g-t] lib/igt_kms.c: " Marc Herbert
2015-02-24 0:03 ` Daniel Vetter [this message]
2015-02-24 16:12 ` Thomas Wood
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=20150224000336.GH24485@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=marc.herbert@intel.com \
/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