* [PATCH] libdrm: add drm syncobj create/destroy/import/export
@ 2017-06-17 1:06 Dave Airlie
2017-06-26 20:55 ` Dave Airlie
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Dave Airlie @ 2017-06-17 1:06 UTC (permalink / raw)
To: dri-devel
From: Dave Airlie <airlied@redhat.com>
These ioctls are now in drm next so add the first set of libdrm APIs.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
include/drm/drm.h | 26 ++++++++++++++++++
xf86drm.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
xf86drm.h | 8 ++++++
3 files changed, 115 insertions(+)
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 1e7a4bc..bf3674a 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -642,6 +642,7 @@ struct drm_gem_open {
#define DRM_CAP_ADDFB2_MODIFIERS 0x10
#define DRM_CAP_PAGE_FLIP_TARGET 0x11
#define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
+#define DRM_CAP_SYNCOBJ 0x13
/** DRM_IOCTL_GET_CAP ioctl argument type */
struct drm_get_cap {
@@ -691,6 +692,26 @@ struct drm_prime_handle {
__s32 fd;
};
+struct drm_syncobj_create {
+ __u32 handle;
+ __u32 flags;
+};
+
+struct drm_syncobj_destroy {
+ __u32 handle;
+ __u32 pad;
+};
+
+#define DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE (1 << 0)
+#define DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE (1 << 0)
+struct drm_syncobj_handle {
+ __u32 handle;
+ __u32 flags;
+
+ __s32 fd;
+ __u32 pad;
+};
+
#if defined(__cplusplus)
}
#endif
@@ -809,6 +830,11 @@ extern "C" {
#define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob)
#define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob)
+#define DRM_IOCTL_SYNCOBJ_CREATE DRM_IOWR(0xBF, struct drm_syncobj_create)
+#define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy)
+#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle)
+#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle)
+
/**
* Device specific ioctls should only be in their respective headers
* The device specific ioctl range is from 0x40 to 0x9f.
diff --git a/xf86drm.c b/xf86drm.c
index 728ac78..2ac3f26 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -4146,3 +4146,84 @@ char *drmGetDeviceNameFromFd2(int fd)
return strdup(node);
#endif
}
+
+int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle)
+{
+ struct drm_syncobj_create args;
+ int ret;
+
+ memclear(args);
+ args.flags = flags;
+ args.handle = 0;
+ ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
+ if (ret)
+ return ret;
+ *handle = args.handle;
+ return 0;
+}
+
+int drmSyncobjDestroy(int fd, uint32_t handle)
+{
+ struct drm_syncobj_destroy args;
+
+ memclear(args);
+ args.handle = handle;
+ return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
+}
+
+int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd)
+{
+ struct drm_syncobj_handle args;
+ int ret;
+
+ memclear(args);
+ args.fd = -1;
+ args.handle = handle;
+ ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
+ if (ret)
+ return ret;
+ *obj_fd = args.fd;
+ return 0;
+}
+
+int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle)
+{
+ struct drm_syncobj_handle args;
+ int ret;
+
+ memclear(args);
+ args.fd = obj_fd;
+ args.handle = 0;
+ ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
+ if (ret)
+ return ret;
+ *handle = args.handle;
+ return 0;
+}
+
+int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd)
+{
+ struct drm_syncobj_handle args;
+
+ memclear(args);
+ args.fd = sync_file_fd;
+ args.handle = handle;
+ args.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE;
+ return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
+}
+
+int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd)
+{
+ struct drm_syncobj_handle args;
+ int ret;
+
+ memclear(args);
+ args.fd = -1;
+ args.handle = handle;
+ args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE;
+ ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
+ if (ret)
+ return ret;
+ *sync_file_fd = args.fd;
+ return 0;
+}
diff --git a/xf86drm.h b/xf86drm.h
index 74f54f1..2855a3e 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -853,6 +853,14 @@ extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_device
extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
+extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle);
+extern int drmSyncobjDestroy(int fd, uint32_t handle);
+extern int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd);
+extern int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle);
+
+extern int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd);
+extern int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd);
+
#if defined(__cplusplus)
}
#endif
--
2.9.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] libdrm: add drm syncobj create/destroy/import/export
2017-06-17 1:06 [PATCH] libdrm: add drm syncobj create/destroy/import/export Dave Airlie
@ 2017-06-26 20:55 ` Dave Airlie
2017-06-27 22:56 ` Eric Anholt
2017-09-08 16:29 ` Marek Olšák
2 siblings, 0 replies; 7+ messages in thread
From: Dave Airlie @ 2017-06-26 20:55 UTC (permalink / raw)
To: dri-devel
ping?
Dave.
On 17 June 2017 at 11:06, Dave Airlie <airlied@gmail.com> wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> These ioctls are now in drm next so add the first set of libdrm APIs.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
> include/drm/drm.h | 26 ++++++++++++++++++
> xf86drm.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> xf86drm.h | 8 ++++++
> 3 files changed, 115 insertions(+)
>
> diff --git a/include/drm/drm.h b/include/drm/drm.h
> index 1e7a4bc..bf3674a 100644
> --- a/include/drm/drm.h
> +++ b/include/drm/drm.h
> @@ -642,6 +642,7 @@ struct drm_gem_open {
> #define DRM_CAP_ADDFB2_MODIFIERS 0x10
> #define DRM_CAP_PAGE_FLIP_TARGET 0x11
> #define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
> +#define DRM_CAP_SYNCOBJ 0x13
>
> /** DRM_IOCTL_GET_CAP ioctl argument type */
> struct drm_get_cap {
> @@ -691,6 +692,26 @@ struct drm_prime_handle {
> __s32 fd;
> };
>
> +struct drm_syncobj_create {
> + __u32 handle;
> + __u32 flags;
> +};
> +
> +struct drm_syncobj_destroy {
> + __u32 handle;
> + __u32 pad;
> +};
> +
> +#define DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE (1 << 0)
> +#define DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE (1 << 0)
> +struct drm_syncobj_handle {
> + __u32 handle;
> + __u32 flags;
> +
> + __s32 fd;
> + __u32 pad;
> +};
> +
> #if defined(__cplusplus)
> }
> #endif
> @@ -809,6 +830,11 @@ extern "C" {
> #define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob)
> #define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob)
>
> +#define DRM_IOCTL_SYNCOBJ_CREATE DRM_IOWR(0xBF, struct drm_syncobj_create)
> +#define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy)
> +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle)
> +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle)
> +
> /**
> * Device specific ioctls should only be in their respective headers
> * The device specific ioctl range is from 0x40 to 0x9f.
> diff --git a/xf86drm.c b/xf86drm.c
> index 728ac78..2ac3f26 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -4146,3 +4146,84 @@ char *drmGetDeviceNameFromFd2(int fd)
> return strdup(node);
> #endif
> }
> +
> +int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle)
> +{
> + struct drm_syncobj_create args;
> + int ret;
> +
> + memclear(args);
> + args.flags = flags;
> + args.handle = 0;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
> + if (ret)
> + return ret;
> + *handle = args.handle;
> + return 0;
> +}
> +
> +int drmSyncobjDestroy(int fd, uint32_t handle)
> +{
> + struct drm_syncobj_destroy args;
> +
> + memclear(args);
> + args.handle = handle;
> + return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
> +}
> +
> +int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = -1;
> + args.handle = handle;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
> + if (ret)
> + return ret;
> + *obj_fd = args.fd;
> + return 0;
> +}
> +
> +int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = obj_fd;
> + args.handle = 0;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
> + if (ret)
> + return ret;
> + *handle = args.handle;
> + return 0;
> +}
> +
> +int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd)
> +{
> + struct drm_syncobj_handle args;
> +
> + memclear(args);
> + args.fd = sync_file_fd;
> + args.handle = handle;
> + args.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE;
> + return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
> +}
> +
> +int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = -1;
> + args.handle = handle;
> + args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
> + if (ret)
> + return ret;
> + *sync_file_fd = args.fd;
> + return 0;
> +}
> diff --git a/xf86drm.h b/xf86drm.h
> index 74f54f1..2855a3e 100644
> --- a/xf86drm.h
> +++ b/xf86drm.h
> @@ -853,6 +853,14 @@ extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_device
>
> extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
>
> +extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle);
> +extern int drmSyncobjDestroy(int fd, uint32_t handle);
> +extern int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd);
> +extern int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle);
> +
> +extern int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd);
> +extern int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd);
> +
> #if defined(__cplusplus)
> }
> #endif
> --
> 2.9.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] libdrm: add drm syncobj create/destroy/import/export
2017-06-17 1:06 [PATCH] libdrm: add drm syncobj create/destroy/import/export Dave Airlie
2017-06-26 20:55 ` Dave Airlie
@ 2017-06-27 22:56 ` Eric Anholt
2017-09-08 16:29 ` Marek Olšák
2 siblings, 0 replies; 7+ messages in thread
From: Eric Anholt @ 2017-06-27 22:56 UTC (permalink / raw)
To: Dave Airlie, dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 429 bytes --]
Dave Airlie <airlied@gmail.com> writes:
> From: Dave Airlie <airlied@redhat.com>
>
> These ioctls are now in drm next so add the first set of libdrm APIs.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
It took me a bit of digging to understand the functional difference
between drmSyncobjHandleToFD() and drmSyncobjExportSyncFile(), but the
wrappers for these ioctls seem fine.
Reviewed-by: Eric Anholt <eric@anholt.net>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libdrm: add drm syncobj create/destroy/import/export
2017-06-17 1:06 [PATCH] libdrm: add drm syncobj create/destroy/import/export Dave Airlie
2017-06-26 20:55 ` Dave Airlie
2017-06-27 22:56 ` Eric Anholt
@ 2017-09-08 16:29 ` Marek Olšák
2017-09-08 20:08 ` Dave Airlie
2 siblings, 1 reply; 7+ messages in thread
From: Marek Olšák @ 2017-09-08 16:29 UTC (permalink / raw)
To: Dave Airlie; +Cc: dri-devel
What's the difference between HandleToFD and ExportSyncFile?
Thanks,
Marek
On Sat, Jun 17, 2017 at 3:06 AM, Dave Airlie <airlied@gmail.com> wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> These ioctls are now in drm next so add the first set of libdrm APIs.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
> include/drm/drm.h | 26 ++++++++++++++++++
> xf86drm.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> xf86drm.h | 8 ++++++
> 3 files changed, 115 insertions(+)
>
> diff --git a/include/drm/drm.h b/include/drm/drm.h
> index 1e7a4bc..bf3674a 100644
> --- a/include/drm/drm.h
> +++ b/include/drm/drm.h
> @@ -642,6 +642,7 @@ struct drm_gem_open {
> #define DRM_CAP_ADDFB2_MODIFIERS 0x10
> #define DRM_CAP_PAGE_FLIP_TARGET 0x11
> #define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
> +#define DRM_CAP_SYNCOBJ 0x13
>
> /** DRM_IOCTL_GET_CAP ioctl argument type */
> struct drm_get_cap {
> @@ -691,6 +692,26 @@ struct drm_prime_handle {
> __s32 fd;
> };
>
> +struct drm_syncobj_create {
> + __u32 handle;
> + __u32 flags;
> +};
> +
> +struct drm_syncobj_destroy {
> + __u32 handle;
> + __u32 pad;
> +};
> +
> +#define DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE (1 << 0)
> +#define DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE (1 << 0)
> +struct drm_syncobj_handle {
> + __u32 handle;
> + __u32 flags;
> +
> + __s32 fd;
> + __u32 pad;
> +};
> +
> #if defined(__cplusplus)
> }
> #endif
> @@ -809,6 +830,11 @@ extern "C" {
> #define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob)
> #define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob)
>
> +#define DRM_IOCTL_SYNCOBJ_CREATE DRM_IOWR(0xBF, struct drm_syncobj_create)
> +#define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy)
> +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle)
> +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle)
> +
> /**
> * Device specific ioctls should only be in their respective headers
> * The device specific ioctl range is from 0x40 to 0x9f.
> diff --git a/xf86drm.c b/xf86drm.c
> index 728ac78..2ac3f26 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -4146,3 +4146,84 @@ char *drmGetDeviceNameFromFd2(int fd)
> return strdup(node);
> #endif
> }
> +
> +int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle)
> +{
> + struct drm_syncobj_create args;
> + int ret;
> +
> + memclear(args);
> + args.flags = flags;
> + args.handle = 0;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
> + if (ret)
> + return ret;
> + *handle = args.handle;
> + return 0;
> +}
> +
> +int drmSyncobjDestroy(int fd, uint32_t handle)
> +{
> + struct drm_syncobj_destroy args;
> +
> + memclear(args);
> + args.handle = handle;
> + return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
> +}
> +
> +int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = -1;
> + args.handle = handle;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
> + if (ret)
> + return ret;
> + *obj_fd = args.fd;
> + return 0;
> +}
> +
> +int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = obj_fd;
> + args.handle = 0;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
> + if (ret)
> + return ret;
> + *handle = args.handle;
> + return 0;
> +}
> +
> +int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd)
> +{
> + struct drm_syncobj_handle args;
> +
> + memclear(args);
> + args.fd = sync_file_fd;
> + args.handle = handle;
> + args.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE;
> + return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
> +}
> +
> +int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = -1;
> + args.handle = handle;
> + args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
> + if (ret)
> + return ret;
> + *sync_file_fd = args.fd;
> + return 0;
> +}
> diff --git a/xf86drm.h b/xf86drm.h
> index 74f54f1..2855a3e 100644
> --- a/xf86drm.h
> +++ b/xf86drm.h
> @@ -853,6 +853,14 @@ extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_device
>
> extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
>
> +extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle);
> +extern int drmSyncobjDestroy(int fd, uint32_t handle);
> +extern int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd);
> +extern int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle);
> +
> +extern int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd);
> +extern int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd);
> +
> #if defined(__cplusplus)
> }
> #endif
> --
> 2.9.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] libdrm: add drm syncobj create/destroy/import/export
2017-09-08 16:29 ` Marek Olšák
@ 2017-09-08 20:08 ` Dave Airlie
2017-09-09 0:17 ` Marek Olšák
0 siblings, 1 reply; 7+ messages in thread
From: Dave Airlie @ 2017-09-08 20:08 UTC (permalink / raw)
To: Marek Olšák; +Cc: dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 5979 bytes --]
On 9 Sep. 2017 2:30 am, "Marek Olšák" <maraeo@gmail.com> wrote:
What's the difference between HandleToFD and ExportSyncFile?
One just gives you an FD for sharing the syncobj itself, the other exports
the syncobj state into a sync file and you get to do sync file stuff with
it.
A) is for process sharing
B) for interop with sync files
Dave.
Thanks,
Marek
On Sat, Jun 17, 2017 at 3:06 AM, Dave Airlie <airlied@gmail.com> wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> These ioctls are now in drm next so add the first set of libdrm APIs.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
> include/drm/drm.h | 26 ++++++++++++++++++
> xf86drm.c | 81 ++++++++++++++++++++++++++++++
+++++++++++++++++++++++++
> xf86drm.h | 8 ++++++
> 3 files changed, 115 insertions(+)
>
> diff --git a/include/drm/drm.h b/include/drm/drm.h
> index 1e7a4bc..bf3674a 100644
> --- a/include/drm/drm.h
> +++ b/include/drm/drm.h
> @@ -642,6 +642,7 @@ struct drm_gem_open {
> #define DRM_CAP_ADDFB2_MODIFIERS 0x10
> #define DRM_CAP_PAGE_FLIP_TARGET 0x11
> #define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
> +#define DRM_CAP_SYNCOBJ 0x13
>
> /** DRM_IOCTL_GET_CAP ioctl argument type */
> struct drm_get_cap {
> @@ -691,6 +692,26 @@ struct drm_prime_handle {
> __s32 fd;
> };
>
> +struct drm_syncobj_create {
> + __u32 handle;
> + __u32 flags;
> +};
> +
> +struct drm_syncobj_destroy {
> + __u32 handle;
> + __u32 pad;
> +};
> +
> +#define DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE (1 << 0)
> +#define DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE (1 << 0)
> +struct drm_syncobj_handle {
> + __u32 handle;
> + __u32 flags;
> +
> + __s32 fd;
> + __u32 pad;
> +};
> +
> #if defined(__cplusplus)
> }
> #endif
> @@ -809,6 +830,11 @@ extern "C" {
> #define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct
drm_mode_create_blob)
> #define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct
drm_mode_destroy_blob)
>
> +#define DRM_IOCTL_SYNCOBJ_CREATE DRM_IOWR(0xBF, struct
drm_syncobj_create)
> +#define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct
drm_syncobj_destroy)
> +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct
drm_syncobj_handle)
> +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct
drm_syncobj_handle)
> +
> /**
> * Device specific ioctls should only be in their respective headers
> * The device specific ioctl range is from 0x40 to 0x9f.
> diff --git a/xf86drm.c b/xf86drm.c
> index 728ac78..2ac3f26 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -4146,3 +4146,84 @@ char *drmGetDeviceNameFromFd2(int fd)
> return strdup(node);
> #endif
> }
> +
> +int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle)
> +{
> + struct drm_syncobj_create args;
> + int ret;
> +
> + memclear(args);
> + args.flags = flags;
> + args.handle = 0;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
> + if (ret)
> + return ret;
> + *handle = args.handle;
> + return 0;
> +}
> +
> +int drmSyncobjDestroy(int fd, uint32_t handle)
> +{
> + struct drm_syncobj_destroy args;
> +
> + memclear(args);
> + args.handle = handle;
> + return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
> +}
> +
> +int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = -1;
> + args.handle = handle;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
> + if (ret)
> + return ret;
> + *obj_fd = args.fd;
> + return 0;
> +}
> +
> +int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = obj_fd;
> + args.handle = 0;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
> + if (ret)
> + return ret;
> + *handle = args.handle;
> + return 0;
> +}
> +
> +int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd)
> +{
> + struct drm_syncobj_handle args;
> +
> + memclear(args);
> + args.fd = sync_file_fd;
> + args.handle = handle;
> + args.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE;
> + return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
> +}
> +
> +int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd)
> +{
> + struct drm_syncobj_handle args;
> + int ret;
> +
> + memclear(args);
> + args.fd = -1;
> + args.handle = handle;
> + args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE;
> + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
> + if (ret)
> + return ret;
> + *sync_file_fd = args.fd;
> + return 0;
> +}
> diff --git a/xf86drm.h b/xf86drm.h
> index 74f54f1..2855a3e 100644
> --- a/xf86drm.h
> +++ b/xf86drm.h
> @@ -853,6 +853,14 @@ extern int drmGetDevices2(uint32_t flags,
drmDevicePtr devices[], int max_device
>
> extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
>
> +extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle);
> +extern int drmSyncobjDestroy(int fd, uint32_t handle);
> +extern int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd);
> +extern int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle);
> +
> +extern int drmSyncobjImportSyncFile(int fd, uint32_t handle, int
sync_file_fd);
> +extern int drmSyncobjExportSyncFile(int fd, uint32_t handle, int
*sync_file_fd);
> +
> #if defined(__cplusplus)
> }
> #endif
> --
> 2.9.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
[-- Attachment #1.2: Type: text/html, Size: 8535 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] libdrm: add drm syncobj create/destroy/import/export
2017-09-08 20:08 ` Dave Airlie
@ 2017-09-09 0:17 ` Marek Olšák
2017-09-09 2:14 ` Dave Airlie
0 siblings, 1 reply; 7+ messages in thread
From: Marek Olšák @ 2017-09-09 0:17 UTC (permalink / raw)
To: Dave Airlie; +Cc: dri-devel
On Fri, Sep 8, 2017 at 10:08 PM, Dave Airlie <airlied@gmail.com> wrote:
>
>
> On 9 Sep. 2017 2:30 am, "Marek Olšák" <maraeo@gmail.com> wrote:
>
> What's the difference between HandleToFD and ExportSyncFile?
>
>
> One just gives you an FD for sharing the syncobj itself, the other exports
> the syncobj state into a sync file and you get to do sync file stuff with
> it.
>
> A) is for process sharing
> B) for interop with sync files
i'm still confused, but If I understand it correctly, we have 4 kinds
fences now:
- amdgpu per-ring sequence numbers
- syncobj
- HandleToFD for sharing a syncobj (this is not an Android fence)
- ExportSyncFile, which is an Android fence
Is that right?
Thanks,
Marek
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libdrm: add drm syncobj create/destroy/import/export
2017-09-09 0:17 ` Marek Olšák
@ 2017-09-09 2:14 ` Dave Airlie
0 siblings, 0 replies; 7+ messages in thread
From: Dave Airlie @ 2017-09-09 2:14 UTC (permalink / raw)
To: Marek Olšák; +Cc: dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 1128 bytes --]
On 9 Sep. 2017 10:17 am, "Marek Olšák" <maraeo@gmail.com> wrote:
On Fri, Sep 8, 2017 at 10:08 PM, Dave Airlie <airlied@gmail.com> wrote:
>
>
> On 9 Sep. 2017 2:30 am, "Marek Olšák" <maraeo@gmail.com> wrote:
>
> What's the difference between HandleToFD and ExportSyncFile?
>
>
> One just gives you an FD for sharing the syncobj itself, the other exports
> the syncobj state into a sync file and you get to do sync file stuff with
> it.
>
> A) is for process sharing
> B) for interop with sync files
i'm still confused, but If I understand it correctly, we have 4 kinds
fences now:
- amdgpu per-ring sequence numbers
- syncobj
- HandleToFD for sharing a syncobj (this is not an Android fence)
- ExportSyncFile, which is an Android fence
Yes, syncobj is pretty much Vulkan fence and semaphores semantics, sync
file are android fence semantics.
Syncobj FD is just for sharing and getting back the same under lying object
whereas sync file has a lot of other semantics that are undesirable when
you just want to share between APIs and processes.
Dave.
Is that right?
Thanks,
Marek
[-- Attachment #1.2: Type: text/html, Size: 2018 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-09-09 2:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-17 1:06 [PATCH] libdrm: add drm syncobj create/destroy/import/export Dave Airlie
2017-06-26 20:55 ` Dave Airlie
2017-06-27 22:56 ` Eric Anholt
2017-09-08 16:29 ` Marek Olšák
2017-09-08 20:08 ` Dave Airlie
2017-09-09 0:17 ` Marek Olšák
2017-09-09 2:14 ` Dave Airlie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox