diff options
author | Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> | 2022-07-01 16:05:44 -0700 |
---|---|---|
committer | Andi Shyti <andi.shyti@linux.intel.com> | 2022-07-09 02:43:54 +0200 |
commit | d33d1f0df600f6b8a868daa23832749e26b09b55 (patch) | |
tree | 1e3226f2b5d68d27834bed54a4d3fd862fc70cc8 /lib/ioctl_wrappers.c | |
parent | 790c1b18ca0815ca14b320e3b4d9e262fe46f1a4 (diff) |
tests/i915/vm_bind: Add vm_bind sanity test
Add sanity test to exercise vm_bind uapi.
Test for various cases with vm_bind and vm_unbind ioctls.
Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r-- | lib/ioctl_wrappers.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index ac37b6bb..bf7f5f43 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -1153,28 +1153,55 @@ void gem_require_mocs_registers(int fd) /* prime */ /** - * prime_handle_to_fd: + * prime_handle_to_fd_no_assert: * @fd: open i915 drm file descriptor * @handle: file-private gem buffer object handle + * @flags: DRM_IOCTL_PRIME_HANDLE_TO_FD ioctl flags + * @fd_out: place holder for output file handle * * This wraps the PRIME_HANDLE_TO_FD ioctl, which is used to export a gem buffer * object into a global (i.e. potentially cross-device) dma-buf file-descriptor * handle. * - * Returns: The created dma-buf fd handle. + * Returns: 0 on sucess, error otherwise. Upon success, it returns + * the created dma-buf fd handle in fd_out. */ -int prime_handle_to_fd(int fd, uint32_t handle) +int prime_handle_to_fd_no_assert(int fd, uint32_t handle, int flags, int *fd_out) { struct drm_prime_handle args; + int ret; memset(&args, 0, sizeof(args)); args.handle = handle; - args.flags = DRM_CLOEXEC; + args.flags = flags; args.fd = -1; - do_ioctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args); + ret = drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args); + if (ret) + ret = -errno; + *fd_out = args.fd; - return args.fd; + return ret; +} + +/** + * prime_handle_to_fd: + * @fd: open i915 drm file descriptor + * @handle: file-private gem buffer object handle + * + * This wraps the PRIME_HANDLE_TO_FD ioctl, which is used to export a gem buffer + * object into a global (i.e. potentially cross-device) dma-buf file-descriptor + * handle. It asserts that ioctl succeeds. + * + * Returns: The created dma-buf fd handle. + */ +int prime_handle_to_fd(int fd, uint32_t handle) +{ + int dmabuf; + + igt_assert_eq(prime_handle_to_fd_no_assert(fd, handle, DRM_CLOEXEC, &dmabuf), 0); + + return dmabuf; } /** |