Commit 1fb30f11 authored by Antonio Argenziano's avatar Antonio Argenziano Committed by Chris Wilson

igt: Use lib gem_execbuf where possible

Replace custom execbuf ioctl wrapper with the ones in lib.

v2:
	- Lib execbuf wrapper is not signal handling friendly. (Chris)

v3:
	- EXECBUFFER2_WR != EXECBUFFER2. (Chris)
v4: Drop gem_exec_fence.c changes
Signed-off-by: Antonio Argenziano's avatarAntonio Argenziano <antonio.argenziano@intel.com>

Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala@intel.com>
Reviewed-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 998e1da7
......@@ -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)
;
}
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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))
......
......@@ -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(__gem_execbuf(fd, &execbuf), -expected_errno); \
} 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 */
}
......
......@@ -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);
......
......@@ -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,11 +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);
if (ret < 0)
ret = -errno;
ret = __gem_execbuf(fd, &execbuf);
for (n = 0; n < num_exec; n++)
gem_close(fd, gem_exec[n].handle);
......
......@@ -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);
......
......@@ -88,7 +88,6 @@ render_copy(int fd,
struct drm_i915_gem_execbuffer2 exec;
uint32_t handle;
uint32_t tiling_bits;
int ret;
/* invariant state */
*b++ = (_3DSTATE_AA_CMD |
......@@ -310,12 +309,7 @@ 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) {
drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
}
igt_assert_eq(ret, 0);
gem_execbuf(fd, &exec);
gem_close(fd, handle);
}
......@@ -327,7 +321,6 @@ static void blt_copy(int fd, uint32_t dst, uint32_t src)
struct drm_i915_gem_exec_object2 obj[3];
struct drm_i915_gem_execbuffer2 exec;
uint32_t handle;
int ret;
*b++ = (XY_SRC_COPY_BLT_CMD |
XY_SRC_COPY_BLT_WRITE_ALPHA |
......@@ -388,12 +381,7 @@ 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);
while (ret && errno == EBUSY) {
drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
}
igt_assert_eq(ret, 0);
gem_execbuf(fd, &exec);
gem_close(fd, handle);
}
......
......@@ -85,7 +85,6 @@ copy(int fd, uint32_t dst, uint32_t src)
struct drm_i915_gem_exec_object2 obj[3];
struct drm_i915_gem_execbuffer2 exec;
uint32_t handle;
int ret;
/* invariant state */
*b++ = (_3DSTATE_AA_CMD |
......@@ -280,12 +279,7 @@ 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) {
drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
}
igt_assert_eq(ret, 0);
gem_execbuf(fd, &exec);
gem_close(fd, handle);
}
......
......@@ -87,7 +87,6 @@ copy(int fd,
struct drm_i915_gem_execbuffer2 exec;
uint32_t handle;
uint32_t tiling_bits;
int ret;
/* invariant state */
*b++ = (_3DSTATE_AA_CMD |
......@@ -293,12 +292,7 @@ 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) {
drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
}
igt_assert_eq(ret, 0);
gem_execbuf(fd, &exec);
gem_close(fd, handle);
}
......
......@@ -84,7 +84,6 @@ copy(int fd, uint32_t dst, uint32_t src)
struct drm_i915_gem_exec_object2 obj[3];
struct drm_i915_gem_execbuffer2 exec;
uint32_t handle;
int ret;
/* invariant state */
*b++ = (_3DSTATE_AA_CMD |
......@@ -280,12 +279,7 @@ 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) {
drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
}
igt_assert_eq(ret, 0);
gem_execbuf(fd, &exec);
gem_close(fd, handle);
}
......
......@@ -84,7 +84,6 @@ copy(int fd, uint32_t dst, uint32_t src)
struct drm_i915_gem_exec_object2 obj[3];
struct drm_i915_gem_execbuffer2 exec;
uint32_t handle;
int ret;
/* invariant state */
*b++ = (_3DSTATE_AA_CMD |
......@@ -280,12 +279,7 @@ 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) {
drmCommandNone(fd, DRM_I915_GEM_THROTTLE);
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
}
igt_assert_eq(ret, 0);
gem_execbuf(fd, &exec);
gem_close(fd, handle);
}
......
......@@ -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());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment