Skip to contentSkip to conversation

lib/gt: api polish for igt_can_hang_ring

PATCH In review Daniel Vetter 3 participants 32 messages Feb 10, 2015 – Feb 11, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/17 lib/gt: api polish for igt_can_hang_ring

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

---
 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(-)
lib/igt_gt.c +4 -8
index 526cbee03308..c003a7ca30f0 100644
@@ -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)
lib/igt_gt.h +1 -1
index 19bbcef2a91e..1ed78837cf5b 100644
@@ -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;
tests/gem_concurrent_blit.c +1 -1
index 726198012c14..245ad4581783 100644
@@ -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,
tests/gem_pread_after_blit.c +1 -1
index c09c8dc49ee0..6e4bd6257feb 100644
@@ -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);
 		}
 	}
tests/gem_reloc_vs_gpu.c +3 -5
index bb8615b6a593..68bd17d3ae5b 100644
@@ -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();
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/17 lib/ioctl: api polish for gem_context_has_param

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

---
 lib/igt_gt.c         | 2 +-
 lib/ioctl_wrappers.c | 4 ++--
 lib/ioctl_wrappers.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
lib/igt_gt.c +1 -1
index c003a7ca30f0..615f9893b876 100644
@@ -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);
 }
 
lib/ioctl_wrappers.c +2 -2
index 19a457ac2b34..dd89e2c57e7f 100644
@@ -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);
 }
lib/ioctl_wrappers.h +1 -1
index 30ab83628a04..a1017ecd3767 100644
@@ -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);
 
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/17 lib/ioctl: gem_ prefix for igt_require_mmap_wc

In reply to Daniel Vetter

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

---
 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(-)
lib/ioctl_wrappers.h +10 -1
index a1017ecd3767..8d8fa46d1942 100644
@@ -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:
tests/gem_concurrent_blit.c +2 -2
index 245ad4581783..cec6ea49f95c 100644
@@ -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)
tests/gem_fence_upload.c +1 -1
index 81f797b4ba86..9595bc822e59 100644
@@ -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);
tests/gem_mmap_wc.c +8 -8
index 87916b6e81c0..73a97d556927 100644
@@ -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);
tests/gem_tiled_wc.c +1 -1
index f705378173d7..b0f7a655a17a 100644
@@ -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);
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc

Quoted 1 line · Daniel Vetter

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

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc

Quoted 5 lines · Chris Wilson
Quoted 1 line · Daniel Vetter

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 4/17 igt/ioctls: doc for gem_mmap

In reply to 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.

---
 lib/ioctl_wrappers.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
lib/ioctl_wrappers.h +10 -1
index 8d8fa46d1942..663b3da2ecd4 100644
@@ -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);
 
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

PATCH 5/17 lib/ioctls: make gem_context_set/get_param infallible

In reply to Daniel Vetter

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

---
 lib/igt_gt.c         |  2 +-
 lib/ioctl_wrappers.c | 18 +++++-------------
 lib/ioctl_wrappers.h |  4 ++--
 3 files changed, 8 insertions(+), 16 deletions(-)
lib/igt_gt.c +1 -1
index 615f9893b876..e02219acc6fd 100644
@@ -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));
lib/ioctl_wrappers.c +5 -13
index dd89e2c57e7f..c8c0e1c16f8b 100644
@@ -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);
 }
lib/ioctl_wrappers.h +2 -2
index 663b3da2ecd4..23b8c9d56e44 100644
@@ -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 */
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

Re: [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible

Quoted 2 lines · Daniel Vetter

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

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

Re: [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible

Quoted 5 lines · Chris Wilson
Quoted 2 lines · Daniel Vetter

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH 6/17 lib/ioctl: Add gem_context_destroy helpers

In reply to Daniel Vetter

We also need a raw version for some tests.

---
 lib/ioctl_wrappers.c | 32 ++++++++++++++++++++++++++++++++
 lib/ioctl_wrappers.h |  2 ++
 2 files changed, 34 insertions(+)
lib/ioctl_wrappers.c +32 -0
index c8c0e1c16f8b..e86b3c2bfa46 100644
@@ -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
lib/ioctl_wrappers.h +2 -0
index 23b8c9d56e44..ad10bd03d370 100644
@@ -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);
 
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

PATCH 7/17 tests/gem_ctx_*: Use helpers

In reply to Daniel Vetter
---
 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(-)
tests/gem_ctx_bad_destroy.c +5 -20
index d848265c7802..368bf95f2fcb 100644
@@ -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);
 }
tests/gem_ctx_create.c +2 -9
index 522e7b1ca022..1c710fdebbf7 100644
@@ -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);
tests/gem_ctx_exec.c +4 -19
index 7a6ed9b1f1d2..ca5bf640adaf 100644
@@ -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);
 	}
 }
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

PATCH 8/17 tests/gem_reset_stat: Use new ctx helpers

In reply to 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.

---
 tests/gem_reset_stats.c | 117 +++++++++++-------------------------------------
 1 file changed, 27 insertions(+), 90 deletions(-)
tests/gem_reset_stats.c +27 -90
index 646d6dac052e..faa209c1d28a 100644
@@ -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);
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

PATCH 9/17 lib/ioctl: Document ctx param functions

In reply to Daniel Vetter

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

---
 lib/ioctl_wrappers.c | 79 +++++++++++++++++++++++++++++++++++-----------------
 lib/ioctl_wrappers.h | 22 +++++++--------
 2 files changed, 63 insertions(+), 38 deletions(-)
lib/ioctl_wrappers.c +53 -26
index e86b3c2bfa46..288ab8d7e0e2 100644
@@ -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);
-}
lib/ioctl_wrappers.h +10 -12
index ad10bd03d370..ea9f5598e7e3 100644
@@ -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 */
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

PATCH 10/17 tests: Add gem_ctx_param_basic

In reply to 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.

---
 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
tests/.gitignore +1 -0
index 88a6405394b2..7b4dd94722a2 100644
@@ -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
tests/Makefile.sources +1 -0
index 74deec3127fb..51e8376b24e6 100644
@@ -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 \
tests/gem_ctx_exec.c +2 -1
index ca5bf640adaf..ead3d463003a 100644
@@ -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);
tests/gem_ctx_param_basic. new file +172 -0

172 lines not on this page · raw message

tests/gem_ctx_param_basic.c new file +137 -0

137 lines not on this page · raw message

Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

PATCH 11/17 tests: Add invalid pad tests for ctx create/destroy

In reply to 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.

---
 tests/gem_ctx_bad_destroy.c | 48 +++++++++++++++++++++++++++++++--------------
 tests/gem_ctx_create.c      | 42 +++++++++++++++++++++++++++------------
 2 files changed, 63 insertions(+), 27 deletions(-)
tests/gem_ctx_bad_destroy.c +33 -15
index 368bf95f2fcb..ee89763870ef 100644
@@ -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);
 }
tests/gem_ctx_create.c +30 -12

52 lines not on this page · raw message

Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

PATCH 12/17 tests/gem_ppgtt: Start rcs before bcs for context tests

In reply to 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.

---
 tests/gem_ppgtt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/gem_ppgtt.c +1 -1
index 0ee4f5b2a31e..850c99ea4b8a 100644
@@ -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();
 
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

PATCH 13/17 tests: Align subtest with naming convention

In reply to Daniel Vetter

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

---
 tests/gem_concurrent_blit.c |  4 ++--
 tests/gem_ppgtt.c           |  4 ++--
 tests/kms_flip.c            | 16 ++++++++--------
 3 files changed, 12 insertions(+), 12 deletions(-)
tests/gem_concurrent_blit.c +2 -2
index cec6ea49f95c..0b0adce7892c 100644
@@ -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 {
tests/gem_ppgtt.c +2 -2
index 850c99ea4b8a..5bf773c25270 100644
@@ -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);
tests/kms_flip.c +8 -8
index 557bcd4ad3f6..292b7bc60f09 100644
@@ -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" },
 
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

Re: [PATCH i-g-t 13/17] tests: Align subtest with naming convention

Quoted 2 lines · Daniel Vetter

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

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#18 lore raw

Re: [PATCH i-g-t 13/17] tests: Align subtest with naming convention

Quoted 6 lines · Chris Wilson
Quoted 2 lines · Daniel Vetter

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

PATCH 14/17 lib/igt_aux: s/swap/igt_swap/

In reply to Daniel Vetter

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

---
 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(-)
lib/igt.cocci +2 -2
index fd4ad2564bea..41a8beb36029 100644
@@ -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()
 @@
lib/igt_aux.h +1 -1
index 798a5b45fcb9..edc36a221922 100644
@@ -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;		\
tests/eviction_common.c +1 -1
index 4a12dcbc345d..b18c2a73f9c7 100644
@@ -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,
tests/gem_ctx_thrash.c +2 -2
index 5c272338e795..b4818f4e6337 100644
@@ -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)
tests/gem_seqno_wrap.c +1 -1
index 42493efdb20e..d07ec96064eb 100644
@@ -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)
tests/gem_stress.c +1 -1
index 9f20bde2f45a..f687b2d1c795 100644
@@ -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)
tests/kms_flip.c +2 -2
index 292b7bc60f09..09dc3c794fdf 100644
@@ -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,
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#20 lore raw

PATCH 15/17 tests/gem_wait: Adjust makefile

In reply to Daniel Vetter

I've forgotten to do this in

commit e4753d2d96fbb88077e70820793137f45f02c9ba

Author: Daniel Vetter <[email protected]>
Date:   Mon Sep 29 14:42:33 2014 +0200

tests/gem_wait_render_timeout: Convert to subtests

---
 tests/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile.am +1 -1
index ec2bd301fac1..5efc8d8c0e0d 100644
@@ -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)
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#21 lore raw

PATCH 16/17 doc: Consolidate naming conventions into docbook

In reply to 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.

---
 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
CONTRIBUTING +1 -1
index 7c20fdb734ce..e2c352e78fa0 100644
@@ -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.
 
NEWS +12 -0
index 67146a3c50af..becf1b246852 100644
@@ -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)
 ------------------------
 
