public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* pipe CRCs, intel-gpu-tools
@ 2013-10-15 18:44 Damien Lespiau
  2013-10-15 18:44 ` [PATCH 1/8] lib: Add a small helper to open debugfs files Damien Lespiau
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

And now the igt part, that adds a basic test using CRCs.

-- 
Damien

 lib/Makefile.am          |   4 +
 lib/drmtest.c            |   8 ++
 lib/drmtest.h            |  16 +++
 lib/igt_debugfs.c        | 283 ++++++++++++++++++++++++++++++++++++++++
 lib/igt_debugfs.h        |  77 +++++++++++
 lib/igt_display.c        |  41 ++++++
 lib/igt_display.h        |  57 ++++++++
 tests/.gitignore         |   1 +
 tests/Makefile.am        |   1 +
 tests/debugfs_pipe_crc.c | 237 +++++++++++++++++++++++++++++++++
	   10 files changed, 725 insertions(+)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] lib: Add a small helper to open debugfs files
  2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
@ 2013-10-15 18:44 ` Damien Lespiau
  2013-10-16 15:28   ` Ben Widawsky
  2013-10-15 18:44 ` [PATCH 2/8] lib: Add igt_debugfs_fopen() Damien Lespiau
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/Makefile.am   |  2 ++
 lib/igt_debugfs.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_debugfs.h | 36 ++++++++++++++++++++++++++
 3 files changed, 113 insertions(+)
 create mode 100644 lib/igt_debugfs.c
 create mode 100644 lib/igt_debugfs.h

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 387141b..5710802 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -11,6 +11,8 @@ libintel_tools_la_SOURCES = 	\
 	i830_reg.h		\
 	i915_3d.h		\
 	i915_reg.h		\
+	igt_debugfs.c		\
+	igt_debugfs.h		\
 	instdone.c		\
 	instdone.h		\
 	intel_batchbuffer.c	\
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
new file mode 100644
index 0000000..33c4fc1
--- /dev/null
+++ b/lib/igt_debugfs.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <sys/stat.h>
+#include <sys/mount.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "igt_debugfs.h"
+
+int igt_debugfs_init(igt_debugfs_t *debugfs)
+{
+	const char *path = "/sys/kernel/debug";
+	struct stat st;
+	int n;
+
+	if (stat("/debug/dri", &st) == 0) {
+		path = "/debug/dri";
+		goto find_minor;
+	}
+
+	if (stat("/sys/kernel/debug/dri", &st) == 0)
+		goto find_minor;
+
+	if (stat("/sys/kernel/debug", &st))
+		return errno;
+
+	if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0))
+		return errno;
+
+find_minor:
+	strcpy(debugfs->root, path);
+	for (n = 0; n < 16; n++) {
+		int len = sprintf(debugfs->dri_path, "%s/dri/%d", path, n);
+		sprintf(debugfs->dri_path + len, "/i915_error_state");
+		if (stat(debugfs->dri_path, &st) == 0) {
+			debugfs->dri_path[len] = '\0';
+			return 0;
+		}
+	}
+
+	debugfs->dri_path[0] = '\0';
+	return ENOENT;
+}
+
+int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename)
+{
+	char buf[1024];
+
+	sprintf(buf, "%s/%s", debugfs->dri_path, filename);
+	return open(buf, O_RDONLY);
+}
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
new file mode 100644
index 0000000..aa9449a
--- /dev/null
+++ b/lib/igt_debugfs.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __IGT_DEBUGFS_H__
+#define __IGT_DEBUGFS_H__
+
+typedef struct {
+	char root[128];
+	char dri_path[128];
+} igt_debugfs_t;
+
+int igt_debugfs_init(igt_debugfs_t *debugfs);
+int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename);
+
+#endif /* __IGT_DEBUGFS_H__ */
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/8] lib: Add igt_debugfs_fopen()
  2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
  2013-10-15 18:44 ` [PATCH 1/8] lib: Add a small helper to open debugfs files Damien Lespiau
@ 2013-10-15 18:44 ` Damien Lespiau
  2013-10-15 18:44 ` [PATCH 3/8] lib: Add a igt_assert_cmpint() Damien Lespiau
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/igt_debugfs.c | 9 +++++++++
 lib/igt_debugfs.h | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 33c4fc1..f194439 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -73,3 +73,12 @@ int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename)
 	sprintf(buf, "%s/%s", debugfs->dri_path, filename);
 	return open(buf, O_RDONLY);
 }
+
+FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename,
+			const char *mode)
+{
+	char buf[1024];
+
+	sprintf(buf, "%s/%s", debugfs->dri_path, filename);
+	return fopen(buf, mode);
+}
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index aa9449a..1035a93 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -25,6 +25,8 @@
 #ifndef __IGT_DEBUGFS_H__
 #define __IGT_DEBUGFS_H__
 
+#include <stdio.h>
+
 typedef struct {
 	char root[128];
 	char dri_path[128];
@@ -32,5 +34,7 @@ typedef struct {
 
 int igt_debugfs_init(igt_debugfs_t *debugfs);
 int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename);
+FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename,
+			const char *mode);
 
 #endif /* __IGT_DEBUGFS_H__ */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/8] lib: Add a igt_assert_cmpint()
  2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
  2013-10-15 18:44 ` [PATCH 1/8] lib: Add a small helper to open debugfs files Damien Lespiau
  2013-10-15 18:44 ` [PATCH 2/8] lib: Add igt_debugfs_fopen() Damien Lespiau
@ 2013-10-15 18:44 ` Damien Lespiau
  2013-10-15 18:44 ` [PATCH 4/8] lib: Add kmstest_paint_color() Damien Lespiau
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/drmtest.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/drmtest.h b/lib/drmtest.h
index ff2827d..f45780b 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -193,6 +193,20 @@ void igt_exit(void) __attribute__((noreturn));
 		__igt_fail_assert(99, __FILE__, __LINE__, __func__, #expr , f); \
 	} while (0)
 /**
+ * igt_assert_cmptint
+ *
+ * Like igt_assert(), but displays the values being compared on failure.
+ */
+#define igt_assert_cmpint(n1, cmp, n2) \
+	do { \
+		int __n1 = (n1), __n2 = (n2); \
+		if (__n1 cmp __n2) ; else \
+		__igt_fail_assert(99, __FILE__, __LINE__, __func__, \
+				  #n1 " " #cmp " " #n2, \
+				  "error: %d %s %d\n", __n1, #cmp, __n2); \
+	} while (0)
+
+/**
  * igt_require - skip a (sub-)test if a condition is not met
  *
  * This is useful to streamline the skip logic since it allows for a more flat
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/8] lib: Add kmstest_paint_color()
  2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
                   ` (2 preceding siblings ...)
  2013-10-15 18:44 ` [PATCH 3/8] lib: Add a igt_assert_cmpint() Damien Lespiau
@ 2013-10-15 18:44 ` Damien Lespiau
  2013-10-15 18:44 ` [PATCH 5/8] lib: Add a igt_display.h with a few enums and defines from the kernel Damien Lespiau
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/drmtest.c | 8 ++++++++
 lib/drmtest.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 2660af7..435a745 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1347,6 +1347,14 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp,
 	return 0;
 }
 
+void kmstest_paint_color(cairo_t *cr, int x, int y, int w, int h,
+			 double r, double g, double b)
+{
+	cairo_rectangle(cr, x, y, w, h);
+	cairo_set_source_rgb(cr, r, g, b);
+	cairo_fill(cr);
+}
+
 void
 kmstest_paint_color_gradient(cairo_t *cr, int x, int y, int w, int h,
 		     int r, int g, int b)
diff --git a/lib/drmtest.h b/lib/drmtest.h
index f45780b..b7909df 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -359,6 +359,8 @@ unsigned int kmstest_create_fb2(int fd, int width, int height, uint32_t format,
 			        bool tiled, struct kmstest_fb *fb);
 void kmstest_remove_fb(int fd, struct kmstest_fb *fb_info);
 cairo_t *kmstest_get_cairo_ctx(int fd, struct kmstest_fb *fb);
+void kmstest_paint_color(cairo_t *cr, int x, int y, int w, int h,
+			 double r, double g, double b);
 void kmstest_paint_color_gradient(cairo_t *cr, int x, int y, int w, int h,
 				  int r, int g, int b);
 void kmstest_paint_test_pattern(cairo_t *cr, int width, int height);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/8] lib: Add a igt_display.h with a few enums and defines from the kernel
  2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
                   ` (3 preceding siblings ...)
  2013-10-15 18:44 ` [PATCH 4/8] lib: Add kmstest_paint_color() Damien Lespiau
@ 2013-10-15 18:44 ` Damien Lespiau
  2013-10-15 18:44 ` [PATCH 6/8] lib: Make igt_debugfs_open() take the mode as argument Damien Lespiau
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/Makefile.am   |  1 +
 lib/igt_display.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 lib/igt_display.h

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5710802..06d406f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -13,6 +13,7 @@ libintel_tools_la_SOURCES = 	\
 	i915_reg.h		\
 	igt_debugfs.c		\
 	igt_debugfs.h		\
+	igt_display.h		\
 	instdone.c		\
 	instdone.h		\
 	intel_batchbuffer.c	\
diff --git a/lib/igt_display.h b/lib/igt_display.h
new file mode 100644
index 0000000..22c8a9f
--- /dev/null
+++ b/lib/igt_display.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __IGT_DISPLAY_H__
+#define __IGT_DISPLAY_H__
+
+enum pipe {
+        PIPE_A = 0,
+        PIPE_B,
+        PIPE_C,
+        I915_MAX_PIPES
+};
+#define pipe_name(p) ((p) + 'A')
+
+enum plane {
+        PLANE_A = 0,
+        PLANE_B,
+        PLANE_C,
+};
+#define plane_name(p) ((p) + 'A')
+
+#define sprite_name(p, s) ((p) * dev_priv->num_plane + (s) + 'A')
+
+enum port {
+        PORT_A = 0,
+        PORT_B,
+        PORT_C,
+        PORT_D,
+        PORT_E,
+        I915_MAX_PORTS
+};
+#define port_name(p) ((p) + 'A')
+
+#endif /* __IGT_DISPLAY_H__ */
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/8] lib: Make igt_debugfs_open() take the mode as argument
  2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
                   ` (4 preceding siblings ...)
  2013-10-15 18:44 ` [PATCH 5/8] lib: Add a igt_display.h with a few enums and defines from the kernel Damien Lespiau
@ 2013-10-15 18:44 ` Damien Lespiau
  2013-10-15 18:44 ` [PATCH 7/8] lib: Add igt_wait_for_vblank() helper Damien Lespiau
  2013-10-15 18:44 ` [PATCH 8/8] debugfs_pipe_crc: Let's check CRCs! Damien Lespiau
  7 siblings, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/igt_debugfs.c | 4 ++--
 lib/igt_debugfs.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index f194439..7e625e1 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -66,12 +66,12 @@ find_minor:
 	return ENOENT;
 }
 
-int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename)
+int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename, int mode)
 {
 	char buf[1024];
 
 	sprintf(buf, "%s/%s", debugfs->dri_path, filename);
-	return open(buf, O_RDONLY);
+	return open(buf, mode);
 }
 
 FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename,
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 1035a93..1ae6bbd 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -33,7 +33,7 @@ typedef struct {
 } igt_debugfs_t;
 
 int igt_debugfs_init(igt_debugfs_t *debugfs);
-int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename);
+int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename, int mode);
 FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename,
 			const char *mode);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/8] lib: Add igt_wait_for_vblank() helper
  2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
                   ` (5 preceding siblings ...)
  2013-10-15 18:44 ` [PATCH 6/8] lib: Make igt_debugfs_open() take the mode as argument Damien Lespiau
@ 2013-10-15 18:44 ` Damien Lespiau
  2013-10-15 18:44 ` [PATCH 8/8] debugfs_pipe_crc: Let's check CRCs! Damien Lespiau
  7 siblings, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/Makefile.am                      |  1 +
 lib/{igt_display.h => igt_display.c} | 38 ++++++++++++------------------------
 lib/igt_display.h                    |  2 ++
 3 files changed, 15 insertions(+), 26 deletions(-)
 copy lib/{igt_display.h => igt_display.c} (68%)

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 06d406f..431fd93 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -13,6 +13,7 @@ libintel_tools_la_SOURCES = 	\
 	i915_reg.h		\
 	igt_debugfs.c		\
 	igt_debugfs.h		\
+	igt_display.c		\
 	igt_display.h		\
 	instdone.c		\
 	instdone.h		\
diff --git a/lib/igt_display.h b/lib/igt_display.c
similarity index 68%
copy from lib/igt_display.h
copy to lib/igt_display.c
index 22c8a9f..28e21e6 100644
--- a/lib/igt_display.h
+++ b/lib/igt_display.c
@@ -22,34 +22,20 @@
  *
  */
 
-#ifndef __IGT_DISPLAY_H__
-#define __IGT_DISPLAY_H__
+#include <string.h>
 
-enum pipe {
-        PIPE_A = 0,
-        PIPE_B,
-        PIPE_C,
-        I915_MAX_PIPES
-};
-#define pipe_name(p) ((p) + 'A')
+#include "drmtest.h"
+#include "igt_display.h"
 
-enum plane {
-        PLANE_A = 0,
-        PLANE_B,
-        PLANE_C,
-};
-#define plane_name(p) ((p) + 'A')
+void igt_wait_for_vblank(int drm_fd, enum pipe pipe)
+{
+	drmVBlank wait_vbl;
 
-#define sprite_name(p, s) ((p) * dev_priv->num_plane + (s) + 'A')
+	memset(&wait_vbl, 0, sizeof(wait_vbl));
 
-enum port {
-        PORT_A = 0,
-        PORT_B,
-        PORT_C,
-        PORT_D,
-        PORT_E,
-        I915_MAX_PORTS
-};
-#define port_name(p) ((p) + 'A')
+	wait_vbl.request.type = pipe << DRM_VBLANK_HIGH_CRTC_SHIFT |
+				DRM_VBLANK_RELATIVE;
+	wait_vbl.request.sequence = 1;
 
-#endif /* __IGT_DISPLAY_H__ */
+	igt_assert(drmWaitVBlank(drm_fd, &wait_vbl) == 0);
+}
diff --git a/lib/igt_display.h b/lib/igt_display.h
index 22c8a9f..1357ce9 100644
--- a/lib/igt_display.h
+++ b/lib/igt_display.h
@@ -52,4 +52,6 @@ enum port {
 };
 #define port_name(p) ((p) + 'A')
 
+void igt_wait_for_vblank(int drm_fd, enum pipe pipe);
+
 #endif /* __IGT_DISPLAY_H__ */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/8] debugfs_pipe_crc: Let's check CRCs!
  2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
                   ` (6 preceding siblings ...)
  2013-10-15 18:44 ` [PATCH 7/8] lib: Add igt_wait_for_vblank() helper Damien Lespiau
@ 2013-10-15 18:44 ` Damien Lespiau
  7 siblings, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-15 18:44 UTC (permalink / raw)
  To: intel-gfx

Let's add a new test that sets a mode, wait for a few vblanks (3) and
then make sure we read 3 identical CRCs.

Some subtests check for various parsing errors.

In the process, improve the debugfs helpers to deal with CRCs.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/igt_debugfs.c        | 199 +++++++++++++++++++++++++++++++++++++++
 lib/igt_debugfs.h        |  37 ++++++++
 tests/.gitignore         |   1 +
 tests/Makefile.am        |   1 +
 tests/debugfs_pipe_crc.c | 237 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 475 insertions(+)
 create mode 100644 tests/debugfs_pipe_crc.c

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 7e625e1..371f583 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -28,7 +28,10 @@
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
+#include <unistd.h>
 
+#include "drmtest.h"
+#include "igt_display.h"
 #include "igt_debugfs.h"
 
 int igt_debugfs_init(igt_debugfs_t *debugfs)
@@ -82,3 +85,199 @@ FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename,
 	sprintf(buf, "%s/%s", debugfs->dri_path, filename);
 	return fopen(buf, mode);
 }
+
+/*
+ * Pipe CRC
+ */
+
+bool igt_crc_is_null(igt_crc_t *crc)
+{
+	int i;
+
+	for (i = 0; i < crc->n_words; i++)
+		if (crc->crc[i])
+			return false;
+
+	return true;
+}
+
+bool igt_crc_equal(igt_crc_t *a, igt_crc_t *b)
+{
+	int i;
+
+	if (a->n_words != b->n_words)
+		return false;
+
+	for (i = 0; i < a->n_words; i++)
+		if (a->crc[i] != b->crc[i])
+			return false;
+
+	return true;
+}
+
+char *igt_crc_to_string(igt_crc_t *crc)
+{
+	char buf[128];
+
+	if (crc->n_words == 5)
+		sprintf(buf, "%08x %08x %08x %08x %08x", crc->crc[0],
+			crc->crc[1], crc->crc[2], crc->crc[3], crc->crc[4]);
+	else
+		igt_assert(0);
+
+	return strdup(buf);
+}
+
+/* (6 fields, 8 chars each, space separated (5) + '\n') */
+#define PIPE_CRC_LINE_LEN       (6 * 8 + 5 + 1)
+/* account for \'0' */
+#define PIPE_CRC_BUFFER_LEN     (PIPE_CRC_LINE_LEN + 1)
+
+struct _igt_pipe_crc {
+	int drm_fd;
+
+	int ctl_fd;
+	int crc_fd;
+	int line_len;
+	int buffer_len;
+
+	enum pipe pipe;
+	enum intel_pipe_crc_source source;
+};
+
+igt_pipe_crc_t *
+igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
+		 enum intel_pipe_crc_source source)
+{
+	igt_pipe_crc_t *pipe_crc;
+	char buf[128];
+
+	pipe_crc = calloc(1, sizeof(struct _igt_pipe_crc));
+
+	pipe_crc->ctl_fd = igt_debugfs_open(debugfs,
+					    "i915_display_crc_ctl", O_WRONLY);
+	igt_assert(pipe_crc->crc_fd != -1);
+
+	sprintf(buf, "i915_pipe_%c_crc", pipe_name(pipe));
+	pipe_crc->crc_fd = igt_debugfs_open(debugfs, buf, O_RDONLY);
+	igt_assert(pipe_crc->crc_fd != -1);
+
+	pipe_crc->line_len = PIPE_CRC_LINE_LEN;
+	pipe_crc->buffer_len = PIPE_CRC_BUFFER_LEN;
+	pipe_crc->drm_fd = drm_fd;
+	pipe_crc->pipe = pipe;
+	pipe_crc->source = source;
+
+	return pipe_crc;
+}
+
+static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
+{
+	char buf[32];
+
+	sprintf(buf, "pipe %c none", pipe_name(pipe));
+	write(fd, buf, strlen(buf));
+}
+
+/*
+ * Turn off everything
+ */
+void igt_pipe_crc_reset(void)
+{
+	igt_debugfs_t debugfs;
+	int fd;
+
+	igt_debugfs_init(&debugfs);
+	fd = igt_debugfs_open(&debugfs, "i915_display_crc_ctl", O_WRONLY);
+
+	igt_pipe_crc_pipe_off(fd, PIPE_A);
+	igt_pipe_crc_pipe_off(fd, PIPE_B);
+	igt_pipe_crc_pipe_off(fd, PIPE_C);
+}
+
+void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc)
+{
+	close(pipe_crc->ctl_fd);
+	close(pipe_crc->crc_fd);
+	free(pipe_crc);
+}
+
+static const char *pipe_crc_sources[] = {
+        "none",
+        "plane1",
+        "plane2",
+        "pf",
+};
+
+static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
+{
+        return pipe_crc_sources[source];
+}
+
+void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
+{
+	char buf[64];
+	igt_crc_t *crcs = NULL;
+
+	igt_wait_for_vblank(pipe_crc->drm_fd, pipe_crc->pipe);
+
+	sprintf(buf, "pipe %c %s", pipe_name(pipe_crc->pipe),
+		pipe_crc_source_name(pipe_crc->source));
+	write(pipe_crc->ctl_fd, buf, strlen(buf));
+
+	/*
+	 * For some no yet identified reason, the first CRC is bonkers. So
+	 * let's just wait for the next vblank and read out the buggy result.
+	 */
+	igt_pipe_crc_get_crcs(pipe_crc, 1, &crcs);
+	free(crcs);
+}
+
+void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc)
+{
+	char buf[32];
+
+	sprintf(buf, "pipe %c none", pipe_name(pipe_crc->pipe));
+	write(pipe_crc->ctl_fd, buf, strlen(buf));
+}
+
+static bool pipe_crc_init_from_string(igt_crc_t *crc, const char *line)
+{
+	int n;
+
+	crc->n_words = 5;
+	n = sscanf(line, "%8u %8x %8x %8x %8x %8x", &crc->frame, &crc->crc[0],
+		   &crc->crc[1], &crc->crc[2], &crc->crc[3], &crc->crc[4]);
+	return n == 6;
+}
+
+/*
+ * Read @n_crcs from the @pipe_crc. This function blocks until @n_crcs are
+ * retrieved.
+ */
+void
+igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
+		      igt_crc_t **out_crcs)
+{
+	ssize_t bytes_read;
+	igt_crc_t *crcs;
+	char buf[pipe_crc->buffer_len];
+	int n = 0;
+
+	crcs = calloc(n_crcs, sizeof(igt_crc_t));
+
+	do {
+		igt_crc_t *crc = &crcs[n];
+
+		bytes_read = read(pipe_crc->crc_fd, &buf, pipe_crc->line_len);
+		igt_assert_cmpint(bytes_read, ==, pipe_crc->line_len);
+		buf[bytes_read] = '\0';
+
+		if (!pipe_crc_init_from_string(crc, buf))
+			continue;
+
+		n++;
+	} while (n < n_crcs);
+
+	*out_crcs = crcs;
+}
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 1ae6bbd..7c280e7 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -25,8 +25,12 @@
 #ifndef __IGT_DEBUGFS_H__
 #define __IGT_DEBUGFS_H__
 
+#include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
 
+#include "igt_display.h"
+
 typedef struct {
 	char root[128];
 	char dri_path[128];
@@ -37,4 +41,37 @@ int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename, int mode);
 FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename,
 			const char *mode);
 
+/*
+ * Pipe CRC
+ */
+
+enum intel_pipe_crc_source {
+        INTEL_PIPE_CRC_SOURCE_NONE,
+        INTEL_PIPE_CRC_SOURCE_PLANE1,
+        INTEL_PIPE_CRC_SOURCE_PLANE2,
+        INTEL_PIPE_CRC_SOURCE_PF,
+        INTEL_PIPE_CRC_SOURCE_MAX,
+};
+
+typedef struct _igt_pipe_crc igt_pipe_crc_t;
+typedef struct {
+	uint32_t frame;
+	int n_words;
+	uint32_t crc[5];
+} igt_crc_t;
+
+bool igt_crc_is_null(igt_crc_t *crc);
+bool igt_crc_equal(igt_crc_t *a, igt_crc_t *b);
+char *igt_crc_to_string(igt_crc_t *crc);
+
+igt_pipe_crc_t *
+igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
+		 enum intel_pipe_crc_source source);
+void igt_pipe_crc_reset(void);
+void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
+void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
+void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
+void igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
+			   igt_crc_t **out_crcs);
+
 #endif /* __IGT_DEBUGFS_H__ */
diff --git a/tests/.gitignore b/tests/.gitignore
index 7463968..1c97a04 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,5 +1,6 @@
 # Please keep sorted alphabetically
 ddi_compute_wrpll
+debugfs_pipe_crc
 drm_get_client_auth
 drm_vma_limiter
 drm_vma_limiter_cached
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 16a8b6f..843c7d2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,6 +17,7 @@ NOUVEAU_TESTS_M = \
 endif
 
 TESTS_progs_M = \
+	debugfs_pipe_crc \
 	gem_basic \
 	gem_caching \
 	gem_concurrent_blit \
diff --git a/tests/debugfs_pipe_crc.c b/tests/debugfs_pipe_crc.c
new file mode 100644
index 0000000..ff00361
--- /dev/null
+++ b/tests/debugfs_pipe_crc.c
@@ -0,0 +1,237 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "drmtest.h"
+#include "igt_debugfs.h"
+
+typedef struct {
+	struct kmstest_connector_config config;
+	drmModeModeInfo mode;
+	struct kmstest_fb fb;
+	bool valid;
+} connector_t;
+
+typedef struct {
+	int drm_fd;
+	igt_debugfs_t debugfs;
+	drmModeRes *resources;
+	int n_connectors;
+	connector_t *connectors;
+	FILE *ctl;
+} data_t;
+
+static void test_bad_command(data_t *data, const char *cmd)
+{
+	size_t written;
+
+	written = fwrite(cmd, 1, strlen(cmd), data->ctl);
+	fflush(data->ctl);
+	igt_assert_cmpint(written, ==, (strlen(cmd)));
+	igt_assert(ferror(data->ctl));
+	igt_assert_cmpint(errno, ==, EINVAL);
+}
+
+static void connector_init(data_t *data, connector_t *connector, uint32_t id)
+{
+	int ret;
+
+	ret = kmstest_get_connector_config(data->drm_fd, id, -1UL,
+					   &connector->config);
+	if (ret == 0)
+		connector->valid = true;
+
+}
+
+static void connector_fini(connector_t *connector)
+{
+	kmstest_free_connector_config(&connector->config);
+}
+
+static bool
+connector_set_mode(data_t *data, connector_t *connector, drmModeModeInfo *mode)
+{
+	struct kmstest_connector_config *config = &connector->config;
+	unsigned int fb_id;
+	cairo_t *cr;
+	int ret;
+
+	fb_id = kmstest_create_fb(data->drm_fd,
+				  mode->hdisplay, mode->vdisplay,
+				  32 /* bpp */, 24 /* depth */,
+				  false /* tiling */,
+				  &connector->fb);
+	igt_assert(fb_id);
+
+	cr = kmstest_get_cairo_ctx(data->drm_fd, &connector->fb);
+	kmstest_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
+			    0.0, 1.0, 0.0);
+	igt_assert(cairo_status(cr) == 0);
+
+#if 0
+	fprintf(stdout, "Using pipe %c, %dx%d\n", pipe_name(config->pipe),
+		mode->hdisplay, mode->vdisplay);
+#endif
+
+	ret = drmModeSetCrtc(data->drm_fd,
+			     config->crtc->crtc_id,
+			     connector->fb.fb_id,
+			     0, 0, /* x, y */
+			     &config->connector->connector_id,
+			     1,
+			     mode);
+	igt_assert(ret == 0);
+
+	return 0;
+}
+
+static void display_init(data_t *data)
+{
+	int i;
+
+	data->resources = drmModeGetResources(data->drm_fd);
+	igt_assert(data->resources);
+
+	data->n_connectors = data->resources->count_connectors;
+	data->connectors = calloc(data->n_connectors, sizeof(connector_t));
+	igt_assert(data->connectors);
+
+	for (i = 0; i < data->n_connectors; i++) {
+		uint32_t id = data->resources->connectors[i];
+
+		connector_init(data, &data->connectors[i], id);
+	}
+}
+
+static void display_fini(data_t *data)
+{
+	int i;
+
+	for (i = 0; i < data->n_connectors; i++)
+		connector_fini(&data->connectors[i]);
+	free(data->connectors);
+
+	drmModeFreeResources(data->resources);
+}
+
+static connector_t *
+display_find_first_valid_connector(data_t *data)
+{
+	int i;
+
+	for (i = 0;  i < data->n_connectors; i++) {
+		connector_t *connector = &data->connectors[i];
+
+		if (connector->valid)
+			return connector;
+	}
+
+	return NULL;
+}
+
+static void test_read_crc(data_t *data)
+{
+	connector_t *connector;
+	igt_pipe_crc_t *pipe_crc;
+	igt_crc_t *crcs = NULL;
+
+	connector = display_find_first_valid_connector(data);
+	if (!connector)
+		igt_skip("Could not find a valid connector \n");
+
+	pipe_crc = igt_pipe_crc_new(&data->debugfs, data->drm_fd,
+				    connector->config.pipe,
+				    INTEL_PIPE_CRC_SOURCE_PLANE1);
+
+	connector_set_mode(data, connector, &connector->config.default_mode);
+
+	igt_pipe_crc_start(pipe_crc);
+
+	/* wait for 3 vblanks and the corresponding 3 CRCs */
+	igt_pipe_crc_get_crcs(pipe_crc, 3, &crcs);
+
+	igt_pipe_crc_stop(pipe_crc);
+
+	/* and ensure that they'are all equal, we haven't changed the fb */
+	igt_assert(igt_crc_equal(&crcs[0], &crcs[1]));
+	igt_assert(igt_crc_equal(&crcs[1], &crcs[2]));
+
+	free(crcs);
+	igt_pipe_crc_free(pipe_crc);
+}
+
+static void exit_handler(int sig)
+{
+	igt_pipe_crc_reset();
+}
+
+int main(int argc, char **argv)
+{
+	data_t data = {0, };
+
+	igt_subtest_init(argc, argv);
+
+	igt_fixture {
+		data.drm_fd = drm_open_any();
+		do_or_die(igt_set_vt_graphics_mode());
+		do_or_die(igt_install_exit_handler(exit_handler));
+
+		display_init(&data);
+
+		igt_debugfs_init(&data.debugfs);
+		data.ctl = igt_debugfs_fopen(&data.debugfs,
+					     "i915_display_crc_ctl", "r+");
+		if (!data.ctl)
+			igt_skip("No display_crc_ctl found, kernel too old\n");
+	}
+
+	igt_subtest("bad-pipe")
+		test_bad_command(&data, "pipe D none");
+
+	igt_subtest("bad-source")
+		test_bad_command(&data, "pipe A foo");
+
+	igt_subtest("bad-nb-words-1")
+		test_bad_command(&data, "pipe foo");
+
+	igt_subtest("bad-nb-words-3")
+		test_bad_command(&data, "pipe A none option");
+
+	igt_subtest("read-crc")
+		test_read_crc(&data);
+
+	igt_fixture {
+		igt_pipe_crc_reset();
+		display_fini(&data);
+		fclose(data.ctl);
+	}
+
+	return 0;
+}
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/8] lib: Add a small helper to open debugfs files
  2013-10-15 18:44 ` [PATCH 1/8] lib: Add a small helper to open debugfs files Damien Lespiau
@ 2013-10-16 15:28   ` Ben Widawsky
  0 siblings, 0 replies; 10+ messages in thread
From: Ben Widawsky @ 2013-10-16 15:28 UTC (permalink / raw)
  To: Damien Lespiau; +Cc: intel-gfx

On Tue, Oct 15, 2013 at 07:44:27PM +0100, Damien Lespiau wrote:
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  lib/Makefile.am   |  2 ++
>  lib/igt_debugfs.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/igt_debugfs.h | 36 ++++++++++++++++++++++++++
>  3 files changed, 113 insertions(+)
>  create mode 100644 lib/igt_debugfs.c
>  create mode 100644 lib/igt_debugfs.h
> 
> diff --git a/lib/Makefile.am b/lib/Makefile.am
> index 387141b..5710802 100644
> --- a/lib/Makefile.am
> +++ b/lib/Makefile.am
> @@ -11,6 +11,8 @@ libintel_tools_la_SOURCES = 	\
>  	i830_reg.h		\
>  	i915_3d.h		\
>  	i915_reg.h		\
> +	igt_debugfs.c		\
> +	igt_debugfs.h		\
>  	instdone.c		\
>  	instdone.h		\
>  	intel_batchbuffer.c	\
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> new file mode 100644
> index 0000000..33c4fc1
> --- /dev/null
> +++ b/lib/igt_debugfs.c
> @@ -0,0 +1,75 @@
> +/*
> + * Copyright © 2013 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#include <sys/stat.h>
> +#include <sys/mount.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <fcntl.h>
> +
> +#include "igt_debugfs.h"
> +
> +int igt_debugfs_init(igt_debugfs_t *debugfs)
> +{
> +	const char *path = "/sys/kernel/debug";
> +	struct stat st;
> +	int n;
> +
> +	if (stat("/debug/dri", &st) == 0) {
> +		path = "/debug/dri";
> +		goto find_minor;
> +	}
> +
> +	if (stat("/sys/kernel/debug/dri", &st) == 0)
> +		goto find_minor;
> +
> +	if (stat("/sys/kernel/debug", &st))
> +		return errno;
> +
> +	if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0))
> +		return errno;
> +
> +find_minor:
> +	strcpy(debugfs->root, path);
> +	for (n = 0; n < 16; n++) {
> +		int len = sprintf(debugfs->dri_path, "%s/dri/%d", path, n);
> +		sprintf(debugfs->dri_path + len, "/i915_error_state");
> +		if (stat(debugfs->dri_path, &st) == 0) {
> +			debugfs->dri_path[len] = '\0';
> +			return 0;
> +		}
> +	}
> +
> +	debugfs->dri_path[0] = '\0';
> +	return ENOENT;
> +}
> +
> +int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename)
> +{
> +	char buf[1024];
> +
> +	sprintf(buf, "%s/%s", debugfs->dri_path, filename);
> +	return open(buf, O_RDONLY);
> +}
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> new file mode 100644
> index 0000000..aa9449a
> --- /dev/null
> +++ b/lib/igt_debugfs.h
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright © 2013 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#ifndef __IGT_DEBUGFS_H__
> +#define __IGT_DEBUGFS_H__
> +
> +typedef struct {
> +	char root[128];
> +	char dri_path[128];
> +} igt_debugfs_t;
> +
> +int igt_debugfs_init(igt_debugfs_t *debugfs);
> +int igt_debugfs_open(igt_debugfs_t *debugfs, const char *filename);
> +
> +#endif /* __IGT_DEBUGFS_H__ */

Can you please consolidate this with the stuff in lib/intel_mmio.c?

(I didn't look at the later patches yet).

-- 
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-10-16 15:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15 18:44 pipe CRCs, intel-gpu-tools Damien Lespiau
2013-10-15 18:44 ` [PATCH 1/8] lib: Add a small helper to open debugfs files Damien Lespiau
2013-10-16 15:28   ` Ben Widawsky
2013-10-15 18:44 ` [PATCH 2/8] lib: Add igt_debugfs_fopen() Damien Lespiau
2013-10-15 18:44 ` [PATCH 3/8] lib: Add a igt_assert_cmpint() Damien Lespiau
2013-10-15 18:44 ` [PATCH 4/8] lib: Add kmstest_paint_color() Damien Lespiau
2013-10-15 18:44 ` [PATCH 5/8] lib: Add a igt_display.h with a few enums and defines from the kernel Damien Lespiau
2013-10-15 18:44 ` [PATCH 6/8] lib: Make igt_debugfs_open() take the mode as argument Damien Lespiau
2013-10-15 18:44 ` [PATCH 7/8] lib: Add igt_wait_for_vblank() helper Damien Lespiau
2013-10-15 18:44 ` [PATCH 8/8] debugfs_pipe_crc: Let's check CRCs! Damien Lespiau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox