All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
To: Intel GFX discussion <intel-gfx@lists.freedesktop.org>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Subject: [PATCH i-g-t 2/2] lib/debugfs: Report failures when starting CRC capture
Date: Thu,  8 Sep 2016 14:38:44 +0200	[thread overview]
Message-ID: <1473338324-6986-2-git-send-email-tomeu.vizoso@collabora.com> (raw)
In-Reply-To: <1473338324-6986-1-git-send-email-tomeu.vizoso@collabora.com>

For drivers other than i915, the "auto" source for a given CRTC may be
only able to generate CRCs in specific modeset configurations.

So allow the tests to find out if CRC generation is possible by
returning an error when CRC capture would start so tests can be skipped.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
 lib/igt_debugfs.c | 28 ++++++++++++++++++++--------
 lib/igt_debugfs.h |  4 ++--
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 1bbbabc9f1c9..4b64ad8d4834 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -325,7 +325,7 @@ static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
 	return pipe_crc_sources[source];
 }
 
-static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
+static int igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 {
 	char buf[64];
 	int mode = O_RDONLY;
@@ -342,7 +342,7 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 	errno = 0;
 	igt_assert_eq(write(pipe_crc->ctl_fd, buf, strlen(buf)), strlen(buf));
 	if (errno != 0)
-		return false;
+		return errno;
 
 	if (!pipe_crc->is_legacy) {
 		sprintf(buf, "crtc-%d/crc/data", pipe_crc->pipe);
@@ -351,11 +351,11 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 			mode |= O_NONBLOCK;
 		pipe_crc->crc_fd = igt_debugfs_open(buf, mode);
 		if (pipe_crc->crc_fd == -1 && errno == EINVAL)
-			return false;
+			return errno;
 		igt_assert_eq(errno, 0);
 	}
 
-	return true;
+	return 0;
 }
 
 static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
@@ -633,11 +633,14 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
  *
  * Starts the CRC capture process on @pipe_crc.
  */
-void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
+int igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
 {
 	igt_crc_t crc;
+	int ret;
 
-	igt_assert(igt_pipe_crc_do_start(pipe_crc));
+	ret = igt_pipe_crc_do_start(pipe_crc);
+	if (ret)
+		return ret;
 
 	if (pipe_crc->is_legacy) {
 		/*
@@ -651,6 +654,8 @@ void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
 		read_one_crc(pipe_crc, &crc);
 		read_one_crc(pipe_crc, &crc);
 	}
+
+	return 0;
 }
 
 /**
@@ -756,15 +761,22 @@ static void crc_sanity_checks(igt_crc_t *crc)
  * For continuous CRC collection look at igt_pipe_crc_start(),
  * igt_pipe_crc_get_crcs() and igt_pipe_crc_stop().
  */
-void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc)
+int igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc)
 {
+	int ret;
+
 	igt_debug_wait_for_keypress("crc");
 
-	igt_pipe_crc_start(pipe_crc);
+	ret = igt_pipe_crc_start(pipe_crc);
+	if (ret)
+		return ret;
+
 	read_one_crc(pipe_crc, out_crc);
 	igt_pipe_crc_stop(pipe_crc);
 
 	crc_sanity_checks(out_crc);
+
+	return 0;
 }
 
 /*
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 84d5c0a0a84b..e51a89bbac30 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -124,12 +124,12 @@ igt_pipe_crc_new_legacy(enum pipe pipe, enum intel_pipe_crc_source source);
 igt_pipe_crc_t *
 igt_pipe_crc_new_nonblock_legacy(enum pipe pipe, enum intel_pipe_crc_source source);
 void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
-void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
+int igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
 void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
 __attribute__((warn_unused_result))
 int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
 			  igt_crc_t **out_crcs);
-void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
+int igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
 
 /*
  * Drop caches
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2016-09-08 12:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 12:38 [PATCH i-g-t 1/2] lib/debugfs: Support new generic ABI for CRC capture Tomeu Vizoso
2016-09-08 12:38 ` Tomeu Vizoso [this message]

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=1473338324-6986-2-git-send-email-tomeu.vizoso@collabora.com \
    --to=tomeu.vizoso@collabora.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.