summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/intel_chipset.h2
-rw-r--r--lib/ioctl_wrappers.c39
-rw-r--r--lib/ioctl_wrappers.h1
3 files changed, 36 insertions, 6 deletions
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index d7a6ff19..7cf82591 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -225,4 +225,6 @@ void intel_check_pch(void);
#define HAS_FLATCCS(devid) (intel_get_device_info(devid)->has_flatccs)
+#define HAS_64K_PAGES(devid) (IS_DG2(devid))
+
#endif /* _INTEL_CHIPSET_H */
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;
}
/**
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 223cd916..9f50a241 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -143,6 +143,7 @@ struct local_dma_buf_sync {
#define LOCAL_DMA_BUF_BASE 'b'
#define LOCAL_DMA_BUF_IOCTL_SYNC _IOW(LOCAL_DMA_BUF_BASE, 0, struct local_dma_buf_sync)
+int prime_handle_to_fd_no_assert(int fd, uint32_t handle, int flags, int *fd_out);
int prime_handle_to_fd(int fd, uint32_t handle);
#ifndef DRM_RDWR
#define DRM_RDWR O_RDWR