summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_gem.c62
-rw-r--r--src/intel/vulkan/anv_gem_stubs.c20
-rw-r--r--src/intel/vulkan/anv_private.h5
3 files changed, 87 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 9bd37f4cb3d..8283117cd0e 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -488,3 +488,65 @@ anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
return args.handle;
}
+
+void
+anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
+{
+ struct drm_syncobj_array args = {
+ .handles = (uint64_t)(uintptr_t)&handle,
+ .count_handles = 1,
+ };
+
+ anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_RESET, &args);
+}
+
+bool
+anv_gem_supports_syncobj_wait(int fd)
+{
+ int ret;
+
+ struct drm_syncobj_create create = {
+ .flags = 0,
+ };
+ ret = anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
+ if (ret)
+ return false;
+
+ uint32_t syncobj = create.handle;
+
+ struct drm_syncobj_wait wait = {
+ .handles = (uint64_t)(uintptr_t)&create,
+ .count_handles = 1,
+ .timeout_nsec = 0,
+ .flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
+ };
+ ret = anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);
+
+ struct drm_syncobj_destroy destroy = {
+ .handle = syncobj,
+ };
+ anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
+
+ /* If it timed out, then we have the ioctl and it supports the
+ * DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT flag.
+ */
+ return ret == -1 && errno == ETIME;
+}
+
+int
+anv_gem_syncobj_wait(struct anv_device *device,
+ uint32_t *handles, uint32_t num_handles,
+ int64_t abs_timeout_ns, bool wait_all)
+{
+ struct drm_syncobj_wait args = {
+ .handles = (uint64_t)(uintptr_t)handles,
+ .count_handles = num_handles,
+ .timeout_nsec = abs_timeout_ns,
+ .flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
+ };
+
+ if (wait_all)
+ args.flags |= DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL;
+
+ return anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args);
+}
diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c
index a0928691eaf..36700d7434c 100644
--- a/src/intel/vulkan/anv_gem_stubs.c
+++ b/src/intel/vulkan/anv_gem_stubs.c
@@ -210,3 +210,23 @@ anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
{
unreachable("Unused");
}
+
+void
+anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
+{
+ unreachable("Unused");
+}
+
+bool
+anv_gem_supports_syncobj_wait(int fd)
+{
+ return false;
+}
+
+int
+anv_gem_syncobj_wait(struct anv_device *device,
+ uint32_t *handles, uint32_t num_handles,
+ int64_t abs_timeout_ns, bool wait_all)
+{
+ unreachable("Unused");
+}
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 9b3efda3708..7817dc07f05 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -809,6 +809,11 @@ uint32_t anv_gem_syncobj_create(struct anv_device *device, uint32_t flags);
void anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle);
int anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle);
uint32_t anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd);
+void anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle);
+bool anv_gem_supports_syncobj_wait(int fd);
+int anv_gem_syncobj_wait(struct anv_device *device,
+ uint32_t *handles, uint32_t num_handles,
+ int64_t abs_timeout_ns, bool wait_all);
VkResult anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size);