docs/reference/intel-gpu-tools/Makefile.am +1 -1
index 0a47764d8696..0f10eaab4d6a 100644
@@ -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 $@`
docs/reference/intel-gpu-tools/igt_test_programs.xml +7 -0
index 36ad1f358e04..bf8a939d6665 100644
@@ -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>
tests/NAMING-CONVENTION deleted +0 -71

71 lines not on this page · raw message

Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#22 lore raw

PATCH 17/17 lib/igt_gt: Document and consolidate

In reply to 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.

---
 .../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(-)
docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml +1 -0
index 9cfb836bb8bd..6c953fd6841f 100644
@@ -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"/>
lib/drmtest.c +1 -0
index 7cdef36655d0..1d6e882c0fea 100644
@@ -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"
lib/igt_aux.c +0 -68

74 lines not on this page · raw message

lib/igt_aux.h +0 -3
index edc36a221922..7f42b337f2ec 100644
@@ -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,
lib/igt_debugfs.c +0 -122

125 lines not on this page · raw message

lib/igt_debugfs.h +0 -35
index 8ac153966bc1..828502957a98 100644
@@ -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__ */
lib/igt_gt.c +238 -2

275 lines not on this page · raw message

lib/igt_gt.h +44 -2

56 lines not on this page · raw message

lib/intel_mmio.c +1 -1
index 5ff1ec1e6be7..9a2ee27bd5e5 100644
@@ -43,7 +43,7 @@
 
 #include "intel_io.h"
 #include "igt_core.h"
-#include "igt_debugfs.h"
+#include "igt_gt.h"
 #include "intel_chipset.h"
 
 /**
tests/drv_hangman.c +1 -1
index 15918ba63ba5..a882822b26b5 100644
@@ -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
tests/drv_suspend.c +1 -1
index 80f6a2254b75..d96f316a8eab 100644
@@ -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)
tests/gem_concurrent_blit.c +2 -2
index 0b0adce7892c..e1693ba76279 100644
@@ -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)
tests/gem_ctx_exec.c +1 -1
index ead3d463003a..43b38a2f5673 100644
@@ -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.");
 
tests/gem_evict_alignment.c +1 -0
index 0ec58099cad6..c0757705328d 100644
@@ -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.");
tests/gem_evict_everything.c +1 -0
index ad198f023ae5..15ab382a3427 100644
@@ -45,6 +45,7 @@
 #include "ioctl_wrappers.h"
 #include "drmtest.h"
 #include "intel_chipset.h"
+#include "igt_gt.h"
 
 #include "eviction_common.c"
 
tests/gem_pread_after_blit.c +1 -1
index 6e4bd6257feb..8ed431002172 100644
@@ -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,
tests/gem_reloc_vs_gpu.c +1 -1
index 68bd17d3ae5b..79f182b477b6 100644
@@ -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,
tests/gem_reset_stats.c +1 -1
index faa209c1d28a..d3cfe8b13960 100644
@@ -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"
tests/gem_workarounds.c +1 -1
index 7511a4306595..0e3613f34b64 100644
@@ -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"
tests/kms_flip.c +1 -1
index 09dc3c794fdf..b843478143a2 100644
@@ -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)
tests/kms_pipe_crc_basic.c +1 -1
index 7380c8a1ea31..a658b39df019 100644
@@ -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"
tests/pm_rpm.c +1 -1
index c120d75e4bb3..84254b79df53 100644
@@ -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
tests/pm_rps.c +1 -1
index f222c09daaf5..d6897881d2c6 100644
@@ -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;
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#23 lore raw
In reply to Daniel Vetter
Quoted 3 lines · Daniel Vetter

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

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#24 lore raw
Quoted 8 lines · Chris Wilson
Quoted 3 lines · Daniel Vetter

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#25 lore raw

PATCH 1/1 lib/chipset: Cache devid

In reply to Chris Wilson

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.

---
 lib/intel_chipset.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/intel_chipset.c +4 -1
index fafd232f89c0..64d66eb29bae 100644
@@ -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);
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#26 lore raw

Re: [PATCH i-g-t] lib/chipset: Cache devid

Quoted 6 lines · 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.

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

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#27 lore raw

Re: [PATCH i-g-t] lib/chipset: Cache devid

Quoted 9 lines · Chris Wilson
Quoted 6 lines · 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.

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#28 lore raw

Re: [PATCH i-g-t] lib/chipset: Cache devid

Quoted 6 lines · Daniel Vetter
Quoted 5 lines · Chris Wilson
Quoted 4 lines · 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.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#29 lore raw

Re: [PATCH i-g-t] lib/chipset: Cache devid

Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Chris Wilson
Quoted 6 lines · 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.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#30 lore raw

Re: [PATCH i-g-t] lib/chipset: Cache devid

Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Daniel Vetter
Quoted 13 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
Quoted 6 lines · 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.

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

Quoted 6 lines
Quoted 3 lines

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:

lib/drmtest.c +7 -1
index 7cdef36..4090a4a 100644
@@ -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)
lib/drmtest.h +2 -0
index 508cc83..fabf43e 100644
@@ -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);
lib/intel_chipset.c +6 -17
index fafd232..33177c6 100644
@@ -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;
 }
 
 /**
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#31 lore raw

Re: [PATCH i-g-t] lib/chipset: Cache devid

Quoted 17 lines · Chris Wilson
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Daniel Vetter
Quoted 13 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
Quoted 6 lines · 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.

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

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

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

Quoted 79 lines
lib/drmtest.c +7 -1
index 7cdef36..4090a4a 100644
@@ -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)
lib/drmtest.h +2 -0
index 508cc83..fabf43e 100644
@@ -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);
lib/intel_chipset.c +6 -17
index fafd232..33177c6 100644
@@ -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;
 }
 
 /**
Signature · 2 lines
-- 
Chris Wilson, Intel Open Source Technology Centre
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx