Skip to contentSkip to conversation

igt: Use lib gem_execbuf where possible

PATCH Superseded Antonio Argenziano 4 participants 7 messages Feb 9, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igt: Use lib gem_execbuf where possible

Replace custom execbuf ioctl wrapper with the ones in lib.

Cc Chris Wilson <[email protected]>
Cc Petri Latvala <[email protected]>
---
 tests/gem_busy.c                 |  7 +------
 tests/gem_close_race.c           |  3 +--
 tests/gem_ctx_exec.c             | 15 +++++----------
 tests/gem_evict_alignment.c      |  7 ++-----
 tests/gem_exec_await.c           |  7 +------
 tests/gem_exec_bad_domains.c     |  6 +-----
 tests/gem_exec_blt.c             |  4 ++--
 tests/gem_exec_fence.c           |  7 +------
 tests/gem_exec_latency.c         |  7 +------
 tests/gem_exec_lut_handle.c      |  2 +-
 tests/gem_exec_params.c          |  9 ++-------
 tests/gem_exec_schedule.c        | 16 ++++------------
 tests/gem_gtt_hog.c              |  2 +-
 tests/gem_lut_handle.c           | 11 ++---------
 tests/gem_pwrite_pread.c         | 12 ++++++------
 tests/gem_ringfill.c             |  7 +------
 tests/gen3_mixed_blits.c         | 10 +++++-----
 tests/gen3_render_linear_blits.c |  6 +++---
 tests/gen3_render_mixed_blits.c  |  6 +++---
 tests/gen3_render_tiledx_blits.c |  4 ++--
 tests/gen3_render_tiledy_blits.c |  6 +++---
 tests/pm_rpm.c                   |  6 +++---
 22 files changed, 51 insertions(+), 109 deletions(-)
tests/gem_busy.c +1 -6
index c349c291..444c1dd1 100644
@@ -332,11 +332,6 @@ static void alarm_handler(int sig)
 {
 }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
 static unsigned int measure_ring_size(int fd)
 {
 	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -373,7 +368,7 @@ static unsigned int measure_ring_size(int fd)
 	last = -1;
 	count = 0;
 	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
 			count++;
 			continue;
 		}
tests/gem_close_race.c +1 -2
index d9a45387..bc1127b1 100644
@@ -119,8 +119,7 @@ static void selfcopy(int fd, uint32_t handle, int loops)
 	gem_pwrite.size = sizeof(buf);
 	gem_pwrite.data_ptr = to_user_pointer(buf);
 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite) == 0) {
-		while (loops-- &&
-		       drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0)
+		while (loops-- && __gem_execbuf(fd, &execbuf) == 0)
 			;
 	}
 
tests/gem_ctx_exec.c +5 -10
index fa864a21..1f8ed64d 100644
@@ -52,7 +52,6 @@ static int exec(int fd, uint32_t handle, int ring, int ctx_id)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 gem_exec;
-	int ret = 0;
 
 	gem_exec.handle = handle;
 	gem_exec.relocation_count = 0;
@@ -75,10 +74,7 @@ static int exec(int fd, uint32_t handle, int ring, int ctx_id)
 	i915_execbuffer2_set_context_id(execbuf, ctx_id);
 	execbuf.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2,
-			&execbuf);
-
-	return ret;
+	return __gem_execbuf(fd, &execbuf);
 }
 
 static void big_exec(int fd, uint32_t handle, int ring)
@@ -116,7 +112,7 @@ static void big_exec(int fd, uint32_t handle, int ring)
 
 	execbuf.buffer_count = 1;
 	i915_execbuffer2_set_context_id(execbuf, ctx_id1);
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
 
 	for (i = 0; i < num_buffers; i++) {
 		uint32_t tmp_handle = gem_create(fd, 4096);
@@ -127,8 +123,7 @@ static void big_exec(int fd, uint32_t handle, int ring)
 	execbuf.buffer_count = i + 1;
 
 	/* figure out how many buffers we can exactly fit */
-	while (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2,
-			&execbuf) != 0) {
+	while (__gem_execbuf(fd, &execbuf) != 0) {
 		i--;
 		gem_close(fd, gem_exec[i].handle);
 		gem_exec[i].handle = handle;
@@ -140,10 +135,10 @@ static void big_exec(int fd, uint32_t handle, int ring)
 	       i - 1, num_buffers);
 
 	/* double check that it works */
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
 
 	i915_execbuffer2_set_context_id(execbuf, ctx_id2);
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
 	gem_sync(fd, handle);
 }
 
tests/gem_evict_alignment.c +2 -5
index 239be728..a80aa414 100644
@@ -61,7 +61,7 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo,
 	struct drm_i915_gem_exec_object2 *obj;
 	struct drm_i915_gem_execbuffer2 exec;
 	uint32_t handle;
-	int n, ret, i=0;
+	int n, i=0;
 
 	batch[i++] = (XY_SRC_COPY_BLT_CMD |
 		    XY_SRC_COPY_BLT_WRITE_ALPHA |
@@ -121,10 +121,7 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo,
 	i915_execbuffer2_set_context_id(exec, 0);
 	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	if (ret)
-		ret = errno;
-	igt_assert_eq(ret, error);
+	igt_assert_eq(__gem_execbuf(fd, &exec), error);
 
 	gem_close(fd, handle);
 	free(obj);
tests/gem_exec_await.c +1 -6
index e19363c4..c1ff7b7e 100644
@@ -270,11 +270,6 @@ static void alarm_handler(int sig)
 {
 }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
 static unsigned int measure_ring_size(int fd)
 {
 	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -305,7 +300,7 @@ static unsigned int measure_ring_size(int fd)
 
 	last = count = 0;
 	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
 			count++;
 			continue;
 		}
tests/gem_exec_bad_domains.c +1 -5
index 9a7487e3..cd2c8956 100644
@@ -95,7 +95,6 @@ static void multi_write_domain(int fd)
 	struct drm_i915_gem_exec_object2 exec[2];
 	struct drm_i915_gem_relocation_entry reloc[1];
 	uint32_t handle, handle_target;
-	int ret;
 
 	handle = gem_create(fd, 4096);
 	handle_target = gem_create(fd, 4096);
@@ -137,10 +136,7 @@ static void multi_write_domain(int fd)
 	i915_execbuffer2_set_context_id(execbuf, 0);
 	execbuf.rsvd2 = 0;
 
-	ret = drmIoctl(fd,
-		       DRM_IOCTL_I915_GEM_EXECBUFFER2,
-		       &execbuf);
-	igt_assert(ret != 0 && errno == EINVAL);
+	igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL);
 
 	gem_close(fd, handle);
 	gem_close(fd, handle_target);
