[Intel-gfx] [PATCH i-g-t v5 3/7] lib/igt_debugfs: Introduce CRC check function, with logic made common

Paul Kocialkowski paul.kocialkowski at linux.intel.com
Wed Jul 19 13:46:06 UTC 2017


This introduces an igt_check_crc_equal function in addition to
igt_assert_crc_equal and makes the CRC comparison logic from the latter
common. In particular, an igt_find_crc_mismatch function indicates
whether there is a mistmatch and at what index, so that the calling
functions can print the diverging values.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski at linux.intel.com>
---
 lib/igt_debugfs.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 lib/igt_debugfs.h |  1 +
 2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 2702686a..ef05dc77 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -281,6 +281,26 @@ bool igt_debugfs_search(int device, const char *filename, const char *substring)
  * Pipe CRC
  */
 
+static bool igt_find_crc_mismatch(const igt_crc_t *a, const igt_crc_t *b,
+				  int *index)
+{
+	int i;
+
+	if (a->n_words != b->n_words)
+		return true;
+
+	for (i = 0; i < a->n_words; i++) {
+		if (a->crc[i] != b->crc[i]) {
+			if (index)
+				*index = i;
+
+			return true;
+		}
+	}
+
+	return false;
+}
+
 /**
  * igt_assert_crc_equal:
  * @a: first pipe CRC value
@@ -294,10 +314,37 @@ bool igt_debugfs_search(int device, const char *filename, const char *substring)
  */
 void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b)
 {
-	int i;
+	int index;
+	bool mismatch;
+
+	mismatch = igt_find_crc_mismatch(a, b, &index);
+	if (mismatch)
+		igt_debug("CRC mismatch at index %d: 0x%x != 0x%x\n", index,
+			  a->crc[index], b->crc[index]);
+
+	igt_assert(!mismatch);
+}
+
+/**
+ * igt_check_crc_equal:
+ * @a: first pipe CRC value
+ * @b: second pipe CRC value
+ *
+ * Compares two CRC values and return whether they match.
+ *
+ * Returns: A boolean indicating whether the CRC values match
+ */
+bool igt_check_crc_equal(const igt_crc_t *a, const igt_crc_t *b)
+{
+	int index;
+	bool mismatch;
+
+	mismatch = igt_find_crc_mismatch(a, b, &index);
+	if (mismatch)
+		igt_debug("CRC mismatch at index %d: 0x%x != 0x%x\n", index,
+			  a->crc[index], b->crc[index]);
 
-	for (i = 0; i < a->n_words; i++)
-		igt_assert_eq_u32(a->crc[i], b->crc[i]);
+	return !mismatch;
 }
 
 /**
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 7b846a83..fe355919 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -114,6 +114,7 @@ enum intel_pipe_crc_source {
 };
 
 void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b);
+bool igt_check_crc_equal(const igt_crc_t *a, const igt_crc_t *b);
 char *igt_crc_to_string(igt_crc_t *crc);
 
 void igt_require_pipe_crc(int fd);
-- 
2.13.2



More information about the Intel-gfx mailing list