summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-01-27 14:30:24 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-01-27 14:45:19 +0000
commitb7f150b606bc27199a007dab8d248d9510967173 (patch)
treec871904a8be177b0b1163ccaf83891d7cf5cb379 /lib
parente3b68bb66683ad4cb4c80df904a3a21c98a2b6c2 (diff)
lib: Query the kernel for support of a particular exec id
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/ioctl_wrappers.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index bc6c490f..9dfa9b26 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1308,6 +1308,27 @@ void gem_require_caching(int fd)
errno = 0;
}
+static int gem_has_ring(int fd, int ring)
+{
+ uint32_t bbe = MI_BATCH_BUFFER_END;
+ struct drm_i915_gem_execbuffer2 execbuf;
+ struct drm_i915_gem_exec_object2 exec;
+ int ret;
+
+ memset(&exec, 0, sizeof(exec));
+ exec.handle = gem_create(fd, 4096);
+ gem_write(fd, exec.handle, 0, &bbe, sizeof(bbe));
+
+ memset(&execbuf, 0, sizeof(execbuf));
+ execbuf.buffers_ptr = (uintptr_t)&exec;
+ execbuf.buffer_count = 1;
+ execbuf.flags = ring;
+ ret = __gem_execbuf(fd, &execbuf);
+ gem_close(fd, exec.handle);
+
+ return ret == 0;
+}
+
/**
* gem_require_ring:
* @fd: open i915 drm file descriptor
@@ -1319,26 +1340,7 @@ void gem_require_caching(int fd)
*/
void gem_require_ring(int fd, int ring_id)
{
- switch (ring_id) {
- case I915_EXEC_DEFAULT:
- case I915_EXEC_RENDER:
- return;
- case I915_EXEC_BLT:
- igt_require(gem_has_blt(fd));
- return;
- case I915_EXEC_BSD:
- igt_require(gem_has_bsd(fd));
- return;
-#ifdef I915_EXEC_VEBOX
- case I915_EXEC_VEBOX:
- igt_require(gem_has_vebox(fd));
- return;
-#endif
- default:
- igt_warn("Invalid ring: %d\n", ring_id);
- igt_assert(0);
- return;
- }
+ igt_require(gem_has_ring(fd, ring_id));
}
/* prime */