diff options
author | Jason Ekstrand <[email protected]> | 2017-05-10 14:28:33 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-08-15 19:08:26 -0700 |
commit | 5c4e4932e02164e18cba9ae2cf3ec56afa2f2a6b (patch) | |
tree | 6b3bc6cb8951dcbd1937262995e651d5e91239fc /src/intel/vulkan/anv_gem.c | |
parent | e4054ab77b4f5867d0a86830bd9daec685941a23 (diff) |
anv: Implement support for exporting semaphores as FENCE_FD
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_gem.c')
-rw-r--r-- | src/intel/vulkan/anv_gem.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index 36692f567ca..40ef9144e6c 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -22,6 +22,7 @@ */ #include <sys/ioctl.h> +#include <sys/types.h> #include <sys/mman.h> #include <string.h> #include <errno.h> @@ -400,3 +401,38 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd) return args.handle; } + +#ifndef SYNC_IOC_MAGIC +/* duplicated from linux/sync_file.h to avoid build-time dependency + * on new (v4.7) kernel headers. Once distro's are mostly using + * something newer than v4.7 drop this and #include <linux/sync_file.h> + * instead. + */ +struct sync_merge_data { + char name[32]; + __s32 fd2; + __s32 fence; + __u32 flags; + __u32 pad; +}; + +#define SYNC_IOC_MAGIC '>' +#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data) +#endif + +int +anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2) +{ + const char name[] = "anv merge fence"; + struct sync_merge_data args = { + .fd2 = fd2, + .fence = -1, + }; + memcpy(args.name, name, sizeof(name)); + + int ret = anv_ioctl(fd1, SYNC_IOC_MERGE, &args); + if (ret == -1) + return -1; + + return args.fence; +} |