[Mesa-dev] [PATCH 07/10] anv/gem: Add support for syncobj wait and reset

Jason Ekstrand jason at jlekstrand.net
Tue Aug 8 22:45:32 UTC 2017


---
 src/intel/vulkan/anv_gem.c       | 61 ++++++++++++++++++++++++++++++++++++++++
 src/intel/vulkan/anv_gem_stubs.c | 20 +++++++++++++
 src/intel/vulkan/anv_private.h   |  5 ++++
 3 files changed, 86 insertions(+)

diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 9e6b2bb..4f46d2a 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -488,3 +488,64 @@ 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_reset args = {
+      .handle = handle,
+   };
+
+   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 842efb3..6c97730 100644
--- a/src/intel/vulkan/anv_gem_stubs.c
+++ b/src/intel/vulkan/anv_gem_stubs.c
@@ -204,3 +204,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 5f49153..2f89d3f 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -817,6 +817,11 @@ uint32_t anv_gem_syncobj_create(struct anv_device *device);
 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);
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list