tests/gem_exec_blt.c +2 -2
index 8c0453f6..8d61dc87 100644
@@ -228,12 +228,12 @@ static void run(int object_size, bool dumb)
 	execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
 	execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
 
-	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf)) {
+	if (__gem_execbuf(fd, &execbuf)) {
 		len = gem_linear_blt(fd, buf, src, dst, object_size, reloc);
 		igt_assert(len == execbuf.batch_len);
 		gem_write(fd, handle, 0, buf, len);
 		execbuf.flags = ring;
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(fd, &execbuf);
 	}
 	gem_sync(fd, handle);
 
tests/gem_exec_fence.c +1 -6
index bd7b1263..460e0d44 100644
@@ -355,11 +355,6 @@ static void alarm_handler(int sig)
 {
 }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
 static unsigned int measure_ring_size(int fd)
 {
 	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -396,7 +391,7 @@ static unsigned int measure_ring_size(int fd)
 	last = -1;
 	count = 0;
 	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
 			count++;
 			continue;
 		}
tests/gem_exec_latency.c +1 -6
index 74044bf4..0c783494 100644
@@ -96,11 +96,6 @@ static void set_timeout(int seconds)
 	alarm(seconds);
 }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
 static unsigned int measure_ring_size(int fd)
 {
 	struct drm_i915_gem_exec_object2 obj[2];
@@ -122,7 +117,7 @@ static unsigned int measure_ring_size(int fd)
 
 	count = 0;
 	set_timeout(1);
-	while (__execbuf(fd, &execbuf) == 0)
+	while (__gem_execbuf(fd, &execbuf) == 0)
 		count++;
 	set_timeout(0);
 
tests/gem_exec_lut_handle.c +1 -1
index 9793133c..98e6ae5a 100644
@@ -77,7 +77,7 @@ static int has_exec_lut(int fd)
 	execbuf.buffer_count = 1;
 	execbuf.flags = LOCAL_I915_EXEC_HANDLE_LUT;
 
-	return drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0;
+	return __gem_execbuf(fd, &execbuf) == 0;
 }
 
 #define ELAPSED(a,b) (1e6*((b)->tv_sec - (a)->tv_sec) + ((b)->tv_usec - (a)->tv_usec))
tests/gem_exec_params.c +2 -7
index c3dc0ac2..5909bc93 100644
@@ -233,10 +233,7 @@ igt_main
 	}
 
 #define RUN_FAIL(expected_errno) do { \
-		igt_assert(drmIoctl(fd, \
-				    DRM_IOCTL_I915_GEM_EXECBUFFER2, \
-				    &execbuf) == -1); \
-		igt_assert_eq(errno, expected_errno); \
+		igt_assert_eq(errno, __gem_execbuf(fd, &execbuf)); \
 	} while(0)
 
 	igt_subtest("no-bsd") {
@@ -350,9 +347,7 @@ igt_main
 		RUN_FAIL(EPERM);
 
 		igt_device_set_master(fd);
-		igt_assert(drmIoctl(fd,
-				    DRM_IOCTL_I915_GEM_EXECBUFFER2,
-				    &execbuf) == 0);
+		gem_execbuf(fd, &execbuf);
 
 		igt_device_drop_master(fd); /* Only needs temporary master */
 	}
tests/gem_exec_schedule.c +4 -12
index aeb7610b..b61e432d 100644
@@ -646,14 +646,6 @@ static void alarm_handler(int sig)
 {
 }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	int err = 0;
-	if (ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf))
-		err = -errno;
-	return err;
-}
-
 static unsigned int measure_ring_size(int fd, unsigned int ring)
 {
 	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -692,7 +684,7 @@ static unsigned int measure_ring_size(int fd, unsigned int ring)
 	last = -1;
 	count = 0;
 	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
 			count++;
 			continue;
 		}
@@ -922,7 +914,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 	last = -1;
 	count = 0;
 	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
 			count++;
 			continue;
 		}
@@ -962,7 +954,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 		 * able to add ourselves to *our* ring without interruption.
 		 */
 		igt_debug("HP child executing\n");
-		result[2] = __execbuf(fd, &execbuf) == 0;
+		result[2] = __gem_execbuf(fd, &execbuf) == 0;
 		gem_context_destroy(fd, execbuf.rsvd1);
 	}
 
@@ -976,7 +968,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 	itv.it_value.tv_usec = 50000;
 	setitimer(ITIMER_REAL, &itv, NULL);
 	igt_debug("LP parent executing\n");
-	igt_assert_eq(__execbuf(fd, &execbuf), -EINTR);
+	igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINTR);
 	igt_assert_f(result[1], "Child was not released!\n");
 	igt_assert_f(result[2],
 		     "High priority child unable to submit within 10ms\n");
tests/gem_gtt_hog.c +1 -1
index a3dbfad4..ca730649 100644
@@ -113,7 +113,7 @@ static void busy(data_t *data, uint32_t handle, int size, int loops)
 	gem_pwrite.data_ptr = to_user_pointer(buf);
 	if (drmIoctl(data->fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite) == 0) {
 		while (loops--)
-			drmIoctl(data->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+			gem_execbuf(data->fd, &execbuf);
 	}
 
 	drmIoctl(data->fd, DRM_IOCTL_GEM_CLOSE, &create.handle);
tests/gem_lut_handle.c +2 -9
index 10516b4f..27758f39 100644
@@ -84,12 +84,7 @@ static int exec(int fd, uint32_t handle, unsigned int flags)
 	i915_execbuffer2_set_context_id(execbuf, 0);
 	execbuf.rsvd2 = 0;
 
-	if (drmIoctl(fd,
-		     DRM_IOCTL_I915_GEM_EXECBUFFER2,
-		     &execbuf))
-		return -errno;
-
-	return 0;
+	return __gem_execbuf(fd, &execbuf);
 }
 
 static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsigned flags)
@@ -156,9 +151,7 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsign
 	i915_execbuffer2_set_context_id(execbuf, 0);
 	execbuf.rsvd2 = 0;
 
-	ret = drmIoctl(fd,
-		       DRM_IOCTL_I915_GEM_EXECBUFFER2,
-		       &execbuf);
+	ret = __gem_execbuf(fd, &execbuf);
 	if (ret < 0)
 		ret = -errno;
 
tests/gem_pwrite_pread.c +6 -6
index e1543f22..383a57f7 100644
@@ -100,7 +100,7 @@ static void copy(int fd, uint32_t src, uint32_t dst, void *buf, int len, int loo
 
 	while (loops--) {
 		gem_write(fd, src, 0, buf, len);
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(fd, &execbuf);
 		gem_read(fd, dst, 0, buf, len);
 	}
 
@@ -120,7 +120,7 @@ static void as_gtt_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len,
 			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 		memcpy(src_ptr, buf, len);
 
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(fd, &execbuf);
 		gem_set_domain(fd, dst,
 			       I915_GEM_DOMAIN_GTT, 0);
 		memcpy(buf, dst_ptr, len);
@@ -145,7 +145,7 @@ static void as_cpu_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len,
 			       I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
 		memcpy(src_ptr, buf, len);
 
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(fd, &execbuf);
 		gem_set_domain(fd, dst,
 			       I915_GEM_DOMAIN_CPU, 0);
 		memcpy(buf, dst_ptr, len);
@@ -167,7 +167,7 @@ static void test_copy(int fd, uint32_t src, uint32_t dst, uint32_t *buf, int len
 	gem_write(fd, src, 0, buf, len);
 	memset(buf, 0, len);
 
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
 	gem_read(fd, dst, 0, buf, len);
 
 	gem_close(fd, exec[2].handle);
@@ -189,7 +189,7 @@ static void test_as_gtt_mmap(int fd, uint32_t src, uint32_t dst, int len)
 	for (i = 0; i < len/4; i++)
 		src_ptr[i] = i;
 
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
 	gem_close(fd, exec[2].handle);
 
 	gem_set_domain(fd, dst, I915_GEM_DOMAIN_GTT, 0);
@@ -213,7 +213,7 @@ static void test_as_cpu_mmap(int fd, uint32_t src, uint32_t dst, int len)
 	for (i = 0; i < len/4; i++)
 		src_ptr[i] = i;
 
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
 	gem_close(fd, exec[2].handle);
 
 	gem_set_domain(fd, dst, I915_GEM_DOMAIN_CPU, 0);
tests/gem_ringfill.c +1 -6
index c3376a67..c51c3911 100644
@@ -270,11 +270,6 @@ static void alarm_handler(int sig)
 {
 }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
 static unsigned int measure_ring_size(int fd)
 {
 	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -311,7 +306,7 @@ static unsigned int measure_ring_size(int fd)
 	last = -1;
 	count = 0;
 	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
 			count++;
 			continue;
 		}
tests/gen3_mixed_blits.c +5 -5
index 1159b4eb..147b7b87 100644
@@ -310,10 +310,10 @@ render_copy(int fd,
 	i915_execbuffer2_set_context_id(exec, 0);
 	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	while (ret && errno == EBUSY) {
+	ret = __gem_execbuf(fd, &exec);
+	while (ret == EBUSY) {
 		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
 	}
 	igt_assert_eq(ret, 0);
 
@@ -388,10 +388,10 @@ static void blt_copy(int fd, uint32_t dst, uint32_t src)
 	i915_execbuffer2_set_context_id(exec, 0);
 	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+	ret = __gem_execbuf(fd, &exec);
 	while (ret && errno == EBUSY) {
 		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
 	}
 	igt_assert_eq(ret, 0);
 
tests/gen3_render_linear_blits.c +3 -3
index e56bff93..980a1eed 100644
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)
 	i915_execbuffer2_set_context_id(exec, 0);
 	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	while (ret && errno == EBUSY) {
+	ret = __gem_execbuf(fd, &exec);
+	while (ret == EBUSY) {
 		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
 	}
 	igt_assert_eq(ret, 0);
 
tests/gen3_render_mixed_blits.c +3 -3
index 6cc8d056..7dab181d 100644
@@ -293,10 +293,10 @@ copy(int fd,
 	i915_execbuffer2_set_context_id(exec, 0);
 	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	while (ret && errno == EBUSY) {
+	ret = __gem_execbuf(fd, &exec);
+	while (ret == EBUSY) {
 		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
 	}
 	igt_assert_eq(ret, 0);
 
tests/gen3_render_tiledx_blits.c +2 -2
index 6706d3a3..b7a632fa 100644
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)
 	i915_execbuffer2_set_context_id(exec, 0);
 	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+	ret = __gem_execbuf(fd, &exec);
 	while (ret && errno == EBUSY) {
 		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
 	}
 	igt_assert_eq(ret, 0);
 
tests/gen3_render_tiledy_blits.c +3 -3
index 44e88d4d..5a495534 100644
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)
 	i915_execbuffer2_set_context_id(exec, 0);
 	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	while (ret && errno == EBUSY) {
+	ret = __gem_execbuf(fd, &exec);
+	while (ret == EBUSY) {
 		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
 	}
 	igt_assert_eq(ret, 0);
 
tests/pm_rpm.c +3 -3
index d2a6705e..04be8c54 100644
@@ -1116,7 +1116,7 @@ static void submit_blt_cmd(uint32_t dst_handle, uint16_t x, uint16_t y,
 	execbuf.flags = I915_EXEC_BLT;
 	i915_execbuffer2_set_context_id(execbuf, 0);
 
-	do_ioctl(drm_fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(drm_fd, &execbuf);
 
 	*presumed_dst_offset = relocs[0].presumed_offset;
 
@@ -1257,7 +1257,7 @@ static void gem_execbuf_stress_subtest(int rounds, int wait_flags)
 	i915_execbuffer2_set_context_id(execbuf, 0);
 
 	for (i = 0; i < rounds; i++) {
-		do_ioctl(drm_fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(drm_fd, &execbuf);
 
 		if (wait_flags & WAIT_STATUS)
 			igt_assert(wait_for_suspended());
@@ -1387,7 +1387,7 @@ static void system_suspend_execbuf_subtest(void)
 	igt_assert(wait_for_suspended());
 
 	for (i = 0; i < 20; i++) {
-		do_ioctl(drm_fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(drm_fd, &execbuf);
 		igt_assert(wait_for_suspended());
 	}
 
Signature · 6 lines
2.14.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw
Quoted 5 lines · Antonio Argenziano

Replace custom execbuf ioctl wrapper with the ones in lib.

Cc Chris Wilson <[email protected]>
Cc Petri Latvala <[email protected]>

I seem to remember re-sending this after rebase but I couldn't find it anywhere... So apologies if this is the third time I have sent this.

Thanks,
Antonio

Quoted 609 lines
---
  tests/gem_busy.c                 |  7 +------
  tests/gem_close_race.c           |  3 +--
  tests/gem_ctx_exec.c             | 15 +++++----------
  tests/gem_evict_alignment.c      |  7 ++-----
  tests/gem_exec_await.c           |  7 +------
  tests/gem_exec_bad_domains.c     |  6 +-----
  tests/gem_exec_blt.c             |  4 ++--
  tests/gem_exec_fence.c           |  7 +------
  tests/gem_exec_latency.c         |  7 +------
  tests/gem_exec_lut_handle.c      |  2 +-
  tests/gem_exec_params.c          |  9 ++-------
  tests/gem_exec_schedule.c        | 16 ++++------------
  tests/gem_gtt_hog.c              |  2 +-
  tests/gem_lut_handle.c           | 11 ++---------
  tests/gem_pwrite_pread.c         | 12 ++++++------
  tests/gem_ringfill.c             |  7 +------
  tests/gen3_mixed_blits.c         | 10 +++++-----
  tests/gen3_render_linear_blits.c |  6 +++---
  tests/gen3_render_mixed_blits.c  |  6 +++---
  tests/gen3_render_tiledx_blits.c |  4 ++--
  tests/gen3_render_tiledy_blits.c |  6 +++---
  tests/pm_rpm.c                   |  6 +++---
  22 files changed, 51 insertions(+), 109 deletions(-)
tests/gem_busy.c +1 -6
index c349c291..444c1dd1 100644
@@ -332,11 +332,6 @@ static void alarm_handler(int sig)
  {
  }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
  static unsigned int measure_ring_size(int fd)
  {
  	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -373,7 +368,7 @@ static unsigned int measure_ring_size(int fd)
  	last = -1;
  	count = 0;
  	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
  			count++;
  			continue;
  		}
tests/gem_close_race.c +1 -2
index d9a45387..bc1127b1 100644
@@ -119,8 +119,7 @@ static void selfcopy(int fd, uint32_t handle, int loops)
  	gem_pwrite.size = sizeof(buf);
  	gem_pwrite.data_ptr = to_user_pointer(buf);
  	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite) == 0) {
-		while (loops-- &&
-		       drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0)
+		while (loops-- && __gem_execbuf(fd, &execbuf) == 0)
  			;
  	}
 
tests/gem_ctx_exec.c +5 -10
index fa864a21..1f8ed64d 100644
@@ -52,7 +52,6 @@ static int exec(int fd, uint32_t handle, int ring, int ctx_id)
  {
  	struct drm_i915_gem_execbuffer2 execbuf;
  	struct drm_i915_gem_exec_object2 gem_exec;
-	int ret = 0;
 
  	gem_exec.handle = handle;
  	gem_exec.relocation_count = 0;
@@ -75,10 +74,7 @@ static int exec(int fd, uint32_t handle, int ring, int ctx_id)
  	i915_execbuffer2_set_context_id(execbuf, ctx_id);
  	execbuf.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2,
-			&execbuf);
-
-	return ret;
+	return __gem_execbuf(fd, &execbuf);
  }
 
  static void big_exec(int fd, uint32_t handle, int ring)
@@ -116,7 +112,7 @@ static void big_exec(int fd, uint32_t handle, int ring)
 
  	execbuf.buffer_count = 1;
  	i915_execbuffer2_set_context_id(execbuf, ctx_id1);
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
 
  	for (i = 0; i < num_buffers; i++) {
  		uint32_t tmp_handle = gem_create(fd, 4096);
@@ -127,8 +123,7 @@ static void big_exec(int fd, uint32_t handle, int ring)
  	execbuf.buffer_count = i + 1;
 
  	/* figure out how many buffers we can exactly fit */
-	while (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2,
-			&execbuf) != 0) {
+	while (__gem_execbuf(fd, &execbuf) != 0) {
  		i--;
  		gem_close(fd, gem_exec[i].handle);
  		gem_exec[i].handle = handle;
@@ -140,10 +135,10 @@ static void big_exec(int fd, uint32_t handle, int ring)
  	       i - 1, num_buffers);
 
  	/* double check that it works */
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
 
  	i915_execbuffer2_set_context_id(execbuf, ctx_id2);
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
  	gem_sync(fd, handle);
  }
 
tests/gem_evict_alignment.c +2 -5
index 239be728..a80aa414 100644
@@ -61,7 +61,7 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo,
  	struct drm_i915_gem_exec_object2 *obj;
  	struct drm_i915_gem_execbuffer2 exec;
  	uint32_t handle;
-	int n, ret, i=0;
+	int n, i=0;
 
  	batch[i++] = (XY_SRC_COPY_BLT_CMD |
  		    XY_SRC_COPY_BLT_WRITE_ALPHA |
@@ -121,10 +121,7 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo,
  	i915_execbuffer2_set_context_id(exec, 0);
  	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	if (ret)
-		ret = errno;
-	igt_assert_eq(ret, error);
+	igt_assert_eq(__gem_execbuf(fd, &exec), error);
 
  	gem_close(fd, handle);
  	free(obj);
tests/gem_exec_await.c +1 -6
index e19363c4..c1ff7b7e 100644
@@ -270,11 +270,6 @@ static void alarm_handler(int sig)
  {
  }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
  static unsigned int measure_ring_size(int fd)
  {
  	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -305,7 +300,7 @@ static unsigned int measure_ring_size(int fd)
 
  	last = count = 0;
  	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
  			count++;
  			continue;
  		}
tests/gem_exec_bad_domains.c +1 -5
index 9a7487e3..cd2c8956 100644
@@ -95,7 +95,6 @@ static void multi_write_domain(int fd)
  	struct drm_i915_gem_exec_object2 exec[2];
  	struct drm_i915_gem_relocation_entry reloc[1];
  	uint32_t handle, handle_target;
-	int ret;
 
  	handle = gem_create(fd, 4096);
  	handle_target = gem_create(fd, 4096);
@@ -137,10 +136,7 @@ static void multi_write_domain(int fd)
  	i915_execbuffer2_set_context_id(execbuf, 0);
  	execbuf.rsvd2 = 0;
 
-	ret = drmIoctl(fd,
-		       DRM_IOCTL_I915_GEM_EXECBUFFER2,
-		       &execbuf);
-	igt_assert(ret != 0 && errno == EINVAL);
+	igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL);
 
  	gem_close(fd, handle);
  	gem_close(fd, handle_target);
tests/gem_exec_blt.c +2 -2
index 8c0453f6..8d61dc87 100644
@@ -228,12 +228,12 @@ static void run(int object_size, bool dumb)
  	execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
  	execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
 
-	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf)) {
+	if (__gem_execbuf(fd, &execbuf)) {
  		len = gem_linear_blt(fd, buf, src, dst, object_size, reloc);
  		igt_assert(len == execbuf.batch_len);
  		gem_write(fd, handle, 0, buf, len);
  		execbuf.flags = ring;
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(fd, &execbuf);
  	}
  	gem_sync(fd, handle);
 
tests/gem_exec_fence.c +1 -6
index bd7b1263..460e0d44 100644
@@ -355,11 +355,6 @@ static void alarm_handler(int sig)
  {
  }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
  static unsigned int measure_ring_size(int fd)
  {
  	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -396,7 +391,7 @@ static unsigned int measure_ring_size(int fd)
  	last = -1;
  	count = 0;
  	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
  			count++;
  			continue;
  		}
tests/gem_exec_latency.c +1 -6
index 74044bf4..0c783494 100644
@@ -96,11 +96,6 @@ static void set_timeout(int seconds)
  	alarm(seconds);
  }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
  static unsigned int measure_ring_size(int fd)
  {
  	struct drm_i915_gem_exec_object2 obj[2];
@@ -122,7 +117,7 @@ static unsigned int measure_ring_size(int fd)
 
  	count = 0;
  	set_timeout(1);
-	while (__execbuf(fd, &execbuf) == 0)
+	while (__gem_execbuf(fd, &execbuf) == 0)
  		count++;
  	set_timeout(0);
 
tests/gem_exec_lut_handle.c +1 -1
index 9793133c..98e6ae5a 100644
@@ -77,7 +77,7 @@ static int has_exec_lut(int fd)
  	execbuf.buffer_count = 1;
  	execbuf.flags = LOCAL_I915_EXEC_HANDLE_LUT;
 
-	return drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0;
+	return __gem_execbuf(fd, &execbuf) == 0;
  }
 
  #define ELAPSED(a,b) (1e6*((b)->tv_sec - (a)->tv_sec) + ((b)->tv_usec - (a)->tv_usec))
tests/gem_exec_params.c +2 -7
index c3dc0ac2..5909bc93 100644
@@ -233,10 +233,7 @@ igt_main
  	}
 
  #define RUN_FAIL(expected_errno) do { \
-		igt_assert(drmIoctl(fd, \
-				    DRM_IOCTL_I915_GEM_EXECBUFFER2, \
-				    &execbuf) == -1); \
-		igt_assert_eq(errno, expected_errno); \
+		igt_assert_eq(errno, __gem_execbuf(fd, &execbuf)); \
  	} while(0)
 
  	igt_subtest("no-bsd") {
@@ -350,9 +347,7 @@ igt_main
  		RUN_FAIL(EPERM);
 
  		igt_device_set_master(fd);
-		igt_assert(drmIoctl(fd,
-				    DRM_IOCTL_I915_GEM_EXECBUFFER2,
-				    &execbuf) == 0);
+		gem_execbuf(fd, &execbuf);
 
  		igt_device_drop_master(fd); /* Only needs temporary master */
  	}
tests/gem_exec_schedule.c +4 -12
index aeb7610b..b61e432d 100644
@@ -646,14 +646,6 @@ static void alarm_handler(int sig)
  {
  }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	int err = 0;
-	if (ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf))
-		err = -errno;
-	return err;
-}
-
  static unsigned int measure_ring_size(int fd, unsigned int ring)
  {
  	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -692,7 +684,7 @@ static unsigned int measure_ring_size(int fd, unsigned int ring)
  	last = -1;
  	count = 0;
  	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
  			count++;
  			continue;
  		}
@@ -922,7 +914,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
  	last = -1;
  	count = 0;
  	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
  			count++;
  			continue;
  		}
@@ -962,7 +954,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
  		 * able to add ourselves to *our* ring without interruption.
  		 */
  		igt_debug("HP child executing\n");
-		result[2] = __execbuf(fd, &execbuf) == 0;
+		result[2] = __gem_execbuf(fd, &execbuf) == 0;
  		gem_context_destroy(fd, execbuf.rsvd1);
  	}
 
@@ -976,7 +968,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
  	itv.it_value.tv_usec = 50000;
  	setitimer(ITIMER_REAL, &itv, NULL);
  	igt_debug("LP parent executing\n");
-	igt_assert_eq(__execbuf(fd, &execbuf), -EINTR);
+	igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINTR);
  	igt_assert_f(result[1], "Child was not released!\n");
  	igt_assert_f(result[2],
  		     "High priority child unable to submit within 10ms\n");
tests/gem_gtt_hog.c +1 -1
index a3dbfad4..ca730649 100644
@@ -113,7 +113,7 @@ static void busy(data_t *data, uint32_t handle, int size, int loops)
  	gem_pwrite.data_ptr = to_user_pointer(buf);
  	if (drmIoctl(data->fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite) == 0) {
  		while (loops--)
-			drmIoctl(data->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+			gem_execbuf(data->fd, &execbuf);
  	}
 
  	drmIoctl(data->fd, DRM_IOCTL_GEM_CLOSE, &create.handle);
tests/gem_lut_handle.c +2 -9
index 10516b4f..27758f39 100644
@@ -84,12 +84,7 @@ static int exec(int fd, uint32_t handle, unsigned int flags)
  	i915_execbuffer2_set_context_id(execbuf, 0);
  	execbuf.rsvd2 = 0;
 
-	if (drmIoctl(fd,
-		     DRM_IOCTL_I915_GEM_EXECBUFFER2,
-		     &execbuf))
-		return -errno;
-
-	return 0;
+	return __gem_execbuf(fd, &execbuf);
  }
 
  static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsigned flags)
@@ -156,9 +151,7 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsign
  	i915_execbuffer2_set_context_id(execbuf, 0);
  	execbuf.rsvd2 = 0;
 
-	ret = drmIoctl(fd,
-		       DRM_IOCTL_I915_GEM_EXECBUFFER2,
-		       &execbuf);
+	ret = __gem_execbuf(fd, &execbuf);
  	if (ret < 0)
  		ret = -errno;
 
tests/gem_pwrite_pread.c +6 -6
index e1543f22..383a57f7 100644
@@ -100,7 +100,7 @@ static void copy(int fd, uint32_t src, uint32_t dst, void *buf, int len, int loo
 
  	while (loops--) {
  		gem_write(fd, src, 0, buf, len);
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(fd, &execbuf);
  		gem_read(fd, dst, 0, buf, len);
  	}
 
@@ -120,7 +120,7 @@ static void as_gtt_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len,
  			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
  		memcpy(src_ptr, buf, len);
 
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(fd, &execbuf);
  		gem_set_domain(fd, dst,
  			       I915_GEM_DOMAIN_GTT, 0);
  		memcpy(buf, dst_ptr, len);
@@ -145,7 +145,7 @@ static void as_cpu_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len,
  			       I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
  		memcpy(src_ptr, buf, len);
 
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(fd, &execbuf);
  		gem_set_domain(fd, dst,
  			       I915_GEM_DOMAIN_CPU, 0);
  		memcpy(buf, dst_ptr, len);
@@ -167,7 +167,7 @@ static void test_copy(int fd, uint32_t src, uint32_t dst, uint32_t *buf, int len
  	gem_write(fd, src, 0, buf, len);
  	memset(buf, 0, len);
 
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
  	gem_read(fd, dst, 0, buf, len);
 
  	gem_close(fd, exec[2].handle);
@@ -189,7 +189,7 @@ static void test_as_gtt_mmap(int fd, uint32_t src, uint32_t dst, int len)
  	for (i = 0; i < len/4; i++)
  		src_ptr[i] = i;
 
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
  	gem_close(fd, exec[2].handle);
 
  	gem_set_domain(fd, dst, I915_GEM_DOMAIN_GTT, 0);
@@ -213,7 +213,7 @@ static void test_as_cpu_mmap(int fd, uint32_t src, uint32_t dst, int len)
  	for (i = 0; i < len/4; i++)
  		src_ptr[i] = i;
 
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(fd, &execbuf);
  	gem_close(fd, exec[2].handle);
 
  	gem_set_domain(fd, dst, I915_GEM_DOMAIN_CPU, 0);
tests/gem_ringfill.c +1 -6
index c3376a67..c51c3911 100644
@@ -270,11 +270,6 @@ static void alarm_handler(int sig)
  {
  }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}
-
  static unsigned int measure_ring_size(int fd)
  {
  	struct sigaction sa = { .sa_handler = alarm_handler };
@@ -311,7 +306,7 @@ static unsigned int measure_ring_size(int fd)
  	last = -1;
  	count = 0;
  	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		if (__gem_execbuf(fd, &execbuf) == 0) {
  			count++;
  			continue;
  		}
tests/gen3_mixed_blits.c +5 -5
index 1159b4eb..147b7b87 100644
@@ -310,10 +310,10 @@ render_copy(int fd,
  	i915_execbuffer2_set_context_id(exec, 0);
  	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	while (ret && errno == EBUSY) {
+	ret = __gem_execbuf(fd, &exec);
+	while (ret == EBUSY) {
  		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
  	}
  	igt_assert_eq(ret, 0);
 
@@ -388,10 +388,10 @@ static void blt_copy(int fd, uint32_t dst, uint32_t src)
  	i915_execbuffer2_set_context_id(exec, 0);
  	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+	ret = __gem_execbuf(fd, &exec);
  	while (ret && errno == EBUSY) {
  		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
  	}
  	igt_assert_eq(ret, 0);
 
tests/gen3_render_linear_blits.c +3 -3
index e56bff93..980a1eed 100644
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)
  	i915_execbuffer2_set_context_id(exec, 0);
  	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	while (ret && errno == EBUSY) {
+	ret = __gem_execbuf(fd, &exec);
+	while (ret == EBUSY) {
  		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
  	}
  	igt_assert_eq(ret, 0);
 
tests/gen3_render_mixed_blits.c +3 -3
index 6cc8d056..7dab181d 100644
@@ -293,10 +293,10 @@ copy(int fd,
  	i915_execbuffer2_set_context_id(exec, 0);
  	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	while (ret && errno == EBUSY) {
+	ret = __gem_execbuf(fd, &exec);
+	while (ret == EBUSY) {
  		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
  	}
  	igt_assert_eq(ret, 0);
 
tests/gen3_render_tiledx_blits.c +2 -2
index 6706d3a3..b7a632fa 100644
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)
  	i915_execbuffer2_set_context_id(exec, 0);
  	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+	ret = __gem_execbuf(fd, &exec);
  	while (ret && errno == EBUSY) {
  		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
  	}
  	igt_assert_eq(ret, 0);
 
tests/gen3_render_tiledy_blits.c +3 -3
index 44e88d4d..5a495534 100644
@@ -280,10 +280,10 @@ copy(int fd, uint32_t dst, uint32_t src)
  	i915_execbuffer2_set_context_id(exec, 0);
  	exec.rsvd2 = 0;
 
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
-	while (ret && errno == EBUSY) {
+	ret = __gem_execbuf(fd, &exec);
+	while (ret == EBUSY) {
  		drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
-		ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
+		ret = __gem_execbuf(fd, &exec);
  	}
  	igt_assert_eq(ret, 0);
 
tests/pm_rpm.c +2 -2
index d2a6705e..04be8c54 100644
@@ -1116,7 +1116,7 @@ static void submit_blt_cmd(uint32_t dst_handle, uint16_t x, uint16_t y,
  	execbuf.flags = I915_EXEC_BLT;
  	i915_execbuffer2_set_context_id(execbuf, 0);
 
-	do_ioctl(drm_fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	gem_execbuf(drm_fd, &execbuf);
 
  	*presumed_dst_offset = relocs[0].presumed_offset;
 
@@ -1257,7 +1257,7 @@ static void gem_execbuf_stress_subtest(int rounds, int wait_flags)
  	i915_execbuffer2_set_context_id(execbuf, 0);
 
  	for (i = 0; i < rounds; i++) {
-		do_ioctl(drm_fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(drm_fd, &execbuf);
 
  		if (wait_flags & WAIT_STATUS)
  			igt_assert(wait_for_suspended());

tests/pm_rpm.c static void system_suspend_execbuf_subtest(void) · line 1393

Quoted 8 lines
tests/pm_rpm.c +1 -1
@@ -1387,7 +1387,7 @@ static void system_suspend_execbuf_subtest(void)
  	igt_assert(wait_for_suspended());
 
  	for (i = 0; i < 20; i++) {
-		do_ioctl(drm_fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_execbuf(drm_fd, &execbuf);
  		igt_assert(wait_for_suspended());
  	}
 

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for igt: Use lib gem_execbuf where possible

In reply to Antonio Argenziano
== Series Details ==

== Series Details ==

Series: igt: Use lib gem_execbuf where possible
URL : https://patchwork.freedesktop.org/series/37963/
State : failure

== Summary ==

IGT patchset tested on top of latest successful build
3af87d45da24015b7a6124b59b2c4b854381cab6 tools/intel_aubdump: Simulate "enhanced execlist" submission for gen11+

with latest DRM-Tip kernel build CI_DRM_3748
6c10ba221576 drm-tip: 2018y-02m-08d-19h-13m-44s UTC integration manifest

No testlist changes.

Test gem_exec_fence:

        Subgroup basic-busy-default:
                skip       -> INCOMPLETE (fi-gdg-551)
                pass       -> INCOMPLETE (fi-blb-e6850)
                pass       -> INCOMPLETE (fi-pnv-d510)
                skip       -> INCOMPLETE (fi-bwr-2160)
                pass       -> INCOMPLETE (fi-elk-e7500)
                pass       -> INCOMPLETE (fi-ilk-650)
                pass       -> INCOMPLETE (fi-snb-2520m)
                pass       -> INCOMPLETE (fi-snb-2600)
                pass       -> INCOMPLETE (fi-ivb-3520m)
                pass       -> INCOMPLETE (fi-ivb-3770)
                pass       -> INCOMPLETE (fi-byt-j1900)
                pass       -> INCOMPLETE (fi-byt-n2820)
                pass       -> INCOMPLETE (fi-hsw-4770)
                pass       -> INCOMPLETE (fi-bdw-5557u)
                pass       -> INCOMPLETE (fi-bdw-gvtdvm)
                pass       -> INCOMPLETE (fi-bsw-n3050)
                pass       -> INCOMPLETE (fi-skl-6260u)
                pass       -> INCOMPLETE (fi-skl-6600u)
                pass       -> INCOMPLETE (fi-skl-6700hq)
                pass       -> INCOMPLETE (fi-skl-6700k2)
                pass       -> INCOMPLETE (fi-skl-6770hq)
                pass       -> INCOMPLETE (fi-skl-guc)
                pass       -> INCOMPLETE (fi-skl-gvtdvm)
                pass       -> INCOMPLETE (fi-bxt-dsi)
                pass       -> INCOMPLETE (fi-bxt-j4205)
                pass       -> INCOMPLETE (fi-kbl-7500u)
                pass       -> INCOMPLETE (fi-kbl-7560u)
                pass       -> INCOMPLETE (fi-kbl-7567u)
                pass       -> INCOMPLETE (fi-kbl-r)
                pass       -> INCOMPLETE (fi-glk-1)
                pass       -> INCOMPLETE (fi-cfl-s2)
                pass       -> INCOMPLETE (fi-cnl-y3)
fi-bdw-5557u     total:45   pass:44   dwarn:0   dfail:0   fail:0   skip:0  
fi-bdw-gvtdvm    total:45   pass:44   dwarn:0   dfail:0   fail:0   skip:0  
fi-blb-e6850     total:45   pass:22   dwarn:0   dfail:0   fail:0   skip:22 
fi-bsw-n3050     total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-bwr-2160      total:45   pass:20   dwarn:0   dfail:0   fail:0   skip:24 
fi-bxt-dsi       total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-bxt-j4205     total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-byt-j1900     total:45   pass:35   dwarn:0   dfail:0   fail:0   skip:9  
fi-byt-n2820     total:45   pass:35   dwarn:0   dfail:0   fail:0   skip:9  
fi-cfl-s2        total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-cnl-y3        total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-elk-e7500     total:45   pass:25   dwarn:0   dfail:0   fail:0   skip:19 
fi-gdg-551       total:45   pass:20   dwarn:0   dfail:0   fail:0   skip:24 
fi-glk-1         total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-hsw-4770      total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-ilk-650       total:45   pass:25   dwarn:0   dfail:0   fail:0   skip:19 
fi-ivb-3520m     total:45   pass:35   dwarn:0   dfail:0   fail:0   skip:9  
fi-ivb-3770      total:45   pass:35   dwarn:0   dfail:0   fail:0   skip:9  
fi-kbl-7500u     total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-kbl-7560u     total:45   pass:44   dwarn:0   dfail:0   fail:0   skip:0  
fi-kbl-7567u     total:45   pass:44   dwarn:0   dfail:0   fail:0   skip:0  
fi-kbl-r         total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-pnv-d510      total:45   pass:22   dwarn:0   dfail:0   fail:0   skip:22 
fi-skl-6260u     total:45   pass:44   dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6600u     total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-skl-6700hq    total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-skl-6700k2    total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-skl-6770hq    total:45   pass:44   dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-guc       total:45   pass:38   dwarn:0   dfail:0   fail:0   skip:6  
fi-skl-gvtdvm    total:45   pass:44   dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2520m     total:45   pass:35   dwarn:0   dfail:0   fail:0   skip:9  
fi-snb-2600      total:45   pass:35   dwarn:0   dfail:0   fail:0   skip:9  

Blacklisted hosts:
fi-glk-dsi total:45 pass:38 dwarn:0 dfail:0 fail:0 skip:6

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_890/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw
In reply to Antonio Argenziano

Quoting Antonio Argenziano (2018-02-09 00:21:57)

tests/gem_busy.c static void alarm_handler(int sig) · line 338

Quoted 12 lines
tests/gem_busy.c +0 -4
index c349c291..444c1dd1 100644
@@ -332,11 +332,6 @@ static void alarm_handler(int sig)
 {
 }
 
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-       return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}

Wrong. There's an important difference here, can you see it? It's all to do with signal handling...
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw
Quoted 9 lines · Chris Wilson

Quoting Antonio Argenziano (2018-02-09 00:21:57)

Quoted 8 lines
tests/gem_busy.c +0 -0
index c349c291..444c1dd1 100644
@@ -332,11 +332,6 @@ static void alarm_handler(int sig)
  {
  }
 
Quoted 7 lines

tests/gem_busy.c static void alarm_handler(int sig) · line 338

Quoted 4 lines
tests/gem_busy.c +0 -4
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-       return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}

Wrong. There's an important difference here, can you see it? It's all to do with signal handling...

I guess we do not want to keep trying doing the same ioctl once the ringbuffer is full...

Thanks for finding this, it would have been a nasty one.

Antonio

Quoted 2 lines

-Chris

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#5 lore raw
Quoted 19 lines · Antonio Argenziano
Quoted 15 lines · Chris Wilson

Quoting Antonio Argenziano (2018-02-09 00:21:57)

tests/gem_busy.c static void alarm_handler(int sig) · line 337

Quoted 11 lines
tests/gem_busy.c +0 -4
index c349c291..444c1dd1 100644
@@ -332,11 +332,6 @@ static void alarm_handler(int sig)
  {
  }
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-       return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}

Wrong. There's an important difference here, can you see it? It's all to do with signal handling...

Quoted 1 line

I guess we do not want to keep trying doing the same ioctl once the ringbuffer is full...

Say one wanted to put measure_ring_size() in lib, what would be the right place for it?

Thanks,
Antonio

Quoted 7 lines

Thanks for finding this, it would have been a nasty one.

Antonio

Quoted 2 lines

-Chris

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#6 lore raw
Quoted 22 lines · Antonio Argenziano
Quoted 19 lines · Antonio Argenziano
Quoted 15 lines · Chris Wilson

Quoting Antonio Argenziano (2018-02-09 00:21:57)

tests/gem_busy.c static void alarm_handler(int sig) · line 337

Quoted 11 lines
tests/gem_busy.c +0 -4
index c349c291..444c1dd1 100644
@@ -332,11 +332,6 @@ static void alarm_handler(int sig)
   {
   }
-static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-       return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
-}

Wrong. There's an important difference here, can you see it? It's all to do with signal handling...

Quoted 7 lines
Quoted 1 line

I guess we do not want to keep trying doing the same ioctl once the ringbuffer is full...

Say one wanted to put measure_ring_size() in lib, what would be the right place for it?

Thanks,
Antonio

I had sent a series for that (and igt_cork) a while back:

https://patchwork.freedesktop.org/series/31858/

It's still on my list of things to come back to but I doubt I'll have time in the short term, so feel free to pick it up if you don't want to wait.

Thanks,
Daniele

Quoted 11 lines
Quoted 7 lines

Thanks for finding this, it would have been a nasty one.

Antonio

Quoted 2 lines

-Chris

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev