Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring
@ 2015-02-10 18:05 Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 02/17] lib/ioctl: api polish for gem_context_has_param Daniel Vetter
                   ` (16 more replies)
  0 siblings, 17 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter

Align with common igt library style:
- Push the igt_require into the function.
- Push the intel_gen into the function.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 lib/igt_gt.c                 | 12 ++++--------
 lib/igt_gt.h                 |  2 +-
 tests/gem_concurrent_blit.c  |  2 +-
 tests/gem_pread_after_blit.c |  2 +-
 tests/gem_reloc_vs_gpu.c     |  8 +++-----
 5 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 526cbee03308..c003a7ca30f0 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -29,16 +29,12 @@
 #include "igt_debugfs.h"
 #include "ioctl_wrappers.h"
 #include "intel_reg.h"
+#include "intel_chipset.h"
 
-int igt_can_hang_ring(int fd, int gen, int ring)
+void igt_require_hang_ring(int fd, int ring)
 {
-	if (!gem_context_has_param(fd, LOCAL_CONTEXT_PARAM_BAN_PERIOD))
-		return 0;
-
-	if (gen < 5) /* safe resets */
-		return 0;
-
-	return 1;
+	igt_require(gem_context_has_param(fd, LOCAL_CONTEXT_PARAM_BAN_PERIOD));
+	igt_require(intel_gen(intel_get_drm_devid(fd)) >= 5);
 }
 
 struct igt_hang_ring igt_hang_ring(int fd, int gen, int ring)
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index 19bbcef2a91e..1ed78837cf5b 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -24,7 +24,7 @@
 #ifndef IGT_GT_H
 #define IGT_GT_H
 
-int igt_can_hang_ring(int fd, int gen, int ring);
+void igt_require_hang_ring(int fd, int ring);
 
 struct igt_hang_ring {
 	unsigned handle;
diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index 726198012c14..245ad4581783 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -474,7 +474,7 @@ static struct igt_hang_ring rcs_hang(void)
 
 static void hang_require(void)
 {
-	igt_require(igt_can_hang_ring(fd, gen, -1));
+	igt_require_hang_ring(fd, -1);
 }
 
 static void do_overwrite_source(const struct access_mode *mode,
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index c09c8dc49ee0..6e4bd6257feb 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -239,7 +239,7 @@ igt_main
 		igt_stop_signal_helper();
 
 		igt_subtest_f("%s-hang", t->name) {
-			igt_require(igt_can_hang_ring(fd, batch->gen, -1));
+			igt_require_hang_ring(fd, -1);
 			do_test(fd, t->cache, src, start, dst, 1, bcs_hang);
 		}
 	}
diff --git a/tests/gem_reloc_vs_gpu.c b/tests/gem_reloc_vs_gpu.c
index bb8615b6a593..68bd17d3ae5b 100644
--- a/tests/gem_reloc_vs_gpu.c
+++ b/tests/gem_reloc_vs_gpu.c
@@ -263,9 +263,7 @@ static void do_forked_test(int fd, unsigned flags)
 	struct igt_helper_process thrasher = {};
 
 	if (flags & HANG)
-		igt_require(igt_can_hang_ring(fd,
-					      intel_gen(devid),
-					      I915_EXEC_BLT));
+		igt_require_hang_ring(fd, I915_EXEC_BLT);
 
 	if (flags & (THRASH | THRASH_INACTIVE)) {
 		uint64_t val = (flags & THRASH_INACTIVE) ?
@@ -328,7 +326,7 @@ igt_main
 		do_test(fd, false, no_hang);
 
 	igt_subtest("interruptible-hang") {
-		igt_require(igt_can_hang_ring(fd, intel_gen(devid), I915_EXEC_BLT));
+		igt_require_hang_ring(fd, I915_EXEC_BLT);
 		do_test(fd, false, bcs_hang);
 	}
 
@@ -336,7 +334,7 @@ igt_main
 		do_test(fd, true, no_hang);
 
 	igt_subtest("faulting-reloc-interruptible-hang") {
-		igt_require(igt_can_hang_ring(fd, intel_gen(devid), I915_EXEC_BLT));
+		igt_require_hang_ring(fd, I915_EXEC_BLT);
 		do_test(fd, true, bcs_hang);
 	}
 	igt_stop_signal_helper();
-- 
2.1.4

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

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

* [PATCH i-g-t 02/17] lib/ioctl: api polish for gem_context_has_param
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc Daniel Vetter
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter

Just push the igt_require down to align with the usual style.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 lib/igt_gt.c         | 2 +-
 lib/ioctl_wrappers.c | 4 ++--
 lib/ioctl_wrappers.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index c003a7ca30f0..615f9893b876 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -33,7 +33,7 @@
 
 void igt_require_hang_ring(int fd, int ring)
 {
-	igt_require(gem_context_has_param(fd, LOCAL_CONTEXT_PARAM_BAN_PERIOD));
+	gem_context_require_param(fd, LOCAL_CONTEXT_PARAM_BAN_PERIOD);
 	igt_require(intel_gen(intel_get_drm_devid(fd)) >= 5);
 }
 
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 19a457ac2b34..dd89e2c57e7f 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1080,7 +1080,7 @@ int gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
 	return 0;
 }
 
-int gem_context_has_param(int fd, uint64_t param)
+void gem_context_require_param(int fd, uint64_t param)
 {
 	struct local_i915_gem_context_param p;
 
@@ -1089,5 +1089,5 @@ int gem_context_has_param(int fd, uint64_t param)
 	p.value = 0;
 	p.size = 0;
 
-	return gem_context_get_param(fd, &p) == 0;
+	igt_require(gem_context_get_param(fd, &p) == 0);
 }
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 30ab83628a04..a1017ecd3767 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -113,7 +113,7 @@ struct local_i915_gem_context_param {
 	uint64_t value;
 };
 
-int gem_context_has_param(int fd, uint64_t param);
+void gem_context_require_param(int fd, uint64_t param);
 int gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
 int gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
 
-- 
2.1.4

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

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

* [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 02/17] lib/ioctl: api polish for gem_context_has_param Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 21:58   ` Chris Wilson
  2015-02-10 18:05 ` [PATCH i-g-t 04/17] igt/ioctls: doc for gem_mmap Daniel Vetter
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

We stick to the overall prefix even for magic require functions.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/ioctl_wrappers.h        | 11 ++++++++++-
 tests/gem_concurrent_blit.c |  4 ++--
 tests/gem_fence_upload.c    |  2 +-
 tests/gem_mmap_wc.c         | 16 ++++++++--------
 tests/gem_tiled_wc.c        |  2 +-
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index a1017ecd3767..8d8fa46d1942 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -65,7 +65,16 @@ void *gem_mmap__cpu(int fd, uint32_t handle, int offset, int size, int prot);
 
 bool gem_mmap__has_wc(int fd);
 void *gem_mmap__wc(int fd, uint32_t handle, int offset, int size, int prot);
-#define igt_require_mmap_wc(x) igt_require(gem_mmap__has_wc(x))
+
+/**
+ * gem_require_mmap_wc:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query whether direct (i.e. cpu access path, bypassing
+ * the gtt) write-combine memory mappings are available. Automatically skips
+ * through igt_require() if not.
+ */
+#define gem_require_mmap_wc(x) igt_require(gem_mmap__has_wc(x))
 
 /**
  * gem_mmap:
diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index 245ad4581783..cec6ea49f95c 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -174,7 +174,7 @@ wc_create_bo(drm_intel_bufmgr *bufmgr, int width, int height)
 {
 	drm_intel_bo *bo;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	bo = unmapped_create_bo(bufmgr, width, height);
 	bo->virtual = gem_mmap__wc(fd, bo->handle, 0, bo->size, PROT_READ | PROT_WRITE);
@@ -696,7 +696,7 @@ static void gtt_require(void)
 static void wc_require(void)
 {
 	bit17_require();
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 }
 
 static void bcs_require(void)
diff --git a/tests/gem_fence_upload.c b/tests/gem_fence_upload.c
index 81f797b4ba86..9595bc822e59 100644
--- a/tests/gem_fence_upload.c
+++ b/tests/gem_fence_upload.c
@@ -345,7 +345,7 @@ static void wc_contention(void)
 	double linear[2], tiled[2];
 
 	fd = drm_open_any();
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	num_fences = gem_available_fences(fd);
 	igt_require(num_fences > 0);
diff --git a/tests/gem_mmap_wc.c b/tests/gem_mmap_wc.c
index 87916b6e81c0..73a97d556927 100644
--- a/tests/gem_mmap_wc.c
+++ b/tests/gem_mmap_wc.c
@@ -130,7 +130,7 @@ test_copy(int fd)
 {
 	void *src, *dst;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	/* copy from a fresh src to fresh dst to force pagefault on both */
 	src = create_pointer(fd);
@@ -180,7 +180,7 @@ test_read_write2(int fd, enum test_read_write order)
 	void *r, *w;
 	volatile uint32_t val = 0;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	handle = gem_create(fd, OBJECT_SIZE);
 	set_domain(fd, handle);
@@ -210,7 +210,7 @@ test_write(int fd)
 	void *src;
 	uint32_t dst;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	/* copy from a fresh src to fresh dst to force pagefault on both */
 	src = create_pointer(fd);
@@ -229,7 +229,7 @@ test_write_gtt(int fd)
 	char *dst_gtt;
 	void *src;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	dst = gem_create(fd, OBJECT_SIZE);
 	set_domain(fd, dst);
@@ -253,7 +253,7 @@ test_read(int fd)
 	void *dst;
 	uint32_t src;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	/* copy from a fresh src to fresh dst to force pagefault on both */
 	dst = create_pointer(fd);
@@ -271,7 +271,7 @@ test_write_cpu_read_wc(int fd)
 	uint32_t handle;
 	uint32_t *src, *dst;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	handle = gem_create(fd, OBJECT_SIZE);
 
@@ -296,7 +296,7 @@ test_write_gtt_read_wc(int fd)
 	uint32_t handle;
 	uint32_t *src, *dst;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	handle = gem_create(fd, OBJECT_SIZE);
 	set_domain(fd, handle);
@@ -390,7 +390,7 @@ test_fault_concurrent(int fd)
 	struct thread_fault_concurrent thread[64];
 	int n;
 
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	for (n = 0; n < 32; n++) {
 		ptr[n] = create_pointer(fd);
diff --git a/tests/gem_tiled_wc.c b/tests/gem_tiled_wc.c
index f705378173d7..b0f7a655a17a 100644
--- a/tests/gem_tiled_wc.c
+++ b/tests/gem_tiled_wc.c
@@ -136,7 +136,7 @@ igt_simple_main
 	uint32_t handle;
 
 	fd = drm_open_any();
-	igt_require_mmap_wc(fd);
+	gem_require_mmap_wc(fd);
 
 	handle = create_bo(fd);
 	get_tiling(fd, handle, &tiling, &swizzle);
-- 
2.1.4

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

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

* [PATCH i-g-t 04/17] igt/ioctls: doc for gem_mmap
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 02/17] lib/ioctl: api polish for gem_context_has_param Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible Daniel Vetter
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Just spotted while driving around. gtkdoc needs the full parameter
list otherwise it doesn't recognize it as a function. So add them.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/ioctl_wrappers.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 8d8fa46d1942..663b3da2ecd4 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -78,10 +78,19 @@ void *gem_mmap__wc(int fd, uint32_t handle, int offset, int size, int prot);
 
 /**
  * gem_mmap:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @size: size of the gem buffer
+ * @prot: memory protection bits as used by mmap()
+ *
+ * This functions wraps up procedure to establish a memory mapping through the
+ * GTT.
  *
  * This is a simple convenience alias to gem_mmap__gtt()
+ *
+ * Returns: A pointer to the created memory mapping.
  */
-#define gem_mmap gem_mmap__gtt
+#define gem_mmap(fd, handle, size, prot) gem_mmap__gtt(fd, handle, size, prot)
 
 int gem_madvise(int fd, uint32_t handle, int state);
 
-- 
2.1.4

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

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

* [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (2 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 04/17] igt/ioctls: doc for gem_mmap Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 21:54   ` Chris Wilson
  2015-02-10 18:05 ` [PATCH i-g-t 06/17] lib/ioctl: Add gem_context_destroy helpers Daniel Vetter
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter

We have separate require checks already, so these failing is a bug in
the test logic.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 lib/igt_gt.c         |  2 +-
 lib/ioctl_wrappers.c | 18 +++++-------------
 lib/ioctl_wrappers.h |  4 ++--
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 615f9893b876..e02219acc6fd 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -55,7 +55,7 @@ struct igt_hang_ring igt_hang_ring(int fd, int gen, int ring)
 	ban = param.value;
 
 	param.value = 0;
-	igt_require(gem_context_set_param(fd, &param) == 0);
+	gem_context_set_param(fd, &param);
 
 	memset(&reloc, 0, sizeof(reloc));
 	memset(&exec, 0, sizeof(exec));
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index dd89e2c57e7f..c8c0e1c16f8b 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1058,26 +1058,18 @@ off_t prime_get_size(int dma_buf_fd)
 	return ret;
 }
 
-int gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
+void gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
 {
 #define LOCAL_I915_GEM_CONTEXT_GETPARAM       0x34
 #define LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_GETPARAM, struct local_i915_gem_context_param)
-	if (drmIoctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, p))
-		return -1;
-
-	errno = 0;
-	return 0;
+	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, p);
 }
 
-int gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
+void gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
 {
 #define LOCAL_I915_GEM_CONTEXT_SETPARAM       0x35
 #define LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_SETPARAM, struct local_i915_gem_context_param)
-	if (drmIoctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, p))
-		return -1;
-
-	errno = 0;
-	return 0;
+	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, p);
 }
 
 void gem_context_require_param(int fd, uint64_t param)
@@ -1089,5 +1081,5 @@ void gem_context_require_param(int fd, uint64_t param)
 	p.value = 0;
 	p.size = 0;
 
-	igt_require(gem_context_get_param(fd, &p) == 0);
+	igt_require(drmIoctl(fd, LOCAL_I915_GEM_CONTEXT_GETPARAM, &p) == 0);
 }
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 663b3da2ecd4..23b8c9d56e44 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -132,7 +132,7 @@ struct local_i915_gem_context_param {
 };
 
 void gem_context_require_param(int fd, uint64_t param);
-int gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
-int gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
+void gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
+void gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
 
 #endif /* IOCTL_WRAPPERS_H */
-- 
2.1.4

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

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

* [PATCH i-g-t 06/17] lib/ioctl: Add gem_context_destroy helpers
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (3 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 07/17] tests/gem_ctx_*: Use helpers Daniel Vetter
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

We also need a raw version for some tests.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/ioctl_wrappers.c | 32 ++++++++++++++++++++++++++++++++
 lib/ioctl_wrappers.h |  2 ++
 2 files changed, 34 insertions(+)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index c8c0e1c16f8b..e86b3c2bfa46 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -630,6 +630,38 @@ uint32_t gem_context_create(int fd)
 	return create.ctx_id;
 }
 
+int __gem_context_destroy(int fd, uint32_t ctx_id)
+{
+	struct drm_i915_gem_context_destroy destroy;
+	int ret;
+
+	memset(&destroy, 0, sizeof(destroy));
+	destroy.ctx_id = ctx_id;
+
+	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
+	if (ret)
+		return -errno;
+	return 0;
+}
+
+/**
+ * gem_context_create:
+ * @fd: open i915 drm file descriptor
+ * @ctx_id: i915 hw context id
+ *
+ * This is a wraps the CONTEXT_DESTROY ioctl, which is used to free a hardware
+ * context.
+ */
+void gem_context_destroy(int fd, uint32_t ctx_id)
+{
+	struct drm_i915_gem_context_destroy destroy;
+
+	memset(&destroy, 0, sizeof(destroy));
+	destroy.ctx_id = ctx_id;
+
+	do_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
+}
+
 /**
  * gem_sw_finish:
  * @fd: open i915 drm file descriptor
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 23b8c9d56e44..ad10bd03d370 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -95,6 +95,8 @@ void *gem_mmap__wc(int fd, uint32_t handle, int offset, int size, int prot);
 int gem_madvise(int fd, uint32_t handle, int state);
 
 uint32_t gem_context_create(int fd);
+void gem_context_destroy(int fd, uint32_t ctx_id);
+int __gem_context_destroy(int fd, uint32_t ctx_id);
 
 void gem_sw_finish(int fd, uint32_t handle);
 
-- 
2.1.4

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

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

* [PATCH i-g-t 07/17] tests/gem_ctx_*: Use helpers
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (4 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 06/17] lib/ioctl: Add gem_context_destroy helpers Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 08/17] tests/gem_reset_stat: Use new ctx helpers Daniel Vetter
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/gem_ctx_bad_destroy.c | 25 +++++--------------------
 tests/gem_ctx_create.c      | 11 ++---------
 tests/gem_ctx_exec.c        | 23 ++++-------------------
 3 files changed, 11 insertions(+), 48 deletions(-)

diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c
index d848265c7802..368bf95f2fcb 100644
--- a/tests/gem_ctx_bad_destroy.c
+++ b/tests/gem_ctx_bad_destroy.c
@@ -38,18 +38,10 @@
 
 IGT_TEST_DESCRIPTION("Negative test cases for destroy contexts.");
 
-struct local_drm_i915_context_destroy {
-	__u32 ctx_id;
-	__u32 pad;
-};
-
-#define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_context_destroy)
-
 igt_simple_main
 {
-	struct local_drm_i915_context_destroy destroy;
 	uint32_t ctx_id;
-	int ret, fd;
+	int fd;
 
 	igt_skip_on_simulation();
 
@@ -57,24 +49,17 @@ igt_simple_main
 
 	ctx_id = gem_context_create(fd);
 
-	destroy.ctx_id = ctx_id;
 	/* Make sure a proper destroy works first */
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	igt_assert(ret == 0);
+	gem_context_destroy(fd, ctx_id);
 
 	/* try double destroy */
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	igt_assert(ret != 0 && errno == ENOENT);
+	igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
 
 	/* destroy something random */
-	destroy.ctx_id = 2;
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	igt_assert(ret != 0 && errno == ENOENT);
+	igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
 
 	/* Try to destroy the default context */
-	destroy.ctx_id = 0;
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	igt_assert(ret != 0 && errno == ENOENT);
+	igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
 
 	close(fd);
 }
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index 522e7b1ca022..1c710fdebbf7 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -32,17 +32,10 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 
-struct local_drm_i915_gem_context_create {
-	__u32 ctx_id;
-	__u32 pad;
-};
-
-#define CONTEXT_CREATE_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2d, struct local_drm_i915_gem_context_create)
-
 igt_simple_main
 {
 	int ret, fd;
-	struct local_drm_i915_gem_context_create create;
+	struct drm_i915_gem_context_create create;
 
 	igt_skip_on_simulation();
 
@@ -51,7 +44,7 @@ igt_simple_main
 
 	fd = drm_open_any_render();
 
-	ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
+	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
 	igt_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
 	igt_assert(ret == 0);
 	igt_assert(create.ctx_id != 0);
diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c
index 7a6ed9b1f1d2..ca5bf640adaf 100644
--- a/tests/gem_ctx_exec.c
+++ b/tests/gem_ctx_exec.c
@@ -50,21 +50,6 @@
 
 IGT_TEST_DESCRIPTION("Test basic context switch functionality.");
 
-struct local_drm_i915_gem_context_destroy {
-	__u32 ctx_id;
-	__u32 pad;
-};
-
-#define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_gem_context_destroy)
-
-static void context_destroy(int fd, uint32_t ctx_id)
-{
-	struct local_drm_i915_gem_context_destroy destroy;
-	destroy.ctx_id = ctx_id;
-	do_ioctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-#include "igt_aux.h"
-}
-
 /* Copied from gem_exec_nop.c */
 static int exec(int fd, uint32_t handle, int ring, int ctx_id)
 {
@@ -183,7 +168,7 @@ igt_main
 
 		/* check that we can create contexts. */
 		ctx_id = gem_context_create(fd);
-		context_destroy(fd, ctx_id);
+		gem_context_destroy(fd, ctx_id);
 		gem_write(fd, handle, 0, batch, sizeof(batch));
 	}
 
@@ -191,12 +176,12 @@ igt_main
 		ctx_id = gem_context_create(fd);
 		igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
 		gem_sync(fd, handle);
-		context_destroy(fd, ctx_id);
+		gem_context_destroy(fd, ctx_id);
 
 		ctx_id = gem_context_create(fd);
 		igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
 		gem_sync(fd, handle);
-		context_destroy(fd, ctx_id);
+		gem_context_destroy(fd, ctx_id);
 
 		igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) < 0);
 		gem_sync(fd, handle);
@@ -227,6 +212,6 @@ igt_main
 			gem_sync(fd, handle);
 		}
 
-		context_destroy(fd, ctx_id);
+		gem_context_destroy(fd, ctx_id);
 	}
 }
-- 
2.1.4

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

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

* [PATCH i-g-t 08/17] tests/gem_reset_stat: Use new ctx helpers
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (5 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 07/17] tests/gem_ctx_*: Use helpers Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 09/17] lib/ioctl: Document ctx param functions Daniel Vetter
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

A bit more invasive since getting rid off all the places meant
to flatten some of the control flow with implicit igt_require.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/gem_reset_stats.c | 117 +++++++++++-------------------------------------
 1 file changed, 27 insertions(+), 90 deletions(-)

diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 646d6dac052e..faa209c1d28a 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -53,7 +53,6 @@
 #define RS_UNKNOWN       (1 << 2)
 
 static uint32_t devid;
-static bool hw_contexts;
 
 struct local_drm_i915_reset_stats {
 	__u32 ctx_id;
@@ -64,20 +63,8 @@ struct local_drm_i915_reset_stats {
 	__u32 pad;
 };
 
-struct local_drm_i915_gem_context_create {
-	__u32 ctx_id;
-	__u32 pad;
-};
-
-struct local_drm_i915_gem_context_destroy {
-	__u32 ctx_id;
-	__u32 pad;
-};
-
 #define MAX_FD 32
 
-#define CONTEXT_CREATE_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2d, struct local_drm_i915_gem_context_create)
-#define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_gem_context_destroy)
 #define GET_RESET_STATS_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x32, struct local_drm_i915_reset_stats)
 
 #define LOCAL_I915_EXEC_VEBOX	(4 << 0)
@@ -89,64 +76,32 @@ static bool gem_has_render(int fd)
 	return true;
 }
 
-static bool has_context(const struct target_ring *ring);
-
 static const struct target_ring {
 	uint32_t exec;
 	bool (*present)(int fd);
-	bool (*contexts)(const struct target_ring *ring);
 	const char *name;
 } rings[] = {
-	{ I915_EXEC_RENDER, gem_has_render, has_context, "render" },
-	{ I915_EXEC_BLT, gem_has_blt, has_context, "blt" },
-	{ I915_EXEC_BSD, gem_has_bsd, has_context, "bsd" },
-	{ LOCAL_I915_EXEC_VEBOX, gem_has_vebox, has_context, "vebox" },
+	{ I915_EXEC_RENDER, gem_has_render, "render" },
+	{ I915_EXEC_BLT, gem_has_blt, "blt" },
+	{ I915_EXEC_BSD, gem_has_bsd, "bsd" },
+	{ LOCAL_I915_EXEC_VEBOX, gem_has_vebox, "vebox" },
 };
 
-static bool has_context(const struct target_ring *ring)
+static void check_context(const struct target_ring *ring)
 {
-	if (!hw_contexts)
-		return false;
+	int fd = drm_open_any();
 
-	if(ring->exec == I915_EXEC_RENDER)
-		return true;
+	gem_context_destroy(fd,
+			    gem_context_create(fd));
+	close(fd);
 
-	return false;
+	igt_require(ring->exec == I915_EXEC_RENDER);
 }
 
 #define NUM_RINGS (sizeof(rings)/sizeof(struct target_ring))
 
 static const struct target_ring *current_ring;
 
-static uint32_t context_create(int fd)
-{
-	struct local_drm_i915_gem_context_create create;
-	int ret;
-
-	create.ctx_id = rand();
-	create.pad = rand();
-
-	ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
-	igt_assert(ret == 0);
-
-	return create.ctx_id;
-}
-
-static int context_destroy(int fd, uint32_t ctx_id)
-{
-	int ret;
-	struct local_drm_i915_gem_context_destroy destroy;
-
-	destroy.ctx_id = ctx_id;
-	destroy.pad = rand();
-
-	ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
-	if (ret != 0)
-		return -errno;
-
-	return 0;
-}
-
 static int gem_reset_stats(int fd, int ctx_id,
 			   struct local_drm_i915_reset_stats *rs)
 {
@@ -450,7 +405,7 @@ static void test_rs_ctx(int num_fds, int num_ctx, int hang_index,
 		assert_reset_status(fd[i], 0, RS_NO_ERROR);
 
 		for (j = 0; j < num_ctx; j++) {
-			ctx[i][j] = context_create(fd[i]);
+			ctx[i][j] = gem_context_create(fd[i]);
 
 		}
 
@@ -502,7 +457,7 @@ static void test_rs_ctx(int num_fds, int num_ctx, int hang_index,
 	for (i = 0; i < num_fds; i++) {
 		for (j = 0; j < num_ctx; j++) {
 			gem_close(fd[i], h[i][j]);
-			igt_assert(context_destroy(fd[i], ctx[i][j]) == 0);
+			gem_context_destroy(fd[i], ctx[i][j]);
 		}
 
 		assert_reset_status(fd[i], 0, RS_NO_ERROR);
@@ -610,8 +565,8 @@ static void test_ban_ctx(void)
 
 	assert_reset_status(fd, 0, RS_NO_ERROR);
 
-	ctx_good = context_create(fd);
-	ctx_bad = context_create(fd);
+	ctx_good = gem_context_create(fd);
+	ctx_bad = gem_context_create(fd);
 
 	assert_reset_status(fd, 0, RS_NO_ERROR);
 	assert_reset_status(fd, ctx_good, RS_NO_ERROR);
@@ -681,8 +636,8 @@ static void test_ban_ctx(void)
 	igt_assert(h1 >= 0);
 	gem_close(fd, h1);
 
-	igt_assert(context_destroy(fd, ctx_good) == 0);
-	igt_assert(context_destroy(fd, ctx_bad) == 0);
+	gem_context_destroy(fd, ctx_good);
+	gem_context_destroy(fd, ctx_bad);
 	igt_assert(gem_reset_status(fd, ctx_good) < 0);
 	igt_assert(gem_reset_status(fd, ctx_bad) < 0);
 	igt_assert(exec_valid(fd, ctx_good) < 0);
@@ -701,8 +656,8 @@ static void test_unrelated_ctx(void)
 	fd2 = drm_open_any();
 	assert_reset_status(fd1, 0, RS_NO_ERROR);
 	assert_reset_status(fd2, 0, RS_NO_ERROR);
-	ctx_guilty = context_create(fd1);
-	ctx_unrelated = context_create(fd2);
+	ctx_guilty = gem_context_create(fd1);
+	ctx_unrelated = gem_context_create(fd2);
 
 	assert_reset_status(fd1, ctx_guilty, RS_NO_ERROR);
 	assert_reset_status(fd2, ctx_unrelated, RS_NO_ERROR);
@@ -721,8 +676,8 @@ static void test_unrelated_ctx(void)
 	gem_close(fd1, h1);
 	gem_close(fd2, h2);
 
-	igt_assert(context_destroy(fd1, ctx_guilty) == 0);
-	igt_assert(context_destroy(fd2, ctx_unrelated) == 0);
+	gem_context_destroy(fd1, ctx_guilty);
+	gem_context_destroy(fd2, ctx_unrelated);
 
 	close(fd1);
 	close(fd2);
@@ -746,14 +701,14 @@ static void test_close_pending_ctx(void)
 	uint32_t ctx;
 
 	fd = drm_open_any();
-	ctx = context_create(fd);
+	ctx = gem_context_create(fd);
 
 	assert_reset_status(fd, ctx, RS_NO_ERROR);
 
 	h = inject_hang(fd, ctx);
 	igt_assert(h >= 0);
-	igt_assert(context_destroy(fd, ctx) == 0);
-	igt_assert(context_destroy(fd, ctx) == -ENOENT);
+	gem_context_destroy(fd, ctx);
+	igt_assert(__gem_context_destroy(fd, ctx) == -ENOENT);
 
 	gem_close(fd, h);
 	close(fd);
@@ -881,7 +836,7 @@ static void test_reset_count(const bool create_ctx)
 
 	fd = drm_open_any();
 	if (create_ctx)
-		ctx = context_create(fd);
+		ctx = gem_context_create(fd);
 	else
 		ctx = 0;
 
@@ -915,7 +870,7 @@ static void test_reset_count(const bool create_ctx)
 	gem_close(fd, h);
 
 	if (create_ctx)
-		context_destroy(fd, ctx);
+		gem_context_destroy(fd, ctx);
 
 	close(fd);
 }
@@ -990,7 +945,7 @@ static void test_params_ctx(void)
 	int fd, ctx;
 
 	fd = drm_open_any();
-	ctx = context_create(fd);
+	ctx = gem_context_create(fd);
 
 	_test_param(fd, ctx);
 
@@ -1047,22 +1002,6 @@ static void defer_hangcheck(int ring_num)
 	close(fd);
 }
 
-static bool gem_has_hw_contexts(int fd)
-{
-	struct local_drm_i915_gem_context_create create;
-	int ret;
-
-	memset(&create, 0, sizeof(create));
-	ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
-
-	if (ret == 0) {
-		drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &create);
-		return true;
-	}
-
-	return false;
-}
-
 static bool gem_has_reset_stats(int fd)
 {
 	struct local_drm_i915_reset_stats rs;
@@ -1109,9 +1048,8 @@ static void check_gpu_ok(void)
 	close(fd);
 }
 
-#define RING_HAS_CONTEXTS (current_ring->contexts(current_ring))
 #define RUN_TEST(...) do { check_gpu_ok(); __VA_ARGS__; check_gpu_ok(); } while (0)
-#define RUN_CTX_TEST(...) do { igt_skip_on(RING_HAS_CONTEXTS == false); RUN_TEST(__VA_ARGS__); } while (0)
+#define RUN_CTX_TEST(...) do { check_context(current_ring); RUN_TEST(__VA_ARGS__); } while (0)
 
 igt_main
 {
@@ -1124,7 +1062,6 @@ igt_main
 		fd = drm_open_any();
 		devid = intel_get_drm_devid(fd);
 
-		hw_contexts = gem_has_hw_contexts(fd);
 		has_reset_stats = gem_has_reset_stats(fd);
 
 		close(fd);
-- 
2.1.4

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

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

* [PATCH i-g-t 09/17] lib/ioctl: Document ctx param functions
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (6 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 08/17] tests/gem_reset_stat: Use new ctx helpers Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 10/17] tests: Add gem_ctx_param_basic Daniel Vetter
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter

And move them so that they're grouped with the other context wrappers.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 lib/ioctl_wrappers.c | 79 +++++++++++++++++++++++++++++++++++-----------------
 lib/ioctl_wrappers.h | 22 +++++++--------
 2 files changed, 63 insertions(+), 38 deletions(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index e86b3c2bfa46..288ab8d7e0e2 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -663,6 +663,59 @@ void gem_context_destroy(int fd, uint32_t ctx_id)
 }
 
 /**
+ * gem_context_get_param:
+ * @fd: open i915 drm file descriptor
+ * @p: i915 hw context parameter
+ *
+ * This is a wraps the CONTEXT_GET_PARAM ioctl, which is used to free a hardware
+ * context. Not that similarly to gem_set_caching() this wrapper calls
+ * igt_require() internally to correctly skip on kernels and platforms where hw
+ * context parameter support is not available.
+ */
+void gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
+{
+#define LOCAL_I915_GEM_CONTEXT_GETPARAM       0x34
+#define LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_GETPARAM, struct local_i915_gem_context_param)
+	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, p);
+}
+
+/**
+ * gem_context_set_param:
+ * @fd: open i915 drm file descriptor
+ * @p: i915 hw context parameter
+ *
+ * This is a wraps the CONTEXT_SET_PARAM ioctl, which is used to free a hardware
+ * context. Not that similarly to gem_set_caching() this wrapper calls
+ * igt_require() internally to correctly skip on kernels and platforms where hw
+ * context parameter support is not available.
+ */
+void gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
+{
+#define LOCAL_I915_GEM_CONTEXT_SETPARAM       0x35
+#define LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_SETPARAM, struct local_i915_gem_context_param)
+	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, p);
+}
+
+/**
+ * gem_require_caching:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query whether hw context parameter support for @param
+ * is available. Automatically skips through igt_require() if not.
+ */
+void gem_context_require_param(int fd, uint64_t param)
+{
+	struct local_i915_gem_context_param p;
+
+	p.context = 0;
+	p.param = param;
+	p.value = 0;
+	p.size = 0;
+
+	igt_require(drmIoctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0);
+}
+
+/**
  * gem_sw_finish:
  * @fd: open i915 drm file descriptor
  * @handle: gem buffer object handle
@@ -1089,29 +1142,3 @@ off_t prime_get_size(int dma_buf_fd)
 
 	return ret;
 }
-
-void gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
-{
-#define LOCAL_I915_GEM_CONTEXT_GETPARAM       0x34
-#define LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_GETPARAM, struct local_i915_gem_context_param)
-	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, p);
-}
-
-void gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
-{
-#define LOCAL_I915_GEM_CONTEXT_SETPARAM       0x35
-#define LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_SETPARAM, struct local_i915_gem_context_param)
-	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, p);
-}
-
-void gem_context_require_param(int fd, uint64_t param)
-{
-	struct local_i915_gem_context_param p;
-
-	p.context = 0;
-	p.param = param;
-	p.value = 0;
-	p.size = 0;
-
-	igt_require(drmIoctl(fd, LOCAL_I915_GEM_CONTEXT_GETPARAM, &p) == 0);
-}
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index ad10bd03d370..ea9f5598e7e3 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -97,6 +97,16 @@ int gem_madvise(int fd, uint32_t handle, int state);
 uint32_t gem_context_create(int fd);
 void gem_context_destroy(int fd, uint32_t ctx_id);
 int __gem_context_destroy(int fd, uint32_t ctx_id);
+struct local_i915_gem_context_param {
+	uint32_t context;
+	uint32_t size;
+	uint64_t param;
+#define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1
+	uint64_t value;
+};
+void gem_context_require_param(int fd, uint64_t param);
+void gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
+void gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
 
 void gem_sw_finish(int fd, uint32_t handle);
 
@@ -125,16 +135,4 @@ int prime_handle_to_fd(int fd, uint32_t handle);
 uint32_t prime_fd_to_handle(int fd, int dma_buf_fd);
 off_t prime_get_size(int dma_buf_fd);
 
-struct local_i915_gem_context_param {
-	uint32_t context;
-	uint32_t size;
-	uint64_t param;
-#define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1
-	uint64_t value;
-};
-
-void gem_context_require_param(int fd, uint64_t param);
-void gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
-void gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
-
 #endif /* IOCTL_WRAPPERS_H */
-- 
2.1.4

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

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

* [PATCH i-g-t 10/17] tests: Add gem_ctx_param_basic
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (7 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 09/17] lib/ioctl: Document ctx param functions Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 11/17] tests: Add invalid pad tests for ctx create/destroy Daniel Vetter
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter

Boring ioctl validation. Luckily no gaps found while doing it.

v2: git add ftw!

v3: Fixes:

- args->size is an outparam for get, adjust test.
- Pick an invalid param, not an invalid ioctl number ... tsk.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 tests/.gitignore            |   1 +
 tests/Makefile.sources      |   1 +
 tests/gem_ctx_exec.c        |   3 +-
 tests/gem_ctx_param_basic.  | 172 ++++++++++++++++++++++++++++++++++++++++++++
 tests/gem_ctx_param_basic.c | 137 +++++++++++++++++++++++++++++++++++
 5 files changed, 313 insertions(+), 1 deletion(-)
 create mode 100644 tests/gem_ctx_param_basic.
 create mode 100644 tests/gem_ctx_param_basic.c

diff --git a/tests/.gitignore b/tests/.gitignore
index 88a6405394b2..7b4dd94722a2 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -30,6 +30,7 @@ gem_ctx_basic
 gem_ctx_create
 gem_ctx_exec
 gem_ctx_thrash
+gem_ctx_param_basic
 gem_double_irq_loop
 gem_dummy_reloc_loop
 gem_evict_alignment
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 74deec3127fb..51e8376b24e6 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -23,6 +23,7 @@ TESTS_progs_M = \
 	gem_close_race \
 	gem_concurrent_blit \
 	gem_cs_tlb \
+	gem_ctx_param_basic \
 	gem_ctx_bad_exec \
 	gem_ctx_exec \
 	gem_dummy_reloc_loop \
diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c
index ca5bf640adaf..ead3d463003a 100644
--- a/tests/gem_ctx_exec.c
+++ b/tests/gem_ctx_exec.c
@@ -161,7 +161,8 @@ int fd;
 igt_main
 {
 	igt_skip_on_simulation();
-		igt_fixture {
+
+	igt_fixture {
 		fd = drm_open_any_render();
 
 		handle = gem_create(fd, 4096);
diff --git a/tests/gem_ctx_param_basic. b/tests/gem_ctx_param_basic.
new file mode 100644
index 000000000000..2d866b3eee26
--- /dev/null
+++ b/tests/gem_ctx_param_basic.
@@ -0,0 +1,172 @@
+/*
+ * Copyright © 2011 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.
+ *
+ * Authors:
+ *    Ben Widawsky <ben@bwidawsk.net>
+ *
+ */
+
+/*
+ * This test is useful for finding memory and refcount leaks.
+ */
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include "drm.h"
+#include "ioctl_wrappers.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_io.h"
+#include "intel_chipset.h"
+
+IGT_TEST_DESCRIPTION("Basic test for memory and refcount leaks.");
+
+/* options */
+int num_contexts = 10;
+int uncontexted = 0; /* test only context create/destroy */
+int multiple_fds = 1;
+int iter = 10000;
+
+/* globals */
+pthread_t *threads;
+int devid;
+int fd;
+
+static void init_buffer(drm_intel_bufmgr *bufmgr,
+			struct igt_buf *buf,
+			uint32_t size)
+{
+	buf->bo = drm_intel_bo_alloc(bufmgr, "", size, 4096);
+	buf->size = size;
+	igt_assert(buf->bo);
+	buf->tiling = I915_TILING_NONE;
+	buf->stride = 4096;
+}
+
+static void *work(void *arg)
+{
+	struct intel_batchbuffer *batch;
+	igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(devid);
+	drm_intel_context *context;
+	drm_intel_bufmgr *bufmgr;
+	int td_fd;
+	int i;
+
+	if (multiple_fds)
+		td_fd = fd = drm_open_any_render();
+	else
+		td_fd = fd;
+
+	igt_assert(td_fd >= 0);
+
+	bufmgr = drm_intel_bufmgr_gem_init(td_fd, 4096);
+	batch = intel_batchbuffer_alloc(bufmgr, devid);
+	context = drm_intel_gem_context_create(bufmgr);
+	igt_require(context);
+
+	for (i = 0; i < iter; i++) {
+		struct igt_buf src, dst;
+
+		init_buffer(bufmgr, &src, 4096);
+		init_buffer(bufmgr, &dst, 4096);
+
+
+		if (uncontexted) {
+			igt_assert(rendercopy);
+			rendercopy(batch, NULL, &src, 0, 0, 0, 0, &dst, 0, 0);
+		} else {
+			int ret;
+			ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer);
+			igt_assert(ret == 0);
+			intel_batchbuffer_flush_with_context(batch, context);
+		}
+	}
+
+	drm_intel_gem_context_destroy(context);
+	intel_batchbuffer_free(batch);
+	drm_intel_bufmgr_destroy(bufmgr);
+
+	if (multiple_fds)
+		close(td_fd);
+
+	pthread_exit(NULL);
+}
+
+static int opt_handler(int opt, int opt_index)
+{
+	switch (opt) {
+		case 'i':
+			iter = atoi(optarg);
+			break;
+		case 'c':
+			num_contexts = atoi(optarg);
+			break;
+		case 'm':
+			multiple_fds = 1;
+			break;
+		case 'u':
+			uncontexted = 1;
+			break;
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	int i;
+
+	igt_simple_init_parse_opts(argc, argv, "i:c:n:mu", NULL, NULL,
+				   opt_handler);
+
+	fd = drm_open_any_render();
+	devid = intel_get_drm_devid(fd);
+
+	if (igt_run_in_simulation()) {
+		num_contexts = 2;
+		iter = 4;
+	}
+
+	threads = calloc(num_contexts, sizeof(*threads));
+
+	for (i = 0; i < num_contexts; i++)
+		pthread_create(&threads[i], NULL, work, &i);
+
+	for (i = 0; i < num_contexts; i++) {
+		void *retval;
+		igt_assert(pthread_join(threads[i], &retval) == 0);
+	}
+
+	free(threads);
+	close(fd);
+
+	igt_exit();
+}
diff --git a/tests/gem_ctx_param_basic.c b/tests/gem_ctx_param_basic.c
new file mode 100644
index 000000000000..8a2534cd64ee
--- /dev/null
+++ b/tests/gem_ctx_param_basic.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright © 2015 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.
+ *
+ * Authors:
+ *    Daniel Vetter <daniel.vetter@ffwll.ch>
+ */
+
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include "ioctl_wrappers.h"
+#include "drmtest.h"
+#include "igt_aux.c"
+
+IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
+
+int fd;
+int32_t ctx;
+
+#define LOCAL_I915_GEM_CONTEXT_GETPARAM       0x34
+#define LOCAL_I915_GEM_CONTEXT_SETPARAM       0x35
+#define LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_GETPARAM, struct local_i915_gem_context_param)
+#define LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_SETPARAM, struct local_i915_gem_context_param)
+
+#define TEST_SUCCESS(ioc) \
+	igt_assert(drmIoctl(fd, (ioc), &ctx_param) == 0);
+#define TEST_FAIL(ioc, exp_errno) \
+	igt_assert(drmIoctl(fd, (ioc), &ctx_param) < 0 && errno == exp_errno);
+
+igt_main
+{
+	struct local_i915_gem_context_param ctx_param;
+
+	memset(&ctx_param, 0, sizeof(ctx_param));
+
+	igt_fixture {
+		fd = drm_open_any_render();
+		ctx = gem_context_create(fd);
+	}
+
+	ctx_param.param  = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
+
+	igt_subtest("basic") {
+		ctx_param.context = ctx;
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM);
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+	}
+
+	igt_subtest("basic-default") {
+		ctx_param.context = 0;
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM);
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+	}
+
+	igt_subtest("invalid-ctx-get") {
+		ctx_param.context = 2;
+		TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, ENOENT);
+	}
+
+	igt_subtest("invalid-ctx-set") {
+		ctx_param.context = ctx;
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM);
+		ctx_param.context = 2;
+		TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, ENOENT);
+	}
+
+	igt_subtest("invalid-size-get") {
+		ctx_param.context = ctx;
+		ctx_param.size = 8;
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM);
+		igt_assert(ctx_param.size == 0);
+	}
+
+	igt_subtest("invalid-size-set") {
+		ctx_param.context = ctx;
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM);
+		ctx_param.size = 8;
+		TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+		ctx_param.size = 0;
+	}
+
+	ctx_param.param  = LOCAL_CONTEXT_PARAM_BAN_PERIOD + 1;
+
+	igt_subtest("invalid-param-get") {
+		ctx_param.context = ctx;
+		TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, EINVAL);
+	}
+
+	igt_subtest("invalid-param-set") {
+		ctx_param.context = ctx;
+		TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+	}
+
+	ctx_param.param  = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
+
+	igt_subtest("non-root-set") {
+		igt_fork(child, 1) {
+			igt_drop_root();
+
+			ctx_param.context = ctx;
+			TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM);
+			ctx_param.value--;
+			TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EPERM);
+		}
+
+		igt_waitchildren();
+	}
+
+	igt_subtest("root-set") {
+		ctx_param.context = ctx;
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM);
+		ctx_param.value--;
+		TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+	}
+
+	igt_fixture
+		close(fd);
+}
-- 
2.1.4

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

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

* [PATCH i-g-t 11/17] tests: Add invalid pad tests for ctx create/destroy
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (8 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 10/17] tests: Add gem_ctx_param_basic Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 12/17] tests/gem_ppgtt: Start rcs before bcs for context tests Daniel Vetter
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter

We've missed them, and the kernel isn't nasty enough and forgot to
check them. To add these tests convert the existing create/destroy
tests over to subtests.

v2: Do the basic create/destroy in ctx_bad_destroy in a fixture
so that all the tests skip properly.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 tests/gem_ctx_bad_destroy.c | 48 +++++++++++++++++++++++++++++++--------------
 tests/gem_ctx_create.c      | 42 +++++++++++++++++++++++++++------------
 2 files changed, 63 insertions(+), 27 deletions(-)

diff --git a/tests/gem_ctx_bad_destroy.c b/tests/gem_ctx_bad_destroy.c
index 368bf95f2fcb..ee89763870ef 100644
--- a/tests/gem_ctx_bad_destroy.c
+++ b/tests/gem_ctx_bad_destroy.c
@@ -38,28 +38,46 @@
 
 IGT_TEST_DESCRIPTION("Negative test cases for destroy contexts.");
 
-igt_simple_main
+uint32_t ctx_id;
+int fd;
+
+igt_main
 {
-	uint32_t ctx_id;
-	int fd;
+	igt_fixture {
+		fd = drm_open_any_render();
+
+		ctx_id = gem_context_create(fd);
+		/* Make sure a proper destroy works first */
+		gem_context_destroy(fd, ctx_id);
+	}
 
-	igt_skip_on_simulation();
+	/* try double destroy */
+	igt_subtest("double-destroy") {
+		ctx_id = gem_context_create(fd);
+		gem_context_destroy(fd, ctx_id);
+		igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
+	}
 
-	fd = drm_open_any_render();
+	igt_subtest("invalid-ctx")
+		igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
 
-	ctx_id = gem_context_create(fd);
+	igt_subtest("invalid-default-ctx")
+		igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
 
-	/* Make sure a proper destroy works first */
-	gem_context_destroy(fd, ctx_id);
+	igt_subtest("invalid-pad") {
+		struct drm_i915_gem_context_destroy destroy;
 
-	/* try double destroy */
-	igt_assert(__gem_context_destroy(fd, ctx_id) == -ENOENT);
+		ctx_id = gem_context_create(fd);
 
-	/* destroy something random */
-	igt_assert(__gem_context_destroy(fd, 2) == -ENOENT);
+		memset(&destroy, 0, sizeof(destroy));
+		destroy.ctx_id = ctx_id;
+		destroy.pad = 1;
 
-	/* Try to destroy the default context */
-	igt_assert(__gem_context_destroy(fd, 0) == -ENOENT);
+		igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy) < 0 &&
+			   errno == EINVAL);
+		gem_context_destroy(fd, ctx_id);
+	}
 
-	close(fd);
+	igt_fixture
+		close(fd);
 }
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index 1c710fdebbf7..046c974dfb6a 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -32,22 +32,40 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 
-igt_simple_main
+int ret, fd;
+struct drm_i915_gem_context_create create;
+
+igt_main
 {
-	int ret, fd;
-	struct drm_i915_gem_context_create create;
+	igt_fixture
+		fd = drm_open_any_render();
+
+	igt_subtest("basic") {
+		create.ctx_id = rand();
+		create.pad = 0;
+
+
+		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
+		igt_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
+		igt_assert(ret == 0);
+		igt_assert(create.ctx_id != 0);
+	}
 
-	igt_skip_on_simulation();
+	igt_subtest("invalid-pad") {
+		create.ctx_id = rand();
+		create.pad = 0;
 
-	create.ctx_id = rand();
-	create.pad = rand();
+		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
+		igt_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
+		igt_assert(ret == 0);
+		igt_assert(create.ctx_id != 0);
 
-	fd = drm_open_any_render();
+		create.pad = 1;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
-	igt_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
-	igt_assert(ret == 0);
-	igt_assert(create.ctx_id != 0);
+		igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create) < 0 &&
+			   errno == EINVAL);
+	}
 
-	close(fd);
+	igt_fixture
+		close(fd);
 }
-- 
2.1.4

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

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

* [PATCH i-g-t 12/17] tests/gem_ppgtt: Start rcs before bcs for context tests
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (9 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 11/17] tests: Add invalid pad tests for ctx create/destroy Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 13/17] tests: Align subtest with naming convention Daniel Vetter
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

This way the igt_require for the ctx support is hit before we've
launched a bazillion threads and need to wait until they're all done.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/gem_ppgtt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/gem_ppgtt.c b/tests/gem_ppgtt.c
index 0ee4f5b2a31e..850c99ea4b8a 100644
--- a/tests/gem_ppgtt.c
+++ b/tests/gem_ppgtt.c
@@ -220,8 +220,8 @@ int main(int argc, char **argv)
 	igt_subtest("bcs-vs-rcs-ctxN") {
 		dri_bo *bcs[1], *rcs[N_CHILD];
 
-		fork_bcs_copy(0x4000, bcs, 1);
 		fork_rcs_copy(0x8000 / N_CHILD, rcs, N_CHILD, CREATE_CONTEXT);
+		fork_bcs_copy(0x4000, bcs, 1);
 
 		igt_waitchildren();
 
-- 
2.1.4

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

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

* [PATCH i-g-t 13/17] tests: Align subtest with naming convention
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (10 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 12/17] tests/gem_ppgtt: Start rcs before bcs for context tests Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 21:53   ` Chris Wilson
  2015-02-10 18:05 ` [PATCH i-g-t 14/17] lib/igt_aux: s/swap/igt_swap/ Daniel Vetter
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Yeah, historically grown but we should try to be somewhat consistent.
It helps with filtering testcases.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/gem_concurrent_blit.c |  4 ++--
 tests/gem_ppgtt.c           |  4 ++--
 tests/kms_flip.c            | 16 ++++++++--------
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index cec6ea49f95c..0b0adce7892c 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -725,8 +725,8 @@ run_basic_modes(const struct access_mode *mode,
 		{ "cpu", cpu_copy_bo, cpu_require },
 		{ "gtt", gtt_copy_bo, gtt_require },
 		{ "wc", wc_copy_bo, wc_require },
-		{ "bcs", blt_copy_bo, bcs_require },
-		{ "rcs", render_copy_bo, rcs_require },
+		{ "blt", blt_copy_bo, bcs_require },
+		{ "render", render_copy_bo, rcs_require },
 		{ NULL, NULL }
 	}, *p;
 	const struct {
diff --git a/tests/gem_ppgtt.c b/tests/gem_ppgtt.c
index 850c99ea4b8a..5bf773c25270 100644
--- a/tests/gem_ppgtt.c
+++ b/tests/gem_ppgtt.c
@@ -205,7 +205,7 @@ int main(int argc, char **argv)
 {
 	igt_subtest_init(argc, argv);
 
-	igt_subtest("bcs-vs-rcs-ctx0") {
+	igt_subtest("blt-vs-render-ctx0") {
 		dri_bo *bcs[1], *rcs[N_CHILD];
 
 		fork_bcs_copy(0x4000, bcs, 1);
@@ -217,7 +217,7 @@ int main(int argc, char **argv)
 		surfaces_check(rcs, N_CHILD, 0x8000 / N_CHILD);
 	}
 
-	igt_subtest("bcs-vs-rcs-ctxN") {
+	igt_subtest("blt-vs-render-ctxN") {
 		dri_bo *bcs[1], *rcs[N_CHILD];
 
 		fork_rcs_copy(0x8000 / N_CHILD, rcs, N_CHILD, CREATE_CONTEXT);
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 557bcd4ad3f6..292b7bc60f09 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1640,12 +1640,12 @@ int main(int argc, char **argv)
 					"blocking-absolute-wf_vblank" },
 		{ 60,  TEST_VBLANK | TEST_DPMS | TEST_EINVAL, "wf_vblank-vs-dpms" },
 		{ 60,  TEST_VBLANK | TEST_DPMS | TEST_WITH_DUMMY_BCS,
-					"bcs-wf_vblank-vs-dpms" },
+					"blt-wf_vblank-vs-dpms" },
 		{ 60,  TEST_VBLANK | TEST_DPMS | TEST_WITH_DUMMY_RCS,
 					"rcs-wf_vblank-vs-dpms" },
 		{ 60,  TEST_VBLANK | TEST_MODESET | TEST_EINVAL, "wf_vblank-vs-modeset" },
 		{ 60,  TEST_VBLANK | TEST_MODESET | TEST_WITH_DUMMY_BCS,
-					"bcs-wf_vblank-vs-modeset" },
+					"blt-wf_vblank-vs-modeset" },
 		{ 60,  TEST_VBLANK | TEST_MODESET | TEST_WITH_DUMMY_RCS,
 					"rcs-wf_vblank-vs-modeset" },
 
@@ -1657,14 +1657,14 @@ int main(int argc, char **argv)
 			"plain-flip-fb-recreate" },
 		{ 30, TEST_FLIP | TEST_RMFB | TEST_MODESET , "flip-vs-rmfb" },
 		{ 60, TEST_FLIP | TEST_DPMS | TEST_EINVAL, "flip-vs-dpms" },
-		{ 60, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_BCS, "bcs-flip-vs-dpms" },
-		{ 60, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_RCS, "rcs-flip-vs-dpms" },
+		{ 60, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_BCS, "blt-flip-vs-dpms" },
+		{ 60, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_RCS, "render-flip-vs-dpms" },
 		{ 30,  TEST_FLIP | TEST_PAN, "flip-vs-panning" },
-		{ 60, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_BCS, "bcs-flip-vs-panning" },
-		{ 60, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_RCS, "rcs-flip-vs-panning" },
+		{ 60, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_BCS, "blt-flip-vs-panning" },
+		{ 60, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_RCS, "render-flip-vs-panning" },
 		{ 60, TEST_FLIP | TEST_MODESET | TEST_EINVAL, "flip-vs-modeset" },
-		{ 60, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_BCS, "bcs-flip-vs-modeset" },
-		{ 60, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_RCS, "rcs-flip-vs-modeset" },
+		{ 60, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_BCS, "blt-flip-vs-modeset" },
+		{ 60, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_RCS, "render-flip-vs-modeset" },
 		{ 30,  TEST_FLIP | TEST_VBLANK_EXPIRED_SEQ,
 					"flip-vs-expired-vblank" },
 
-- 
2.1.4

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

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

* [PATCH i-g-t 14/17] lib/igt_aux: s/swap/igt_swap/
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (11 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 13/17] tests: Align subtest with naming convention Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 15/17] tests/gem_wait: Adjust makefile Daniel Vetter
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

It collides with the subtest naming convention glossary entry for swap.
Which makes the docbook xml stuff unhappy.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 lib/igt.cocci           | 4 ++--
 lib/igt_aux.h           | 2 +-
 tests/eviction_common.c | 2 +-
 tests/gem_ctx_thrash.c  | 4 ++--
 tests/gem_seqno_wrap.c  | 2 +-
 tests/gem_stress.c      | 2 +-
 tests/kms_flip.c        | 4 ++--
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/igt.cocci b/lib/igt.cocci
index fd4ad2564bea..41a8beb36029 100644
--- a/lib/igt.cocci
+++ b/lib/igt.cocci
@@ -92,7 +92,7 @@ expression E;
 - assert(E);
 + igt_assert(E);
 
-// Replace open-coded swap()
+// Replace open-coded igt_swap()
 @@
 type T;
 T a, b, tmp;
@@ -100,7 +100,7 @@ T a, b, tmp;
 - tmp = a;
 - a = b;
 - b = tmp;
-+ swap(a, b);
++ igt_swap(a, b);
 
 // Replace open-coded min()
 @@
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 798a5b45fcb9..edc36a221922 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -94,7 +94,7 @@ void intel_require_memory(uint32_t count, uint32_t size, unsigned mode);
 #define min(a, b) ((a) < (b) ? (a) : (b))
 #define max(a, b) ((a) > (b) ? (a) : (b))
 
-#define swap(a, b) do {		\
+#define igt_swap(a, b) do {	\
 	typeof(a) _tmp = (a);	\
 	(a) = (b);		\
 	(b) = _tmp;		\
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index 4a12dcbc345d..b18c2a73f9c7 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -55,7 +55,7 @@ static void exchange_uint32_t(void *array, unsigned i, unsigned j)
 {
 	uint32_t *i_arr = array;
 
-	swap(i_arr[i], i_arr[j]);
+	igt_swap(i_arr[i], i_arr[j]);
 }
 
 static int minor_evictions(int fd, struct igt_eviction_test_ops *ops,
diff --git a/tests/gem_ctx_thrash.c b/tests/gem_ctx_thrash.c
index 5c272338e795..b4818f4e6337 100644
--- a/tests/gem_ctx_thrash.c
+++ b/tests/gem_ctx_thrash.c
@@ -55,13 +55,13 @@ static int ctx_per_thread;
 static void xchg_ptr(void *array, unsigned i, unsigned j)
 {
 	void **A = array;
-	swap(A[i], A[j]);
+	igt_swap(A[i], A[j]);
 }
 
 static void xchg_int(void *array, unsigned i, unsigned j)
 {
 	int *A = array;
-	swap(A[i], A[j]);
+	igt_swap(A[i], A[j]);
 }
 
 static int reopen(int _fd)
diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c
index 42493efdb20e..d07ec96064eb 100644
--- a/tests/gem_seqno_wrap.c
+++ b/tests/gem_seqno_wrap.c
@@ -172,7 +172,7 @@ static void exchange_uint(void *array, unsigned i, unsigned j)
 {
 	unsigned *i_arr = array;
 
-	swap(i_arr[i], i_arr[j]);
+	igt_swap(i_arr[i], i_arr[j]);
 }
 
 static void run_sync_test(int num_buffers, bool verify)
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index 9f20bde2f45a..f687b2d1c795 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -571,7 +571,7 @@ static void exchange_uint(void *array, unsigned i, unsigned j)
 {
 	unsigned *i_arr = array;
 
-	swap(i_arr[i], i_arr[j]);
+	igt_swap(i_arr[i], i_arr[j]);
 }
 
 static void copy_tiles(unsigned *permutation)
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 292b7bc60f09..09dc3c794fdf 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -242,7 +242,7 @@ static int _emit_dummy_load__bcs(struct test_output *o, int limit, int timeout)
 			  2048, 2048,
 			  2048*4, 2048*4);
 
-		swap(src_bo, dst_bo);
+		igt_swap(src_bo, dst_bo);
 	}
 	blit_copy(fb_bo, src_bo,
 		  min(o->fb_width, 2048), min(o->fb_height, 2048),
@@ -357,7 +357,7 @@ static int _emit_dummy_load__rcs(struct test_output *o, int limit, int timeout)
 			 2048, 2048,
 			 dst, 0, 0);
 
-		swap(src, dst);
+		igt_swap(src, dst);
 	}
 	copyfunc(batch, NULL,
 		 src, 0, 0,
-- 
2.1.4

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

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

* [PATCH i-g-t 15/17] tests/gem_wait: Adjust makefile
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (12 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 14/17] lib/igt_aux: s/swap/igt_swap/ Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:05 ` [PATCH i-g-t 16/17] doc: Consolidate naming conventions into docbook Daniel Vetter
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

I've forgotten to do this in

commit e4753d2d96fbb88077e70820793137f45f02c9ba
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Mon Sep 29 14:42:33 2014 +0200

    tests/gem_wait_render_timeout: Convert to subtests

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index ec2bd301fac1..5efc8d8c0e0d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -73,7 +73,7 @@ gen7_forcewake_mt_LDADD = $(LDADD) -lpthread
 gem_userptr_blits_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_userptr_blits_LDADD = $(LDADD) -lpthread
 
-gem_wait_render_timeout_LDADD = $(LDADD) -lrt
+gem_wait_LDADD = $(LDADD) -lrt
 kms_flip_LDADD = $(LDADD) -lrt -lpthread
 
 prime_nv_test_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
-- 
2.1.4

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

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

* [PATCH i-g-t 16/17] doc: Consolidate naming conventions into docbook
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (13 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 15/17] tests/gem_wait: Adjust makefile Daniel Vetter
@ 2015-02-10 18:05 ` Daniel Vetter
  2015-02-10 18:06 ` [PATCH i-g-t 17/17] lib/igt_gt: Document and consolidate Daniel Vetter
  2015-02-10 21:36 ` [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Chris Wilson
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:05 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

Duplication just means it gets out of sync.

Also update they keyword list in the Makefile, not everything was listed.
And add a new "invalid" keyword.

While at it update NEWS.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 CONTRIBUTING                                       |  2 +-
 NEWS                                               | 12 ++++
 docs/reference/intel-gpu-tools/Makefile.am         |  2 +-
 .../intel-gpu-tools/igt_test_programs.xml          |  7 +++
 tests/NAMING-CONVENTION                            | 71 ----------------------
 5 files changed, 21 insertions(+), 73 deletions(-)
 delete mode 100644 tests/NAMING-CONVENTION

diff --git a/CONTRIBUTING b/CONTRIBUTING
index 7c20fdb734ce..e2c352e78fa0 100644
--- a/CONTRIBUTING
+++ b/CONTRIBUTING
@@ -22,7 +22,7 @@ A short list of contribution guidelines:
   developer's certificate of origin: http://developercertificate.org/
 
 - When submitting new testcases please follow the naming conventions documented
-  in tests/NAMING-CONVENTION. Also please make full use of all the helpers and
+  in the generated documentation. Also please make full use of all the helpers and
   convenience macros provided by the igt library. The semantic patch lib/igt.cocci
   can help with the more automatic conversions.
 
diff --git a/NEWS b/NEWS
index 67146a3c50af..becf1b246852 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,18 @@ Release 1.10 (XXXX-XX-XX)
 
 - New frequency manipulation tool (intel_gpu_frequency)
 
+- Adjustments for the Solaris port (Alan Coopersmith).
+
+- Remove tests/NAMING-CONVENTION since it's all in the docbook now, to avoid
+  divergent conventions.
+
+- New CRITICAL log level for really serious stuff (Thomas Wood).
+
+- Interactive test mode can now be enabled by the shared cmdline option
+  --interactive-debug=$var (Rodrigo Vivi).
+
+- Piles of new testcases and improvements to existing ones as usual.
+
 Release 1.9 (2014-12-12)
 ------------------------
 
diff --git a/docs/reference/intel-gpu-tools/Makefile.am b/docs/reference/intel-gpu-tools/Makefile.am
index 0a47764d8696..0f10eaab4d6a 100644
--- a/docs/reference/intel-gpu-tools/Makefile.am
+++ b/docs/reference/intel-gpu-tools/Makefile.am
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
 TESTLISTS = $(top_builddir)/tests/single-tests.txt $(top_builddir)/tests/multi-tests.txt
-KEYWORDS = (hang|swap|thrash|crc|tiled|tiling|rte|ctx|exec|rpm)
+KEYWORDS = (invalid|hang|swap|thrash|crc|tiled|tiling|rte|ctx|render|blt|bsd|vebox|exec|rpm)
 
 xml/igt_test_programs_%_programs.xml: $(TESTLISTS)
 	mkdir -p `dirname $@`
diff --git a/docs/reference/intel-gpu-tools/igt_test_programs.xml b/docs/reference/intel-gpu-tools/igt_test_programs.xml
index 36ad1f358e04..bf8a939d6665 100644
--- a/docs/reference/intel-gpu-tools/igt_test_programs.xml
+++ b/docs/reference/intel-gpu-tools/igt_test_programs.xml
@@ -197,6 +197,13 @@
       various features of the test and can be used to filter and select
       particular tests.</para>
 
+    <glossentry id="invalid">
+      <glossterm>invalid</glossterm>
+      <glossdef>
+        <para>Negative tests to validate kernel interface input validation.</para>
+      </glossdef>
+    </glossentry>
+
     <glossentry id="hang">
       <glossterm>hang</glossterm>
       <glossdef>
diff --git a/tests/NAMING-CONVENTION b/tests/NAMING-CONVENTION
deleted file mode 100644
index 7c27fdbb16c2..000000000000
--- a/tests/NAMING-CONVENTION
+++ /dev/null
@@ -1,71 +0,0 @@
-Naming Convention of i-g-t Tests and Subtests
-=============================================
-
-To facilitate easy test selection with piglit we need a somewhat consistent
-naming scheme for tests and subtests.
-
-Test Prefixes
--------------
-
-core_: Test for core drm ioctls and behaviour.
-
-kms_: Used for modesetting tests.
-
-drm_: Tests for libdrm behaviour, currently just testing the buffer cache
-reaping.
-
-gem_: Used for all kinds of GEM tests.
-
-prime_: Used for buffer sharing tests, both for self-importing (used by
-dri3/wayland) and actual multi-gpu tests.
-
-drv_: Tests for overall driver behaviour like module reload, s/r, debugfs files.
-
-pm_: Tests for power management features like runtime PM, tuning knobs in sysfs
-and also performance tuning features.
-
-gen3_: Used by Chris' gen3 specific tiling/fencing tests. Generally tests that
-only run on some platforms don't have a specific prefix but just skip on
-platforms where the test doesn't apply.
-
-debugfs_/sysfs_: Mostly for tests that use sysfs/debugfs but tend to tests all
-sorts of things. Please consider using a more appropriate prefix from above if
-the main point isn't to test sysfs/debugfs, but a driver subsystem/feature.
-
-igt_: Testcase which test the i-g-t infrastructure itself and which are all run
-through "make check" while building i-g-t.
-
-(Sub-)Test patterns
--------------------
-
-Much more powerful for filtering sets of tests are patterns anywhere in either
-the test or subtest name.
-
-hang: Tests that provoke gpu hangs
-
-swap: Tests that force their full working sets through swap. Dreadfully slow on
-machines with spinning rust and tons of memory.
-
-thrash: Tests that tend to have really slow forward progress due to
-gtt/memory/.. thrashing. Mostly used to stress-test error-handling corner-cases.
-
-crc: Tests that use the display CRC infrastructure to check the results.
-
-tiled/tiling: Tests that exercise behaviour on tiled buffers.
-
-normal/uncached/snoop: Usual 3 variants for tests that use different coherency
-modes for the buffer objects they're using.
-
-rte: _R_un_t_ime _e_nviroment checks. For testcases which will fail if the
-machine isn't configured properly there should be a first subtest to just check
-for that.
-
-ctx: Tests that exercise the hw context support.
-
-render/blt/bsd/vebox: Tests which apply to individual rings should use these
-suffixes. They're a bit inconsistent and historically grown, but they new Bspec
-names (RCS, BCS, VCS and VECS) aren't really clearer.
-
-exec: Tests that exercise the execbuf code in various ways.
-
-rpm: Runtime PM tests.
-- 
2.1.4

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

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

* [PATCH i-g-t 17/17] lib/igt_gt: Document and consolidate
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (14 preceding siblings ...)
  2015-02-10 18:05 ` [PATCH i-g-t 16/17] doc: Consolidate naming conventions into docbook Daniel Vetter
@ 2015-02-10 18:06 ` Daniel Vetter
  2015-02-10 21:36 ` [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Chris Wilson
  16 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 18:06 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter

Also move forcewake and stop_rings code from igt_debugfs to igt_gt
since it fits better. And move the hang injection fork helpers from
igt_aux to igt_gt, too.

Also push the intel_gen call into igt_hang_ring while at it.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   1 +
 lib/drmtest.c                                      |   1 +
 lib/igt_aux.c                                      |  68 ------
 lib/igt_aux.h                                      |   3 -
 lib/igt_debugfs.c                                  | 122 -----------
 lib/igt_debugfs.h                                  |  35 ---
 lib/igt_gt.c                                       | 240 ++++++++++++++++++++-
 lib/igt_gt.h                                       |  46 +++-
 lib/intel_mmio.c                                   |   2 +-
 tests/drv_hangman.c                                |   2 +-
 tests/drv_suspend.c                                |   2 +-
 tests/gem_concurrent_blit.c                        |   4 +-
 tests/gem_ctx_exec.c                               |   2 +-
 tests/gem_evict_alignment.c                        |   1 +
 tests/gem_evict_everything.c                       |   1 +
 tests/gem_pread_after_blit.c                       |   2 +-
 tests/gem_reloc_vs_gpu.c                           |   2 +-
 tests/gem_reset_stats.c                            |   2 +-
 tests/gem_workarounds.c                            |   2 +-
 tests/kms_flip.c                                   |   2 +-
 tests/kms_pipe_crc_basic.c                         |   2 +-
 tests/pm_rpm.c                                     |   2 +-
 tests/pm_rps.c                                     |   2 +-
 23 files changed, 300 insertions(+), 246 deletions(-)

diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index 9cfb836bb8bd..6c953fd6841f 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -21,6 +21,7 @@
     <xi:include href="xml/igt_kms.xml"/>
     <xi:include href="xml/igt_fb.xml"/>
     <xi:include href="xml/igt_aux.xml"/>
+    <xi:include href="xml/igt_gt.xml"/>
     <xi:include href="xml/ioctl_wrappers.xml"/>
     <xi:include href="xml/intel_batchbuffer.xml"/>
     <xi:include href="xml/intel_chipset.xml"/>
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 7cdef36655d0..1d6e882c0fea 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -51,6 +51,7 @@
 #include "i915_drm.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
+#include "igt_gt.h"
 #include "igt_debugfs.h"
 #include "version.h"
 #include "config.h"
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index aefa0863e9e9..b31f0cdb71fc 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -132,74 +132,6 @@ void igt_stop_signal_helper(void)
 	sig_stat = 0;
 }
 
-/* GPU abusers */
-static struct igt_helper_process hang_helper;
-static void __attribute__((noreturn))
-hang_helper_process(pid_t pid, int fd, int gen)
-{
-	while (1) {
-		if (kill(pid, 0)) /* Parent has died, so must we. */
-			exit(0);
-
-		igt_post_hang_ring(fd,
-				   igt_hang_ring(fd, gen, I915_EXEC_DEFAULT));
-
-		sleep(1);
-	}
-}
-
-/**
- * igt_fork_hang_helper:
- *
- * Fork a child process using #igt_fork_helper to hang the default engine
- * of the GPU at regular intervals.
- *
- * This is useful to exercise slow running code (such as aperture placement)
- * which needs to be robust against a GPU reset.
- *
- * In tests with subtests this function can be called outside of failure
- * catching code blocks like #igt_fixture or #igt_subtest.
- */
-int igt_fork_hang_helper(void)
-{
-	int fd, gen;
-
-	if (igt_only_list_subtests())
-		return 1;
-
-	fd = drm_open_any();
-	if (fd == -1)
-		return 0;
-
-	gen = intel_gen(intel_get_drm_devid(fd));
-	if (gen < 5) {
-		close(fd);
-		return 0;
-	}
-
-	igt_fork_helper(&hang_helper)
-		hang_helper_process(getppid(), fd, gen);
-
-	close(fd);
-	return 1;
-}
-
-/**
- * igt_stop_hang_helper:
- *
- * Stops the child process spawned with igt_fork_hang_helper().
- *
- * In tests with subtests this function can be called outside of failure
- * catching code blocks like #igt_fixture or #igt_subtest.
- */
-void igt_stop_hang_helper(void)
-{
-	if (igt_only_list_subtests())
-		return;
-
-	igt_stop_helper(&hang_helper);
-}
-
 /**
  * igt_check_boolean_env_var:
  * @env_var: environment variable name
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index edc36a221922..7f42b337f2ec 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -39,9 +39,6 @@ extern int num_trash_bos;
 void igt_fork_signal_helper(void);
 void igt_stop_signal_helper(void);
 
-int igt_fork_hang_helper(void);
-void igt_stop_hang_helper(void);
-
 void igt_exchange_int(void *array, unsigned i, unsigned j);
 void igt_permute_array(void *array, unsigned size,
 			   void (*exchange_func)(void *array,
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index b44333e840da..a2cec45a1460 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -613,125 +613,3 @@ void igt_enable_prefault(void)
 {
 	igt_prefault_control(true);
 }
-
-/**
- * igt_open_forcewake_handle:
- *
- * This functions opens the debugfs forcewake file and so prevents the GT from
- * suspending. The reference is automatically dropped when the is closed.
- *
- * Returns:
- * The file descriptor of the forcewake handle or -1 if that didn't work out.
- */
-int igt_open_forcewake_handle(void)
-{
-	if (getenv("IGT_NO_FORCEWAKE"))
-		return -1;
-	return igt_debugfs_open("i915_forcewake_user", O_WRONLY);
-}
-
-/**
- * igt_to_stop_ring_flag:
- * @ring: the specified ring flag from execbuf ioctl (I915_EXEC_*)
- *
- * This converts the specified ring to a ring flag to be used
- * with igt_get_stop_rings() and igt_set_stop_rings().
- *
- * Returns:
- * Ring flag for the given ring.
- */
-enum stop_ring_flags igt_to_stop_ring_flag(int ring) {
-	if (ring == I915_EXEC_DEFAULT)
-		return STOP_RING_RENDER;
-
-	igt_assert(ring && ((ring & ~I915_EXEC_RING_MASK) == 0));
-	return 1 << (ring - 1);
-}
-
-static void stop_rings_write(uint32_t mask)
-{
-	int fd;
-	char buf[80];
-
-	igt_assert(snprintf(buf, sizeof(buf), "0x%08x", mask) == 10);
-	fd = igt_debugfs_open("i915_ring_stop", O_WRONLY);
-	igt_assert(fd >= 0);
-
-	igt_assert(write(fd, buf, strlen(buf)) == strlen(buf));
-	close(fd);
-}
-
-/**
- * igt_get_stop_rings:
- *
- * Read current ring flags from 'i915_ring_stop' debugfs entry.
- *
- * Returns:
- * Current ring flags.
- */
-enum stop_ring_flags igt_get_stop_rings(void)
-{
-	int fd;
-	char buf[80];
-	int l;
-	unsigned long long ring_mask;
-
-	fd = igt_debugfs_open("i915_ring_stop", O_RDONLY);
-	igt_assert(fd >= 0);
-	l = read(fd, buf, sizeof(buf)-1);
-	igt_assert(l > 0);
-	igt_assert(l < sizeof(buf));
-
-	buf[l] = '\0';
-
-	close(fd);
-
-	errno = 0;
-	ring_mask = strtoull(buf, NULL, 0);
-	igt_assert(errno == 0);
-	return ring_mask;
-}
-
-/**
- * igt_set_stop_rings:
- * @flags: Ring flags to write
- *
- * This writes @flags to 'i915_ring_stop' debugfs entry. Driver will
- * prevent the CPU from writing tail pointer for the ring that @flags
- * specify. Note that the ring is not stopped right away. Instead any
- * further command emissions won't be executed after the flag is set.
- *
- * This is the least invasive way to make the GPU stuck. Hence you must
- * set this after a batch submission with it's own invalid or endless
- * looping instructions. In this case it is merely for giving notification
- * for the driver that this was simulated hang, as the batch would have
- * caused hang in any case. On the other hand if you use a valid or noop
- * batch and want to hang the ring (GPU), you must set corresponding flag
- * before submitting the batch.
- *
- * Driver checks periodically if a ring is making any progress, and if
- * it is not, it will declare the ring to be hung and will reset the GPU.
- * After reset, the driver will clear flags in 'i915_ring_stop'
- *
- * Note: Always when hanging the GPU, use igt_set_stop_rings() to
- * notify the driver. Driver controls hang log messaging based on
- * these flags and thus prevents false positives on logs.
- */
-void igt_set_stop_rings(enum stop_ring_flags flags)
-{
-	enum stop_ring_flags current;
-
-	igt_assert((flags & ~(STOP_RING_ALL |
-			      STOP_RING_ALLOW_BAN |
-			      STOP_RING_ALLOW_ERRORS)) == 0);
-
-	current = igt_get_stop_rings();
-	igt_assert_f(flags == 0 || current == 0,
-		     "previous i915_ring_stop is still 0x%x\n", current);
-
-	stop_rings_write(flags);
-	current = igt_get_stop_rings();
-	igt_warn_on_f(current != flags,
-		      "i915_ring_stop readback mismatch 0x%x vs 0x%x\n",
-		      flags, current);
-}
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 8ac153966bc1..828502957a98 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -142,39 +142,4 @@ void igt_drop_caches_set(uint64_t val);
 void igt_disable_prefault(void);
 void igt_enable_prefault(void);
 
-int igt_open_forcewake_handle(void);
-
-/**
- * stop_ring_flags:
- * @STOP_RING_NONE: Can be used to clear the pending stop (warning: hang might
- * be declared already). Returned by igt_get_stop_rings() if there is
- * no currently stopped rings.
- * @STOP_RING_RENDER: Render ring
- * @STOP_RING_BSD: Video encoding/decoding ring
- * @STOP_RING_BLT: Blitter ring
- * @STOP_RING_VEBOX: Video enhancement ring
- * @STOP_RING_ALL: All rings
- * @STOP_RING_ALLOW_ERRORS: Driver will not omit expected DRM_ERRORS
- * @STOP_RING_ALLOW_BAN: Driver will use context ban policy
- * @STOP_RING_DEFAULTS: STOP_RING_ALL | STOP_RING_ALLOW_ERRORS
- *
- * Enumeration of all supported flags for igt_set_stop_rings().
- *
- */
-enum stop_ring_flags {
-	STOP_RING_NONE = 0x00,
-	STOP_RING_RENDER = (1 << 0),
-	STOP_RING_BSD = (1 << 1),
-	STOP_RING_BLT = (1 << 2),
-	STOP_RING_VEBOX = (1 << 3),
-	STOP_RING_ALL = 0xff,
-	STOP_RING_ALLOW_ERRORS = (1 << 30),
-	STOP_RING_ALLOW_BAN = (1 << 31),
-	STOP_RING_DEFAULTS = STOP_RING_ALL | STOP_RING_ALLOW_ERRORS,
-};
-
-enum stop_ring_flags igt_to_stop_ring_flag(int ring);
-void igt_set_stop_rings(enum stop_ring_flags flags);
-enum stop_ring_flags igt_get_stop_rings(void);
-
 #endif /* __IGT_DEBUGFS_H__ */
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index e02219acc6fd..26c347b46e8f 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -22,8 +22,13 @@
  */
 
 #include <string.h>
+#include <signal.h>
 #include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
+#include "drmtest.h"
 #include "igt_core.h"
 #include "igt_gt.h"
 #include "igt_debugfs.h"
@@ -31,13 +36,46 @@
 #include "intel_reg.h"
 #include "intel_chipset.h"
 
+/**
+ * SECTION:igt_gt
+ * @short_description: GT support library
+ * @title: i-g-t gt
+ * @include: igt_gt.h
+ *
+ * This library provides various auxiliary helper functions to handle general
+ * interactions with the GT like forcewake handling, injecting hangs or stopping
+ * engines.
+ */
+
+
+/**
+ * igt_require_hang_ring:
+ * @fd: open i915 drm file descriptor
+ * @ring: execbuf ring flag
+ *
+ * Convenience helper to check whether advanced hang injection is supported by
+ * the kernel. Uses igt_skip to automatically skip the test/subtest if this
+ * isn't the case.
+ */
 void igt_require_hang_ring(int fd, int ring)
 {
 	gem_context_require_param(fd, LOCAL_CONTEXT_PARAM_BAN_PERIOD);
 	igt_require(intel_gen(intel_get_drm_devid(fd)) >= 5);
 }
 
-struct igt_hang_ring igt_hang_ring(int fd, int gen, int ring)
+/**
+ * igt_hang_ring:
+ * @fd: open i915 drm file descriptor
+ * @ring: execbuf ring flag
+ *
+ * This helper function injects a hanging batch into @ring. It returns a
+ * #igt_hang_ring_t structure which must be passed to igt_post_hang_ring() for
+ * hang post-processing (after the gpu hang interaction has been tested.
+ *
+ * Returns:
+ * Structure with helper internal state for igt_post_hang_ring().
+ */
+igt_hang_ring_t igt_hang_ring(int fd, int ring)
 {
 	struct drm_i915_gem_relocation_entry reloc;
 	struct drm_i915_gem_execbuffer2 execbuf;
@@ -66,7 +104,7 @@ struct igt_hang_ring igt_hang_ring(int fd, int gen, int ring)
 	exec.relocs_ptr = (uintptr_t)&reloc;
 
 	len = 2;
-	if (gen >= 8)
+	if (intel_gen(intel_get_drm_devid(fd)) >= 8)
 		len++;
 	b[0] = MI_BATCH_BUFFER_START | (len - 2);
 	b[len] = MI_BATCH_BUFFER_END;
@@ -86,6 +124,14 @@ struct igt_hang_ring igt_hang_ring(int fd, int gen, int ring)
 	return (struct igt_hang_ring){ exec.handle, ban };
 }
 
+/**
+ * igt_hang_ring:
+ * @fd: open i915 drm file descriptor
+ * @arg: hang state from igt_hang_ring()
+ *
+ * This function does the necessary post-processing after a gpu hang injected
+ * with igt_hang_ring().
+ */
 void igt_post_hang_ring(int fd, struct igt_hang_ring arg)
 {
 	struct local_i915_gem_context_param param;
@@ -103,3 +149,193 @@ void igt_post_hang_ring(int fd, struct igt_hang_ring arg)
 	param.value = arg.ban;
 	gem_context_set_param(fd, &param);
 }
+
+/* GPU abusers */
+static struct igt_helper_process hang_helper;
+static void __attribute__((noreturn))
+hang_helper_process(pid_t pid, int fd)
+{
+	while (1) {
+		if (kill(pid, 0)) /* Parent has died, so must we. */
+			exit(0);
+
+		igt_post_hang_ring(fd,
+				   igt_hang_ring(fd, I915_EXEC_DEFAULT));
+
+		sleep(1);
+	}
+}
+
+/**
+ * igt_fork_hang_helper:
+ *
+ * Fork a child process using #igt_fork_helper to hang the default engine
+ * of the GPU at regular intervals.
+ *
+ * This is useful to exercise slow running code (such as aperture placement)
+ * which needs to be robust against a GPU reset.
+ *
+ * In tests with subtests this function can be called outside of failure
+ * catching code blocks like #igt_fixture or #igt_subtest.
+ */
+int igt_fork_hang_helper(void)
+{
+	int fd, gen;
+
+	if (igt_only_list_subtests())
+		return 1;
+
+	fd = drm_open_any();
+	if (fd == -1)
+		return 0;
+
+	gen = intel_gen(intel_get_drm_devid(fd));
+	if (gen < 5) {
+		close(fd);
+		return 0;
+	}
+
+	igt_fork_helper(&hang_helper)
+		hang_helper_process(getppid(), fd);
+
+	close(fd);
+	return 1;
+}
+
+/**
+ * igt_stop_hang_helper:
+ *
+ * Stops the child process spawned with igt_fork_hang_helper().
+ *
+ * In tests with subtests this function can be called outside of failure
+ * catching code blocks like #igt_fixture or #igt_subtest.
+ */
+void igt_stop_hang_helper(void)
+{
+	if (igt_only_list_subtests())
+		return;
+
+	igt_stop_helper(&hang_helper);
+}
+
+/**
+ * igt_open_forcewake_handle:
+ *
+ * This functions opens the debugfs forcewake file and so prevents the GT from
+ * suspending. The reference is automatically dropped when the is closed.
+ *
+ * Returns:
+ * The file descriptor of the forcewake handle or -1 if that didn't work out.
+ */
+int igt_open_forcewake_handle(void)
+{
+	if (getenv("IGT_NO_FORCEWAKE"))
+		return -1;
+	return igt_debugfs_open("i915_forcewake_user", O_WRONLY);
+}
+
+/**
+ * igt_to_stop_ring_flag:
+ * @ring: the specified ring flag from execbuf ioctl (I915_EXEC_*)
+ *
+ * This converts the specified ring to a ring flag to be used
+ * with igt_get_stop_rings() and igt_set_stop_rings().
+ *
+ * Returns:
+ * Ring flag for the given ring.
+ */
+enum stop_ring_flags igt_to_stop_ring_flag(int ring) {
+	if (ring == I915_EXEC_DEFAULT)
+		return STOP_RING_RENDER;
+
+	igt_assert(ring && ((ring & ~I915_EXEC_RING_MASK) == 0));
+	return 1 << (ring - 1);
+}
+
+static void stop_rings_write(uint32_t mask)
+{
+	int fd;
+	char buf[80];
+
+	igt_assert(snprintf(buf, sizeof(buf), "0x%08x", mask) == 10);
+	fd = igt_debugfs_open("i915_ring_stop", O_WRONLY);
+	igt_assert(fd >= 0);
+
+	igt_assert(write(fd, buf, strlen(buf)) == strlen(buf));
+	close(fd);
+}
+
+/**
+ * igt_get_stop_rings:
+ *
+ * Read current ring flags from 'i915_ring_stop' debugfs entry.
+ *
+ * Returns:
+ * Current ring flags.
+ */
+enum stop_ring_flags igt_get_stop_rings(void)
+{
+	int fd;
+	char buf[80];
+	int l;
+	unsigned long long ring_mask;
+
+	fd = igt_debugfs_open("i915_ring_stop", O_RDONLY);
+	igt_assert(fd >= 0);
+	l = read(fd, buf, sizeof(buf)-1);
+	igt_assert(l > 0);
+	igt_assert(l < sizeof(buf));
+
+	buf[l] = '\0';
+
+	close(fd);
+
+	errno = 0;
+	ring_mask = strtoull(buf, NULL, 0);
+	igt_assert(errno == 0);
+	return ring_mask;
+}
+
+/**
+ * igt_set_stop_rings:
+ * @flags: Ring flags to write
+ *
+ * This writes @flags to 'i915_ring_stop' debugfs entry. Driver will
+ * prevent the CPU from writing tail pointer for the ring that @flags
+ * specify. Note that the ring is not stopped right away. Instead any
+ * further command emissions won't be executed after the flag is set.
+ *
+ * This is the least invasive way to make the GPU stuck. Hence you must
+ * set this after a batch submission with it's own invalid or endless
+ * looping instructions. In this case it is merely for giving notification
+ * for the driver that this was simulated hang, as the batch would have
+ * caused hang in any case. On the other hand if you use a valid or noop
+ * batch and want to hang the ring (GPU), you must set corresponding flag
+ * before submitting the batch.
+ *
+ * Driver checks periodically if a ring is making any progress, and if
+ * it is not, it will declare the ring to be hung and will reset the GPU.
+ * After reset, the driver will clear flags in 'i915_ring_stop'
+ *
+ * Note: Always when hanging the GPU, use igt_set_stop_rings() to
+ * notify the driver. Driver controls hang log messaging based on
+ * these flags and thus prevents false positives on logs.
+ */
+void igt_set_stop_rings(enum stop_ring_flags flags)
+{
+	enum stop_ring_flags current;
+
+	igt_assert((flags & ~(STOP_RING_ALL |
+			      STOP_RING_ALLOW_BAN |
+			      STOP_RING_ALLOW_ERRORS)) == 0);
+
+	current = igt_get_stop_rings();
+	igt_assert_f(flags == 0 || current == 0,
+		     "previous i915_ring_stop is still 0x%x\n", current);
+
+	stop_rings_write(flags);
+	current = igt_get_stop_rings();
+	igt_warn_on_f(current != flags,
+		      "i915_ring_stop readback mismatch 0x%x vs 0x%x\n",
+		      flags, current);
+}
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index 1ed78837cf5b..f1e080d350d7 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -24,12 +24,54 @@
 #ifndef IGT_GT_H
 #define IGT_GT_H
 
+#include "igt_debugfs.h"
+
 void igt_require_hang_ring(int fd, int ring);
 
-struct igt_hang_ring {
+typedef struct igt_hang_ring {
 	unsigned handle;
 	unsigned ban;
-} igt_hang_ring(int fd, int gen, int ring);
+} igt_hang_ring_t;
+
+struct igt_hang_ring igt_hang_ring(int fd, int ring);
 void igt_post_hang_ring(int fd, struct igt_hang_ring data);
 
+int igt_fork_hang_helper(void);
+void igt_stop_hang_helper(void);
+
+int igt_open_forcewake_handle(void);
+
+/**
+ * stop_ring_flags:
+ * @STOP_RING_NONE: Can be used to clear the pending stop (warning: hang might
+ * be declared already). Returned by igt_get_stop_rings() if there is
+ * no currently stopped rings.
+ * @STOP_RING_RENDER: Render ring
+ * @STOP_RING_BSD: Video encoding/decoding ring
+ * @STOP_RING_BLT: Blitter ring
+ * @STOP_RING_VEBOX: Video enhancement ring
+ * @STOP_RING_ALL: All rings
+ * @STOP_RING_ALLOW_ERRORS: Driver will not omit expected DRM_ERRORS
+ * @STOP_RING_ALLOW_BAN: Driver will use context ban policy
+ * @STOP_RING_DEFAULTS: STOP_RING_ALL | STOP_RING_ALLOW_ERRORS
+ *
+ * Enumeration of all supported flags for igt_set_stop_rings().
+ *
+ */
+enum stop_ring_flags {
+	STOP_RING_NONE = 0x00,
+	STOP_RING_RENDER = (1 << 0),
+	STOP_RING_BSD = (1 << 1),
+	STOP_RING_BLT = (1 << 2),
+	STOP_RING_VEBOX = (1 << 3),
+	STOP_RING_ALL = 0xff,
+	STOP_RING_ALLOW_ERRORS = (1 << 30),
+	STOP_RING_ALLOW_BAN = (1 << 31),
+	STOP_RING_DEFAULTS = STOP_RING_ALL | STOP_RING_ALLOW_ERRORS,
+};
+
+enum stop_ring_flags igt_to_stop_ring_flag(int ring);
+void igt_set_stop_rings(enum stop_ring_flags flags);
+enum stop_ring_flags igt_get_stop_rings(void);
+
 #endif /* IGT_GT_H */
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 5ff1ec1e6be7..9a2ee27bd5e5 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -43,7 +43,7 @@
 
 #include "intel_io.h"
 #include "igt_core.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 #include "intel_chipset.h"
 
 /**
diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c
index 15918ba63ba5..a882822b26b5 100644
--- a/tests/drv_hangman.c
+++ b/tests/drv_hangman.c
@@ -34,7 +34,7 @@
 #include "intel_chipset.h"
 #include "drmtest.h"
 #include "igt_aux.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 #include "ioctl_wrappers.h"
 
 #ifndef I915_PARAM_CMD_PARSER_VERSION
diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c
index 80f6a2254b75..d96f316a8eab 100644
--- a/tests/drv_suspend.c
+++ b/tests/drv_suspend.c
@@ -39,7 +39,7 @@
 
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 #include "igt_aux.h"
 
 #define OBJECT_SIZE (16*1024*1024)
diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c
index 0b0adce7892c..e1693ba76279 100644
--- a/tests/gem_concurrent_blit.c
+++ b/tests/gem_concurrent_blit.c
@@ -464,12 +464,12 @@ static struct igt_hang_ring no_hang(void)
 
 static struct igt_hang_ring bcs_hang(void)
 {
-	return igt_hang_ring(fd, gen, I915_EXEC_BLT);
+	return igt_hang_ring(fd, I915_EXEC_BLT);
 }
 
 static struct igt_hang_ring rcs_hang(void)
 {
-	return igt_hang_ring(fd, gen, I915_EXEC_RENDER);
+	return igt_hang_ring(fd, I915_EXEC_RENDER);
 }
 
 static void hang_require(void)
diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c
index ead3d463003a..43b38a2f5673 100644
--- a/tests/gem_ctx_exec.c
+++ b/tests/gem_ctx_exec.c
@@ -46,7 +46,7 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "igt_aux.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 
 IGT_TEST_DESCRIPTION("Test basic context switch functionality.");
 
diff --git a/tests/gem_evict_alignment.c b/tests/gem_evict_alignment.c
index 0ec58099cad6..c0757705328d 100644
--- a/tests/gem_evict_alignment.c
+++ b/tests/gem_evict_alignment.c
@@ -48,6 +48,7 @@
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "igt_aux.h"
+#include "igt_gt.h"
 
 IGT_TEST_DESCRIPTION("Run a couple of big batches to force the unbind on"
 		     " misalignment code.");
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index ad198f023ae5..15ab382a3427 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -45,6 +45,7 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
+#include "igt_gt.h"
 
 #include "eviction_common.c"
 
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index 6e4bd6257feb..8ed431002172 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -132,7 +132,7 @@ static struct igt_hang_ring no_hang(int fd)
 
 static struct igt_hang_ring bcs_hang(int fd)
 {
-	return igt_hang_ring(fd, batch->gen, batch->gen >= 6 ? I915_EXEC_BLT : I915_EXEC_DEFAULT);
+	return igt_hang_ring(fd, batch->gen >= 6 ? I915_EXEC_BLT : I915_EXEC_DEFAULT);
 }
 
 static void do_test(int fd, int cache_level,
diff --git a/tests/gem_reloc_vs_gpu.c b/tests/gem_reloc_vs_gpu.c
index 68bd17d3ae5b..79f182b477b6 100644
--- a/tests/gem_reloc_vs_gpu.c
+++ b/tests/gem_reloc_vs_gpu.c
@@ -198,7 +198,7 @@ static struct igt_hang_ring no_hang(int fd)
 
 static struct igt_hang_ring bcs_hang(int fd)
 {
-	return igt_hang_ring(fd, batch->gen, I915_EXEC_BLT);
+	return igt_hang_ring(fd, I915_EXEC_BLT);
 }
 
 static void do_test(int fd, bool faulting_reloc,
diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index faa209c1d28a..d3cfe8b13960 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -42,7 +42,7 @@
 
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_aux.h"
diff --git a/tests/gem_workarounds.c b/tests/gem_workarounds.c
index 7511a4306595..0e3613f34b64 100644
--- a/tests/gem_workarounds.c
+++ b/tests/gem_workarounds.c
@@ -42,7 +42,7 @@
 
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 #include "igt_aux.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 09dc3c794fdf..b843478143a2 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -48,7 +48,7 @@
 #include "intel_batchbuffer.h"
 #include "igt_kms.h"
 #include "igt_aux.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 
 #define TEST_DPMS		(1 << 0)
 #define TEST_WITH_DUMMY_BCS	(1 << 1)
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 7380c8a1ea31..a658b39df019 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -28,7 +28,7 @@
 #include <string.h>
 
 #include "drmtest.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 #include "igt_kms.h"
 #include "igt_aux.h"
 #include "ioctl_wrappers.h"
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index c120d75e4bb3..84254b79df53 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -49,7 +49,7 @@
 #include "ioctl_wrappers.h"
 #include "igt_aux.h"
 #include "igt_kms.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 
 /* One day, this will be on your libdrm. */
 #define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index f222c09daaf5..d6897881d2c6 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -42,7 +42,7 @@
 #include "intel_bufmgr.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 #include "ioctl_wrappers.h"
 
 static int drm_fd;
-- 
2.1.4

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

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

* Re: [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring
  2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
                   ` (15 preceding siblings ...)
  2015-02-10 18:06 ` [PATCH i-g-t 17/17] lib/igt_gt: Document and consolidate Daniel Vetter
@ 2015-02-10 21:36 ` Chris Wilson
  2015-02-10 21:56   ` Daniel Vetter
  2015-02-10 21:59   ` [PATCH i-g-t] lib/chipset: Cache devid Daniel Vetter
  16 siblings, 2 replies; 32+ messages in thread
From: Chris Wilson @ 2015-02-10 21:36 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development

On Tue, Feb 10, 2015 at 07:05:44PM +0100, Daniel Vetter wrote:
> Align with common igt library style:
> - Push the igt_require into the function.
> - Push the intel_gen into the function.

Ugh. intel_gen(intel_get_drm_devid(fd)) is the utmost worst offender
when it comes to polluting tests and debug logs with extra ioctls,
making test bring up harder than it should be.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 13/17] tests: Align subtest with naming convention
  2015-02-10 18:05 ` [PATCH i-g-t 13/17] tests: Align subtest with naming convention Daniel Vetter
@ 2015-02-10 21:53   ` Chris Wilson
  2015-02-11  8:44     ` Daniel Vetter
  0 siblings, 1 reply; 32+ messages in thread
From: Chris Wilson @ 2015-02-10 21:53 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development

On Tue, Feb 10, 2015 at 07:05:56PM +0100, Daniel Vetter wrote:
> Yeah, historically grown but we should try to be somewhat consistent.
> It helps with filtering testcases.

I think you are going the wrong way, since the current consensus prefers
XCS naming.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible
  2015-02-10 18:05 ` [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible Daniel Vetter
@ 2015-02-10 21:54   ` Chris Wilson
  2015-02-11  8:42     ` Daniel Vetter
  0 siblings, 1 reply; 32+ messages in thread
From: Chris Wilson @ 2015-02-10 21:54 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development

On Tue, Feb 10, 2015 at 07:05:48PM +0100, Daniel Vetter wrote:
> We have separate require checks already, so these failing is a bug in
> the test logic.

That makes it impossible to use the wrappers to test the ioctl though.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring
  2015-02-10 21:36 ` [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Chris Wilson
@ 2015-02-10 21:56   ` Daniel Vetter
  2015-02-10 21:59   ` [PATCH i-g-t] lib/chipset: Cache devid Daniel Vetter
  1 sibling, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 21:56 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, Intel Graphics Development,
	Daniel Vetter

On Tue, Feb 10, 2015 at 09:36:43PM +0000, Chris Wilson wrote:
> On Tue, Feb 10, 2015 at 07:05:44PM +0100, Daniel Vetter wrote:
> > Align with common igt library style:
> > - Push the igt_require into the function.
> > - Push the intel_gen into the function.
> 
> Ugh. intel_gen(intel_get_drm_devid(fd)) is the utmost worst offender
> when it comes to polluting tests and debug logs with extra ioctls,
> making test bring up harder than it should be.

Well I did look at all of them and made sure it's at most a constant
factor per subtest. And if you want to fix it the solution imo is
certainyl not to cache this everywhere in each test (and complicate them),
but in the library. I'll throw a patch for that on top.
-Daniel
-- 
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

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

* Re: [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc
  2015-02-10 18:05 ` [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc Daniel Vetter
@ 2015-02-10 21:58   ` Chris Wilson
  2015-02-11  8:37     ` Daniel Vetter
  0 siblings, 1 reply; 32+ messages in thread
From: Chris Wilson @ 2015-02-10 21:58 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development

On Tue, Feb 10, 2015 at 07:05:46PM +0100, Daniel Vetter wrote:
> We stick to the overall prefix even for magic require functions.

That seems a bit perverse. Move the #define to a new header perhaps, but
the require is a function of igt, not part of the kernel GEM interface.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH i-g-t] lib/chipset: Cache devid
  2015-02-10 21:36 ` [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Chris Wilson
  2015-02-10 21:56   ` Daniel Vetter
@ 2015-02-10 21:59   ` Daniel Vetter
  2015-02-10 22:28     ` Chris Wilson
  1 sibling, 1 reply; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 21:59 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter

Chris Wilson complained that this adds a lot of noise to the test
startup when full debugging is enabled, so let's cache it. We can do
that since there's only ever one intel gpu in a given system.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 lib/intel_chipset.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index fafd232f89c0..64d66eb29bae 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -125,9 +125,12 @@ intel_get_pci_device(void)
 uint32_t
 intel_get_drm_devid(int fd)
 {
-	uint32_t devid = 0;
+	static uint32_t devid = 0;
 	const char *override;
 
+	if (devid)
+		return devid;
+
 	override = getenv("INTEL_DEVID_OVERRIDE");
 	if (override) {
 		devid = strtod(override, NULL);
-- 
2.1.4

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

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

* Re: [PATCH i-g-t] lib/chipset: Cache devid
  2015-02-10 21:59   ` [PATCH i-g-t] lib/chipset: Cache devid Daniel Vetter
@ 2015-02-10 22:28     ` Chris Wilson
  2015-02-10 22:37       ` Daniel Vetter
  0 siblings, 1 reply; 32+ messages in thread
From: Chris Wilson @ 2015-02-10 22:28 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development

On Tue, Feb 10, 2015 at 10:59:16PM +0100, Daniel Vetter wrote:
> Chris Wilson complained that this adds a lot of noise to the test
> startup when full debugging is enabled, so let's cache it. We can do
> that since there's only ever one intel gpu in a given system.
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Couldn't we move the devid cache to lib/drmtest.c::is_intel() ?

Then I wonder what to do about the getenv override. Whether that is also
better inside is_intel().
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t] lib/chipset: Cache devid
  2015-02-10 22:28     ` Chris Wilson
@ 2015-02-10 22:37       ` Daniel Vetter
  2015-02-10 22:39         ` Daniel Vetter
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 22:37 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, Intel Graphics Development,
	Daniel Vetter

On Tue, Feb 10, 2015 at 10:28:22PM +0000, Chris Wilson wrote:
> On Tue, Feb 10, 2015 at 10:59:16PM +0100, Daniel Vetter wrote:
> > Chris Wilson complained that this adds a lot of noise to the test
> > startup when full debugging is enabled, so let's cache it. We can do
> > that since there's only ever one intel gpu in a given system.
> > 
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> Couldn't we move the devid cache to lib/drmtest.c::is_intel() ?

Sounds like just another place where we should use the helper from
intel_chipset.c. Next patch in-flight ...
-Daniel
-- 
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

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

* Re: [PATCH i-g-t] lib/chipset: Cache devid
  2015-02-10 22:37       ` Daniel Vetter
@ 2015-02-10 22:39         ` Daniel Vetter
  2015-02-10 22:45           ` Daniel Vetter
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 22:39 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, Intel Graphics Development,
	Daniel Vetter

On Tue, Feb 10, 2015 at 11:37:42PM +0100, Daniel Vetter wrote:
> On Tue, Feb 10, 2015 at 10:28:22PM +0000, Chris Wilson wrote:
> > On Tue, Feb 10, 2015 at 10:59:16PM +0100, Daniel Vetter wrote:
> > > Chris Wilson complained that this adds a lot of noise to the test
> > > startup when full debugging is enabled, so let's cache it. We can do
> > > that since there's only ever one intel gpu in a given system.
> > > 
> > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > 
> > Couldn't we move the devid cache to lib/drmtest.c::is_intel() ?
> 
> Sounds like just another place where we should use the helper from
> intel_chipset.c. Next patch in-flight ...

Ok I'm blind, is_intel can fail. So I guess I should extract a new
__get_drm_devid which can fail, put the caching in there (plus override)
and use that in in intel_chipset.c ...
-Daniel
-- 
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

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

* Re: [PATCH i-g-t] lib/chipset: Cache devid
  2015-02-10 22:39         ` Daniel Vetter
@ 2015-02-10 22:45           ` Daniel Vetter
  2015-02-10 22:50             ` Chris Wilson
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel Vetter @ 2015-02-10 22:45 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, Intel Graphics Development,
	Daniel Vetter

On Tue, Feb 10, 2015 at 11:39:45PM +0100, Daniel Vetter wrote:
> On Tue, Feb 10, 2015 at 11:37:42PM +0100, Daniel Vetter wrote:
> > On Tue, Feb 10, 2015 at 10:28:22PM +0000, Chris Wilson wrote:
> > > On Tue, Feb 10, 2015 at 10:59:16PM +0100, Daniel Vetter wrote:
> > > > Chris Wilson complained that this adds a lot of noise to the test
> > > > startup when full debugging is enabled, so let's cache it. We can do
> > > > that since there's only ever one intel gpu in a given system.
> > > > 
> > > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > 
> > > Couldn't we move the devid cache to lib/drmtest.c::is_intel() ?
> > 
> > Sounds like just another place where we should use the helper from
> > intel_chipset.c. Next patch in-flight ...
> 
> Ok I'm blind, is_intel can fail. So I guess I should extract a new
> __get_drm_devid which can fail, put the caching in there (plus override)
> and use that in in intel_chipset.c ...

Doesn't really work since doing the ioctl is part of the dance we do to
figure out whether the fd is really an intel or not :(
-Daniel
-- 
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

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

* Re: [PATCH i-g-t] lib/chipset: Cache devid
  2015-02-10 22:45           ` Daniel Vetter
@ 2015-02-10 22:50             ` Chris Wilson
  2015-02-11  8:49               ` Daniel Vetter
  0 siblings, 1 reply; 32+ messages in thread
From: Chris Wilson @ 2015-02-10 22:50 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter

On Tue, Feb 10, 2015 at 11:45:12PM +0100, Daniel Vetter wrote:
> On Tue, Feb 10, 2015 at 11:39:45PM +0100, Daniel Vetter wrote:
> > On Tue, Feb 10, 2015 at 11:37:42PM +0100, Daniel Vetter wrote:
> > > On Tue, Feb 10, 2015 at 10:28:22PM +0000, Chris Wilson wrote:
> > > > On Tue, Feb 10, 2015 at 10:59:16PM +0100, Daniel Vetter wrote:
> > > > > Chris Wilson complained that this adds a lot of noise to the test
> > > > > startup when full debugging is enabled, so let's cache it. We can do
> > > > > that since there's only ever one intel gpu in a given system.
> > > > > 
> > > > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > 
> > > > Couldn't we move the devid cache to lib/drmtest.c::is_intel() ?
> > > 
> > > Sounds like just another place where we should use the helper from
> > > intel_chipset.c. Next patch in-flight ...
> > 
> > Ok I'm blind, is_intel can fail. So I guess I should extract a new
> > __get_drm_devid which can fail, put the caching in there (plus override)
> > and use that in in intel_chipset.c ...
> 
> Doesn't really work since doing the ioctl is part of the dance we do to
> figure out whether the fd is really an intel or not :(

Something like:

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 7cdef36..4090a4a 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -72,6 +72,8 @@
  * and [batchbuffer](intel-gpu-tools-intel-batchbuffer.html) libraries as dependencies.
  */
 
+uint16_t __drm_device_id;
+
 static int is_i915_device(int fd)
 {
        drm_version_t version;
@@ -100,7 +102,11 @@ is_intel(int fd)
        if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
                return 0;
 
-       return IS_INTEL(devid);
+       if (!IS_INTEL(devid))
+               return 0;
+
+       __drm_device_id = devid;
+       return 1;
 }
 
 static void check_stop_rings(void)
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 508cc83..fabf43e 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -70,6 +70,8 @@ static inline void *igt_mmap64(void *addr, size_t length, int prot, int flags,
  */
 #define ALIGN(v, a) (((v) + (a)-1) & ~((a)-1))
 
+extern uint16_t __drm_device_id;
+
 int drm_get_card(void);
 int __drm_open_any(void);
 int drm_open_any(void);
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index fafd232..33177c6 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -125,26 +125,15 @@ intel_get_pci_device(void)
 uint32_t
 intel_get_drm_devid(int fd)
 {
-       uint32_t devid = 0;
        const char *override;
 
-       override = getenv("INTEL_DEVID_OVERRIDE");
-       if (override) {
-               devid = strtod(override, NULL);
-       } else {
-               struct drm_i915_getparam gp;
-               int ret;
-
-               memset(&gp, 0, sizeof(gp));
-               gp.param = I915_PARAM_CHIPSET_ID;
-               gp.value = (int *)&devid;
-
-               ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
-               igt_assert(ret == 0);
-               errno = 0;
-       }
+       igt_assert(__drm_device_id);
 
-       return devid;
+       override = getenv("INTEL_DEVID_OVERRIDE");
+       if (override)
+               return strtod(override, NULL);
+       else
+               return __drm_device_id;
 }
 
 /**

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc
  2015-02-10 21:58   ` Chris Wilson
@ 2015-02-11  8:37     ` Daniel Vetter
  0 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-11  8:37 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, Intel Graphics Development

On Tue, Feb 10, 2015 at 09:58:37PM +0000, Chris Wilson wrote:
> On Tue, Feb 10, 2015 at 07:05:46PM +0100, Daniel Vetter wrote:
> > We stick to the overall prefix even for magic require functions.
> 
> That seems a bit perverse. Move the #define to a new header perhaps, but
> the require is a function of igt, not part of the kernel GEM interface.

We have lots of these in the ioctl wrapper library already. Imo no need to
put them into a separate library since often they share some static
function with the real ioctl wrapper.
-Daniel
-- 
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

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

* Re: [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible
  2015-02-10 21:54   ` Chris Wilson
@ 2015-02-11  8:42     ` Daniel Vetter
  0 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-11  8:42 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, Intel Graphics Development,
	Daniel Vetter

On Tue, Feb 10, 2015 at 09:54:46PM +0000, Chris Wilson wrote:
> On Tue, Feb 10, 2015 at 07:05:48PM +0100, Daniel Vetter wrote:
> > We have separate require checks already, so these failing is a bug in
> > the test logic.
> 
> That makes it impossible to use the wrappers to test the ioctl though.

Yes. Ime for ioctl testing you want to open-code it anyway so that all the
nasty "put garbage into reserved stuff and padding" tests are possible.
And for those cases where we want to share a bit of code we just add an __
variant which does the usual -errno integer return value. Then the
infallible ones just wrap that in igt_assert/skip.

So just aligning with the usual style.
-Daniel
-- 
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

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

* Re: [PATCH i-g-t 13/17] tests: Align subtest with naming convention
  2015-02-10 21:53   ` Chris Wilson
@ 2015-02-11  8:44     ` Daniel Vetter
  0 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-11  8:44 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, Intel Graphics Development

On Tue, Feb 10, 2015 at 09:53:32PM +0000, Chris Wilson wrote:
> On Tue, Feb 10, 2015 at 07:05:56PM +0100, Daniel Vetter wrote:
> > Yeah, historically grown but we should try to be somewhat consistent.
> > It helps with filtering testcases.
> 
> I think you are going the wrong way, since the current consensus prefers
> XCS naming.

Well we can switch it over, but it should be somewhat consistent. And the
glossary for common subtest names should be updated in the docs, too. At
least for me these subtest patterns are fairly useful to get at a
reasonable testcase selection for development. Might be that everyone else
just laughs at prts, dunno.
-Daniel
-- 
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

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

* Re: [PATCH i-g-t] lib/chipset: Cache devid
  2015-02-10 22:50             ` Chris Wilson
@ 2015-02-11  8:49               ` Daniel Vetter
  0 siblings, 0 replies; 32+ messages in thread
From: Daniel Vetter @ 2015-02-11  8:49 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter, Daniel Vetter,
	Intel Graphics Development, Daniel Vetter

On Tue, Feb 10, 2015 at 10:50:33PM +0000, Chris Wilson wrote:
> On Tue, Feb 10, 2015 at 11:45:12PM +0100, Daniel Vetter wrote:
> > On Tue, Feb 10, 2015 at 11:39:45PM +0100, Daniel Vetter wrote:
> > > On Tue, Feb 10, 2015 at 11:37:42PM +0100, Daniel Vetter wrote:
> > > > On Tue, Feb 10, 2015 at 10:28:22PM +0000, Chris Wilson wrote:
> > > > > On Tue, Feb 10, 2015 at 10:59:16PM +0100, Daniel Vetter wrote:
> > > > > > Chris Wilson complained that this adds a lot of noise to the test
> > > > > > startup when full debugging is enabled, so let's cache it. We can do
> > > > > > that since there's only ever one intel gpu in a given system.
> > > > > > 
> > > > > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > > 
> > > > > Couldn't we move the devid cache to lib/drmtest.c::is_intel() ?
> > > > 
> > > > Sounds like just another place where we should use the helper from
> > > > intel_chipset.c. Next patch in-flight ...
> > > 
> > > Ok I'm blind, is_intel can fail. So I guess I should extract a new
> > > __get_drm_devid which can fail, put the caching in there (plus override)
> > > and use that in in intel_chipset.c ...
> > 
> > Doesn't really work since doing the ioctl is part of the dance we do to
> > figure out whether the fd is really an intel or not :(
> 
> Something like:

Yeah, lgtm.
-Daniel

> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 7cdef36..4090a4a 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -72,6 +72,8 @@
>   * and [batchbuffer](intel-gpu-tools-intel-batchbuffer.html) libraries as dependencies.
>   */
>  
> +uint16_t __drm_device_id;
> +
>  static int is_i915_device(int fd)
>  {
>         drm_version_t version;
> @@ -100,7 +102,11 @@ is_intel(int fd)
>         if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
>                 return 0;
>  
> -       return IS_INTEL(devid);
> +       if (!IS_INTEL(devid))
> +               return 0;
> +
> +       __drm_device_id = devid;
> +       return 1;
>  }
>  
>  static void check_stop_rings(void)
> diff --git a/lib/drmtest.h b/lib/drmtest.h
> index 508cc83..fabf43e 100644
> --- a/lib/drmtest.h
> +++ b/lib/drmtest.h
> @@ -70,6 +70,8 @@ static inline void *igt_mmap64(void *addr, size_t length, int prot, int flags,
>   */
>  #define ALIGN(v, a) (((v) + (a)-1) & ~((a)-1))
>  
> +extern uint16_t __drm_device_id;
> +
>  int drm_get_card(void);
>  int __drm_open_any(void);
>  int drm_open_any(void);
> diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
> index fafd232..33177c6 100644
> --- a/lib/intel_chipset.c
> +++ b/lib/intel_chipset.c
> @@ -125,26 +125,15 @@ intel_get_pci_device(void)
>  uint32_t
>  intel_get_drm_devid(int fd)
>  {
> -       uint32_t devid = 0;
>         const char *override;
>  
> -       override = getenv("INTEL_DEVID_OVERRIDE");
> -       if (override) {
> -               devid = strtod(override, NULL);
> -       } else {
> -               struct drm_i915_getparam gp;
> -               int ret;
> -
> -               memset(&gp, 0, sizeof(gp));
> -               gp.param = I915_PARAM_CHIPSET_ID;
> -               gp.value = (int *)&devid;
> -
> -               ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
> -               igt_assert(ret == 0);
> -               errno = 0;
> -       }
> +       igt_assert(__drm_device_id);
>  
> -       return devid;
> +       override = getenv("INTEL_DEVID_OVERRIDE");
> +       if (override)
> +               return strtod(override, NULL);
> +       else
> +               return __drm_device_id;
>  }
>  
>  /**
> 
> -- 
> Chris Wilson, Intel Open Source Technology Centre

-- 
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

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

end of thread, other threads:[~2015-02-11  8:48 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 02/17] lib/ioctl: api polish for gem_context_has_param Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc Daniel Vetter
2015-02-10 21:58   ` Chris Wilson
2015-02-11  8:37     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 04/17] igt/ioctls: doc for gem_mmap Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible Daniel Vetter
2015-02-10 21:54   ` Chris Wilson
2015-02-11  8:42     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 06/17] lib/ioctl: Add gem_context_destroy helpers Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 07/17] tests/gem_ctx_*: Use helpers Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 08/17] tests/gem_reset_stat: Use new ctx helpers Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 09/17] lib/ioctl: Document ctx param functions Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 10/17] tests: Add gem_ctx_param_basic Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 11/17] tests: Add invalid pad tests for ctx create/destroy Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 12/17] tests/gem_ppgtt: Start rcs before bcs for context tests Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 13/17] tests: Align subtest with naming convention Daniel Vetter
2015-02-10 21:53   ` Chris Wilson
2015-02-11  8:44     ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 14/17] lib/igt_aux: s/swap/igt_swap/ Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 15/17] tests/gem_wait: Adjust makefile Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 16/17] doc: Consolidate naming conventions into docbook Daniel Vetter
2015-02-10 18:06 ` [PATCH i-g-t 17/17] lib/igt_gt: Document and consolidate Daniel Vetter
2015-02-10 21:36 ` [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Chris Wilson
2015-02-10 21:56   ` Daniel Vetter
2015-02-10 21:59   ` [PATCH i-g-t] lib/chipset: Cache devid Daniel Vetter
2015-02-10 22:28     ` Chris Wilson
2015-02-10 22:37       ` Daniel Vetter
2015-02-10 22:39         ` Daniel Vetter
2015-02-10 22:45           ` Daniel Vetter
2015-02-10 22:50             ` Chris Wilson
2015-02-11  8:49               ` Daniel Vetter

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