[igt-dev] [PATCH i-g-t v2 05/10] tests/i915/exec_fence: switch to internal headers

Lionel Landwerlin lionel.g.landwerlin at intel.com
Fri Nov 22 13:02:55 UTC 2019


Drop local defines etc..

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/gem_exec_fence.c | 122 ++++++++++++++++--------------------
 1 file changed, 55 insertions(+), 67 deletions(-)

diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c
index fbb11ab2..b8fa1a03 100644
--- a/tests/i915/gem_exec_fence.c
+++ b/tests/i915/gem_exec_fence.c
@@ -33,18 +33,6 @@
 
 IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences");
 
-#define LOCAL_EXEC_FENCE_IN (1 << 16)
-#define LOCAL_EXEC_FENCE_OUT (1 << 17)
-#define LOCAL_EXEC_FENCE_SUBMIT (1 << 20)
-
-#define LOCAL_EXEC_FENCE_ARRAY (1 << 19)
-struct local_gem_exec_fence {
-	uint32_t handle;
-	uint32_t flags;
-#define LOCAL_EXEC_FENCE_WAIT (1 << 0)
-#define LOCAL_EXEC_FENCE_SIGNAL (1 << 1)
-};
-
 #ifndef SYNC_IOC_MERGE
 struct sync_merge_data {
 	char    name[32];
@@ -71,7 +59,7 @@ static void store(int fd, unsigned ring, int fence, uint32_t target, unsigned of
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(obj);
 	execbuf.buffer_count = 2;
-	execbuf.flags = ring | LOCAL_EXEC_FENCE_IN;
+	execbuf.flags = ring | I915_EXEC_FENCE_IN;
 	execbuf.rsvd2 = fence;
 	if (gen < 6)
 		execbuf.flags |= I915_EXEC_SECURE;
@@ -137,7 +125,7 @@ static void test_fence_busy(int fd, unsigned ring, unsigned flags)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = ring | LOCAL_EXEC_FENCE_OUT;
+	execbuf.flags = ring | I915_EXEC_FENCE_OUT;
 
 	memset(&obj, 0, sizeof(obj));
 	obj.handle = gem_create(fd, 4096);
@@ -270,7 +258,7 @@ static void test_fence_busy_all(int fd, unsigned flags)
 
 		if ((flags & HANG) == 0)
 			igt_require(gem_engine_has_mutable_submission(fd, eb_ring(e)));
-		execbuf.flags = eb_ring(e) | LOCAL_EXEC_FENCE_OUT;
+		execbuf.flags = eb_ring(e) | I915_EXEC_FENCE_OUT;
 		execbuf.rsvd2 = -1;
 		gem_execbuf_wr(fd, &execbuf);
 		fence = execbuf.rsvd2 >> 32;
@@ -435,7 +423,7 @@ static void test_parallel(int fd, unsigned int master)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(obj);
 	execbuf.buffer_count = 2;
-	execbuf.flags = master | LOCAL_EXEC_FENCE_OUT;
+	execbuf.flags = master | I915_EXEC_FENCE_OUT;
 	if (gen < 6)
 		execbuf.flags |= I915_EXEC_SECURE;
 
@@ -508,7 +496,7 @@ static void test_parallel(int fd, unsigned int master)
 		if (eb_ring(e) == master)
 			continue;
 
-		execbuf.flags = eb_ring(e) | LOCAL_EXEC_FENCE_SUBMIT;
+		execbuf.flags = eb_ring(e) | I915_EXEC_FENCE_SUBMIT;
 		if (gen < 6)
 			execbuf.flags |= I915_EXEC_SECURE;
 
@@ -604,7 +592,7 @@ static void test_keep_in_fence(int fd, unsigned int engine, unsigned int flags)
 	struct drm_i915_gem_execbuffer2 execbuf = {
 		.buffers_ptr = to_user_pointer(&obj),
 		.buffer_count = 1,
-		.flags = engine | LOCAL_EXEC_FENCE_OUT,
+		.flags = engine | I915_EXEC_FENCE_OUT,
 	};
 	unsigned long count, last;
 	struct itimerval itv;
@@ -623,7 +611,7 @@ static void test_keep_in_fence(int fd, unsigned int engine, unsigned int flags)
 	itv.it_value.tv_usec = 10000;
 	setitimer(ITIMER_REAL, &itv, NULL);
 
-	execbuf.flags |= LOCAL_EXEC_FENCE_IN;
+	execbuf.flags |= I915_EXEC_FENCE_IN;
 	execbuf.rsvd2 = fence;
 
 	last = -1;
@@ -692,7 +680,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj[1]);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_OUT;
+	execbuf.flags = I915_EXEC_FENCE_OUT;
 
 	gem_execbuf_wr(fd, &execbuf);
 	all_fences = execbuf.rsvd2 >> 32;
@@ -708,7 +696,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)
 		for (n = 0; n < nengine; n++) {
 			struct sync_merge_data merge;
 
-			execbuf.flags = engines[n] | LOCAL_EXEC_FENCE_OUT;
+			execbuf.flags = engines[n] | I915_EXEC_FENCE_OUT;
 			if (__gem_execbuf_wr(fd, &execbuf))
 				continue;
 
@@ -742,7 +730,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)
 
 	for (s = 0; s < ring_size; s++) {
 		for (n = 0; n < nengine; n++) {
-			execbuf.flags = engines[n] | LOCAL_EXEC_FENCE_IN;
+			execbuf.flags = engines[n] | I915_EXEC_FENCE_IN;
 			if (__gem_execbuf_wr(fd, &execbuf))
 				continue;
 		}
@@ -766,7 +754,7 @@ static bool has_submit_fence(int fd)
 	int value = 0;
 
 	memset(&gp, 0, sizeof(gp));
-	gp.param = 0xdeadbeef ^ 51; /* I915_PARAM_HAS_EXEC_SUBMIT_FENCE */
+	gp.param = 0xdeadbeef ^ I915_PARAM_HAS_EXEC_SUBMIT_FENCE;
 	gp.value = &value;
 
 	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
@@ -777,7 +765,7 @@ static bool has_submit_fence(int fd)
 
 static bool has_syncobj(int fd)
 {
-	struct drm_get_cap cap = { .capability = 0x13 };
+	struct drm_get_cap cap = { .capability = DRM_CAP_SYNCOBJ };
 	ioctl(fd, DRM_IOCTL_GET_CAP, &cap);
 	return cap.value;
 }
@@ -788,7 +776,7 @@ static bool exec_has_fence_array(int fd)
 	int value = 0;
 
 	memset(&gp, 0, sizeof(gp));
-	gp.param = 49; /* I915_PARAM_HAS_EXEC_FENCE_ARRAY */
+	gp.param = I915_PARAM_HAS_EXEC_FENCE_ARRAY;
 	gp.value = &value;
 
 	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
@@ -802,7 +790,7 @@ static void test_invalid_fence_array(int fd)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 obj;
-	struct local_gem_exec_fence fence;
+	struct drm_i915_gem_exec_fence fence;
 	void *ptr;
 
 	/* create an otherwise valid execbuf */
@@ -814,7 +802,7 @@ static void test_invalid_fence_array(int fd)
 	execbuf.buffer_count = 1;
 	gem_execbuf(fd, &execbuf);
 
-	execbuf.flags |= LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.flags |= I915_EXEC_FENCE_ARRAY;
 	gem_execbuf(fd, &execbuf);
 
 	/* Now add a few invalid fence-array pointers */
@@ -1026,7 +1014,7 @@ static void test_syncobj_unused_fence(int fd)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj;
 	struct drm_i915_gem_execbuffer2 execbuf;
-	struct local_gem_exec_fence fence = {
+	struct drm_i915_gem_exec_fence fence = {
 		.handle = syncobj_create(fd),
 	};
 	igt_spin_t *spin = igt_spin_new(fd);
@@ -1037,7 +1025,7 @@ static void test_syncobj_unused_fence(int fd)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.flags = I915_EXEC_FENCE_ARRAY;
 	execbuf.cliprects_ptr = to_user_pointer(&fence);
 	execbuf.num_cliprects = 1;
 
@@ -1062,14 +1050,14 @@ static void test_syncobj_invalid_wait(int fd)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj;
 	struct drm_i915_gem_execbuffer2 execbuf;
-	struct local_gem_exec_fence fence = {
+	struct drm_i915_gem_exec_fence fence = {
 		.handle = syncobj_create(fd),
 	};
 
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.flags = I915_EXEC_FENCE_ARRAY;
 	execbuf.cliprects_ptr = to_user_pointer(&fence);
 	execbuf.num_cliprects = 1;
 
@@ -1078,7 +1066,7 @@ static void test_syncobj_invalid_wait(int fd)
 	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
 
 	/* waiting before the fence is set is invalid */
-	fence.flags = LOCAL_EXEC_FENCE_WAIT;
+	fence.flags = I915_EXEC_FENCE_WAIT;
 	igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL);
 
 	gem_close(fd, obj.handle);
@@ -1090,14 +1078,14 @@ static void test_syncobj_invalid_flags(int fd)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj;
 	struct drm_i915_gem_execbuffer2 execbuf;
-	struct local_gem_exec_fence fence = {
+	struct drm_i915_gem_exec_fence fence = {
 		.handle = syncobj_create(fd),
 	};
 
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.flags = I915_EXEC_FENCE_ARRAY;
 	execbuf.cliprects_ptr = to_user_pointer(&fence);
 	execbuf.num_cliprects = 1;
 
@@ -1118,7 +1106,7 @@ static void test_syncobj_signal(int fd)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj;
 	struct drm_i915_gem_execbuffer2 execbuf;
-	struct local_gem_exec_fence fence = {
+	struct drm_i915_gem_exec_fence fence = {
 		.handle = syncobj_create(fd),
 	};
 	igt_spin_t *spin = igt_spin_new(fd);
@@ -1128,7 +1116,7 @@ static void test_syncobj_signal(int fd)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.flags = I915_EXEC_FENCE_ARRAY;
 	execbuf.cliprects_ptr = to_user_pointer(&fence);
 	execbuf.num_cliprects = 1;
 
@@ -1136,7 +1124,7 @@ static void test_syncobj_signal(int fd)
 	obj.handle = gem_create(fd, 4096);
 	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
 
-	fence.flags = LOCAL_EXEC_FENCE_SIGNAL;
+	fence.flags = I915_EXEC_FENCE_SIGNAL;
 	gem_execbuf(fd, &execbuf);
 
 	igt_assert(gem_bo_busy(fd, obj.handle));
@@ -1157,7 +1145,7 @@ static void test_syncobj_wait(int fd)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj;
 	struct drm_i915_gem_execbuffer2 execbuf;
-	struct local_gem_exec_fence fence = {
+	struct drm_i915_gem_exec_fence fence = {
 		.handle = syncobj_create(fd),
 	};
 	igt_spin_t *spin;
@@ -1181,10 +1169,10 @@ static void test_syncobj_wait(int fd)
 	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
 
 	/* Queue a signaler from the blocked engine */
-	execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.flags = I915_EXEC_FENCE_ARRAY;
 	execbuf.cliprects_ptr = to_user_pointer(&fence);
 	execbuf.num_cliprects = 1;
-	fence.flags = LOCAL_EXEC_FENCE_SIGNAL;
+	fence.flags = I915_EXEC_FENCE_SIGNAL;
 	gem_execbuf(fd, &execbuf);
 	igt_assert(gem_bo_busy(fd, spin->handle));
 
@@ -1209,10 +1197,10 @@ static void test_syncobj_wait(int fd)
 		igt_assert(gem_bo_busy(fd, spin->handle));
 
 		/* Now wait upon the blocked engine */
-		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY | eb_ring(e);
+		execbuf.flags = I915_EXEC_FENCE_ARRAY | eb_ring(e);
 		execbuf.cliprects_ptr = to_user_pointer(&fence);
 		execbuf.num_cliprects = 1;
-		fence.flags = LOCAL_EXEC_FENCE_WAIT;
+		fence.flags = I915_EXEC_FENCE_WAIT;
 		gem_execbuf(fd, &execbuf);
 
 		igt_assert(gem_bo_busy(fd, obj.handle));
@@ -1236,7 +1224,7 @@ static void test_syncobj_export(int fd)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj;
 	struct drm_i915_gem_execbuffer2 execbuf;
-	struct local_gem_exec_fence fence = {
+	struct drm_i915_gem_exec_fence fence = {
 		.handle = syncobj_create(fd),
 	};
 	int export[2];
@@ -1253,7 +1241,7 @@ static void test_syncobj_export(int fd)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.flags = I915_EXEC_FENCE_ARRAY;
 	execbuf.cliprects_ptr = to_user_pointer(&fence);
 	execbuf.num_cliprects = 1;
 
@@ -1261,7 +1249,7 @@ static void test_syncobj_export(int fd)
 	obj.handle = gem_create(fd, 4096);
 	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
 
-	fence.flags = LOCAL_EXEC_FENCE_SIGNAL;
+	fence.flags = I915_EXEC_FENCE_SIGNAL;
 	gem_execbuf(fd, &execbuf);
 
 	igt_assert(syncobj_busy(fd, fence.handle));
@@ -1296,7 +1284,7 @@ static void test_syncobj_repeat(int fd)
 	const unsigned nfences = 4096;
 	struct drm_i915_gem_exec_object2 obj;
 	struct drm_i915_gem_execbuffer2 execbuf;
-	struct local_gem_exec_fence *fence;
+	struct drm_i915_gem_exec_fence *fence;
 	int export;
 	igt_spin_t *spin = igt_spin_new(fd);
 
@@ -1311,7 +1299,7 @@ static void test_syncobj_repeat(int fd)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.flags = I915_EXEC_FENCE_ARRAY;
 	execbuf.cliprects_ptr = to_user_pointer(fence);
 	execbuf.num_cliprects = nfences;
 
@@ -1320,13 +1308,13 @@ static void test_syncobj_repeat(int fd)
 	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
 
 	for (int i = 0; i < nfences; i++)
-		fence[i].flags = LOCAL_EXEC_FENCE_SIGNAL;
+		fence[i].flags = I915_EXEC_FENCE_SIGNAL;
 
 	gem_execbuf(fd, &execbuf);
 
 	for (int i = 0; i < nfences; i++) {
 		igt_assert(syncobj_busy(fd, fence[i].handle));
-		fence[i].flags |= LOCAL_EXEC_FENCE_WAIT;
+		fence[i].flags |= I915_EXEC_FENCE_WAIT;
 	}
 	igt_assert(gem_bo_busy(fd, obj.handle));
 
@@ -1364,7 +1352,7 @@ static void test_syncobj_import(int fd)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_OUT;
+	execbuf.flags = I915_EXEC_FENCE_OUT;
 	execbuf.rsvd2 = -1;
 
 	memset(&obj, 0, sizeof(obj));
@@ -1409,7 +1397,7 @@ static void test_syncobj_channel(int fd)
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
 	execbuf.buffer_count = 1;
-	execbuf.flags = LOCAL_EXEC_FENCE_OUT;
+	execbuf.flags = I915_EXEC_FENCE_OUT;
 	execbuf.rsvd2 = -1;
 
 	memset(&obj, 0, sizeof(obj));
@@ -1417,15 +1405,15 @@ static void test_syncobj_channel(int fd)
 	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
 
 	for (int i = 0; i < ARRAY_SIZE(syncobj); i++) {
-		struct local_gem_exec_fence fence;
+		struct drm_i915_gem_exec_fence fence;
 
-		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+		execbuf.flags = I915_EXEC_FENCE_ARRAY;
 		execbuf.cliprects_ptr = to_user_pointer(&fence);
 		execbuf.num_cliprects = 1;
 
 		/* Create a primed fence */
 		fence.handle = syncobj_create(fd);
-		fence.flags = LOCAL_EXEC_FENCE_SIGNAL;
+		fence.flags = I915_EXEC_FENCE_SIGNAL;
 
 		gem_execbuf(fd, &execbuf);
 
@@ -1434,21 +1422,21 @@ static void test_syncobj_channel(int fd)
 
 	/* Two processes in ping-pong unison (pipe), one out of sync */
 	igt_fork(child, 1) {
-		struct local_gem_exec_fence fence[3];
+		struct drm_i915_gem_exec_fence fence[3];
 		unsigned long count;
 
-		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+		execbuf.flags = I915_EXEC_FENCE_ARRAY;
 		execbuf.cliprects_ptr = to_user_pointer(fence);
 		execbuf.num_cliprects = 3;
 
 		fence[0].handle = syncobj[0];
-		fence[0].flags = LOCAL_EXEC_FENCE_SIGNAL;
+		fence[0].flags = I915_EXEC_FENCE_SIGNAL;
 
 		fence[1].handle = syncobj[1];
-		fence[1].flags = LOCAL_EXEC_FENCE_WAIT;
+		fence[1].flags = I915_EXEC_FENCE_WAIT;
 
 		fence[2].handle = syncobj[2];
-		fence[2].flags = LOCAL_EXEC_FENCE_WAIT;
+		fence[2].flags = I915_EXEC_FENCE_WAIT;
 
 		count = 0;
 		while (!*(volatile unsigned *)control) {
@@ -1459,21 +1447,21 @@ static void test_syncobj_channel(int fd)
 		control[1] = count;
 	}
 	igt_fork(child, 1) {
-		struct local_gem_exec_fence fence[3];
+		struct drm_i915_gem_exec_fence fence[3];
 		unsigned long count;
 
-		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+		execbuf.flags = I915_EXEC_FENCE_ARRAY;
 		execbuf.cliprects_ptr = to_user_pointer(fence);
 		execbuf.num_cliprects = 3;
 
 		fence[0].handle = syncobj[0];
-		fence[0].flags = LOCAL_EXEC_FENCE_WAIT;
+		fence[0].flags = I915_EXEC_FENCE_WAIT;
 
 		fence[1].handle = syncobj[1];
-		fence[1].flags = LOCAL_EXEC_FENCE_SIGNAL;
+		fence[1].flags = I915_EXEC_FENCE_SIGNAL;
 
 		fence[2].handle = syncobj[2];
-		fence[2].flags = LOCAL_EXEC_FENCE_WAIT;
+		fence[2].flags = I915_EXEC_FENCE_WAIT;
 
 		count = 0;
 		while (!*(volatile unsigned *)control) {
@@ -1483,15 +1471,15 @@ static void test_syncobj_channel(int fd)
 		control[2] = count;
 	}
 	igt_fork(child, 1) {
-		struct local_gem_exec_fence fence;
+		struct drm_i915_gem_exec_fence fence;
 		unsigned long count;
 
-		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+		execbuf.flags = I915_EXEC_FENCE_ARRAY;
 		execbuf.cliprects_ptr = to_user_pointer(&fence);
 		execbuf.num_cliprects = 1;
 
 		fence.handle = syncobj[2];
-		fence.flags = LOCAL_EXEC_FENCE_SIGNAL;
+		fence.flags = I915_EXEC_FENCE_SIGNAL;
 
 		count = 0;
 		while (!*(volatile unsigned *)control) {
-- 
2.24.0



More information about the igt-dev mailing list