[PATCH 1/5] drm: introduce sync objects (v3)
From: Dave Airlie Sync objects are new toplevel drm object, that contain a pointer to a fence. This fence can be updated via command submission ioctls via drivers. There is also a generic wait obj API modelled on the vulkan wait API (with code modelled on some amdgpu code). These objects can be converted to an opaque fd that can be passes between processes. v2: rename reference/unreference to put/get (Chris) fix leaked reference (David Zhou) drop mutex in favour of cmpxchg (Chris) v3: cleanups from danvet, rebase on drm_fops rename check fd_flags is 0 in ioctls. Reviewed-by: Sean Paul Signed-off-by: Dave Airlie --- Documentation/gpu/drm-internals.rst | 3 + Documentation/gpu/drm-mm.rst| 12 ++ drivers/gpu/drm/Makefile| 2 +- drivers/gpu/drm/drm_file.c | 8 + drivers/gpu/drm/drm_internal.h | 13 ++ drivers/gpu/drm/drm_ioctl.c | 12 ++ drivers/gpu/drm/drm_syncobj.c | 377 include/drm/drmP.h | 1 - include/drm/drm_drv.h | 1 + include/drm/drm_file.h | 5 + include/drm/drm_syncobj.h | 87 + include/uapi/drm/drm.h | 24 +++ 12 files changed, 543 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/drm_syncobj.c create mode 100644 include/drm/drm_syncobj.h diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst index babfb61..2b23d78 100644 --- a/Documentation/gpu/drm-internals.rst +++ b/Documentation/gpu/drm-internals.rst @@ -98,6 +98,9 @@ DRIVER_ATOMIC implement appropriate obj->atomic_get_property() vfuncs for any modeset objects with driver specific properties. +DRIVER_SYNCOBJ +Driver support drm sync objects. + Major, Minor and Patchlevel ~~~ diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst index 96b9c34..9412798 100644 --- a/Documentation/gpu/drm-mm.rst +++ b/Documentation/gpu/drm-mm.rst @@ -484,3 +484,15 @@ DRM Cache Handling .. kernel-doc:: drivers/gpu/drm/drm_cache.c :export: + +DRM Sync Objects +=== + +.. kernel-doc:: drivers/gpu/drm/drm_syncobj.c + :doc: Overview + +.. kernel-doc:: include/drm/drm_syncobj.h + :export: + +.. kernel-doc:: drivers/gpu/drm/drm_syncobj.c + :export: diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 59f0f9b..6f42188 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -16,7 +16,7 @@ drm-y :=drm_auth.o drm_bufs.o drm_cache.o \ drm_framebuffer.o drm_connector.o drm_blend.o \ drm_encoder.o drm_mode_object.o drm_property.o \ drm_plane.o drm_color_mgmt.o drm_print.o \ - drm_dumb_buffers.o drm_mode_config.o + drm_dumb_buffers.o drm_mode_config.o drm_syncobj.o drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o drm-$(CONFIG_DRM_VM) += drm_vm.o diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 3783b65..a20d6a9 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -229,6 +229,9 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_open(dev, priv); + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + drm_syncobj_open(priv); + if (drm_core_check_feature(dev, DRIVER_PRIME)) drm_prime_init_file_private(&priv->prime); @@ -276,6 +279,8 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) out_prime_destroy: if (drm_core_check_feature(dev, DRIVER_PRIME)) drm_prime_destroy_file_private(&priv->prime); + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + drm_syncobj_release(priv); if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_release(dev, priv); put_pid(priv->pid); @@ -398,6 +403,9 @@ int drm_release(struct inode *inode, struct file *filp) drm_property_destroy_user_blobs(dev, file_priv); } + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + drm_syncobj_release(file_priv); + if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_release(dev, file_priv); diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 3d8e8f8..3fdef2c 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -142,4 +142,17 @@ static inline int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc) { return 0; } + #endif + +/* drm_syncobj.c */ +void drm_syncobj_open(struct drm_file *file_private); +void drm_syncobj_release(struct drm_file *file_private); +int drm_syncobj_create_ioctl(struct drm_device *dev, void *data, +struct drm_file *file_private); +int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data
[PATCH 1/5] drm: introduce sync objects (v3)
From: Dave Airlie Sync objects are new toplevel drm object, that contain a pointer to a fence. This fence can be updated via command submission ioctls via drivers. There is also a generic wait obj API modelled on the vulkan wait API (with code modelled on some amdgpu code). These objects can be converted to an opaque fd that can be passes between processes. v2: rename reference/unreference to put/get (Chris) fix leaked reference (David Zhou) drop mutex in favour of cmpxchg (Chris) v3: cleanups from danvet, rebase on drm_fops rename check fd_flags is 0 in ioctls. Reviewed-by: Sean Paul Signed-off-by: Dave Airlie --- Documentation/gpu/drm-internals.rst | 3 + Documentation/gpu/drm-mm.rst| 12 ++ drivers/gpu/drm/Makefile| 2 +- drivers/gpu/drm/drm_file.c | 8 + drivers/gpu/drm/drm_internal.h | 13 ++ drivers/gpu/drm/drm_ioctl.c | 12 ++ drivers/gpu/drm/drm_syncobj.c | 377 include/drm/drmP.h | 1 - include/drm/drm_drv.h | 1 + include/drm/drm_file.h | 5 + include/drm/drm_syncobj.h | 87 + include/uapi/drm/drm.h | 24 +++ 12 files changed, 543 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/drm_syncobj.c create mode 100644 include/drm/drm_syncobj.h diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst index babfb61..2b23d78 100644 --- a/Documentation/gpu/drm-internals.rst +++ b/Documentation/gpu/drm-internals.rst @@ -98,6 +98,9 @@ DRIVER_ATOMIC implement appropriate obj->atomic_get_property() vfuncs for any modeset objects with driver specific properties. +DRIVER_SYNCOBJ +Driver support drm sync objects. + Major, Minor and Patchlevel ~~~ diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst index 96b9c34..9412798 100644 --- a/Documentation/gpu/drm-mm.rst +++ b/Documentation/gpu/drm-mm.rst @@ -484,3 +484,15 @@ DRM Cache Handling .. kernel-doc:: drivers/gpu/drm/drm_cache.c :export: + +DRM Sync Objects +=== + +.. kernel-doc:: drivers/gpu/drm/drm_syncobj.c + :doc: Overview + +.. kernel-doc:: include/drm/drm_syncobj.h + :export: + +.. kernel-doc:: drivers/gpu/drm/drm_syncobj.c + :export: diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 59f0f9b..6f42188 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -16,7 +16,7 @@ drm-y :=drm_auth.o drm_bufs.o drm_cache.o \ drm_framebuffer.o drm_connector.o drm_blend.o \ drm_encoder.o drm_mode_object.o drm_property.o \ drm_plane.o drm_color_mgmt.o drm_print.o \ - drm_dumb_buffers.o drm_mode_config.o + drm_dumb_buffers.o drm_mode_config.o drm_syncobj.o drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o drm-$(CONFIG_DRM_VM) += drm_vm.o diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 3783b65..a20d6a9 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -229,6 +229,9 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_open(dev, priv); + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + drm_syncobj_open(priv); + if (drm_core_check_feature(dev, DRIVER_PRIME)) drm_prime_init_file_private(&priv->prime); @@ -276,6 +279,8 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) out_prime_destroy: if (drm_core_check_feature(dev, DRIVER_PRIME)) drm_prime_destroy_file_private(&priv->prime); + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + drm_syncobj_release(priv); if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_release(dev, priv); put_pid(priv->pid); @@ -398,6 +403,9 @@ int drm_release(struct inode *inode, struct file *filp) drm_property_destroy_user_blobs(dev, file_priv); } + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + drm_syncobj_release(file_priv); + if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_release(dev, file_priv); diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 3d8e8f8..3fdef2c 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -142,4 +142,17 @@ static inline int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc) { return 0; } + #endif + +/* drm_syncobj.c */ +void drm_syncobj_open(struct drm_file *file_private); +void drm_syncobj_release(struct drm_file *file_private); +int drm_syncobj_create_ioctl(struct drm_device *dev, void *data, +struct drm_file *file_private); +int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data
Re: [PATCH 1/5] drm: introduce sync objects (v3)
I can't really review for all of the kernel details (though the seem ok to me) so this mostly applies to the API: Reviewed-by: Jason Ekstrand On Wed, May 24, 2017 at 12:06 AM, Dave Airlie wrote: > From: Dave Airlie > > Sync objects are new toplevel drm object, that contain a > pointer to a fence. This fence can be updated via command > submission ioctls via drivers. > > There is also a generic wait obj API modelled on the vulkan > wait API (with code modelled on some amdgpu code). > > These objects can be converted to an opaque fd that can be > passes between processes. > > v2: rename reference/unreference to put/get (Chris) > fix leaked reference (David Zhou) > drop mutex in favour of cmpxchg (Chris) > v3: cleanups from danvet, rebase on drm_fops rename > check fd_flags is 0 in ioctls. > > Reviewed-by: Sean Paul > Signed-off-by: Dave Airlie > --- > Documentation/gpu/drm-internals.rst | 3 + > Documentation/gpu/drm-mm.rst| 12 ++ > drivers/gpu/drm/Makefile| 2 +- > drivers/gpu/drm/drm_file.c | 8 + > drivers/gpu/drm/drm_internal.h | 13 ++ > drivers/gpu/drm/drm_ioctl.c | 12 ++ > drivers/gpu/drm/drm_syncobj.c | 377 ++ > ++ > include/drm/drmP.h | 1 - > include/drm/drm_drv.h | 1 + > include/drm/drm_file.h | 5 + > include/drm/drm_syncobj.h | 87 + > include/uapi/drm/drm.h | 24 +++ > 12 files changed, 543 insertions(+), 2 deletions(-) > create mode 100644 drivers/gpu/drm/drm_syncobj.c > create mode 100644 include/drm/drm_syncobj.h > > diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm- > internals.rst > index babfb61..2b23d78 100644 > --- a/Documentation/gpu/drm-internals.rst > +++ b/Documentation/gpu/drm-internals.rst > @@ -98,6 +98,9 @@ DRIVER_ATOMIC > implement appropriate obj->atomic_get_property() vfuncs for any > modeset objects with driver specific properties. > > +DRIVER_SYNCOBJ > +Driver support drm sync objects. > + > Major, Minor and Patchlevel > ~~~ > > diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst > index 96b9c34..9412798 100644 > --- a/Documentation/gpu/drm-mm.rst > +++ b/Documentation/gpu/drm-mm.rst > @@ -484,3 +484,15 @@ DRM Cache Handling > > .. kernel-doc:: drivers/gpu/drm/drm_cache.c > :export: > + > +DRM Sync Objects > +=== > + > +.. kernel-doc:: drivers/gpu/drm/drm_syncobj.c > + :doc: Overview > + > +.. kernel-doc:: include/drm/drm_syncobj.h > + :export: > + > +.. kernel-doc:: drivers/gpu/drm/drm_syncobj.c > + :export: > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index 59f0f9b..6f42188 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -16,7 +16,7 @@ drm-y :=drm_auth.o drm_bufs.o drm_cache.o \ > drm_framebuffer.o drm_connector.o drm_blend.o \ > drm_encoder.o drm_mode_object.o drm_property.o \ > drm_plane.o drm_color_mgmt.o drm_print.o \ > - drm_dumb_buffers.o drm_mode_config.o > + drm_dumb_buffers.o drm_mode_config.o drm_syncobj.o > > drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o > drm-$(CONFIG_DRM_VM) += drm_vm.o > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c > index 3783b65..a20d6a9 100644 > --- a/drivers/gpu/drm/drm_file.c > +++ b/drivers/gpu/drm/drm_file.c > @@ -229,6 +229,9 @@ static int drm_open_helper(struct file *filp, struct > drm_minor *minor) > if (drm_core_check_feature(dev, DRIVER_GEM)) > drm_gem_open(dev, priv); > > + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) > + drm_syncobj_open(priv); > + > if (drm_core_check_feature(dev, DRIVER_PRIME)) > drm_prime_init_file_private(&priv->prime); > > @@ -276,6 +279,8 @@ static int drm_open_helper(struct file *filp, struct > drm_minor *minor) > out_prime_destroy: > if (drm_core_check_feature(dev, DRIVER_PRIME)) > drm_prime_destroy_file_private(&priv->prime); > + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) > + drm_syncobj_release(priv); > if (drm_core_check_feature(dev, DRIVER_GEM)) > drm_gem_release(dev, priv); > put_pid(priv->pid); > @@ -398,6 +403,9 @@ int drm_release(struct inode *inode, struct file *filp) > drm_property_destroy_user_blobs(dev, file_priv); > } > > + if (drm_core_check_feature(dev, DRIVER_SYNCOBJ)) > + drm_syncobj_release(file_priv); > + > if (drm_core_check_feature(dev, DRIVER_GEM)) > drm_gem_release(dev, file_priv); > > diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_ > internal.h > index 3d8e8f8..3fdef2c 100644 > --- a/drivers/gpu/drm/drm_internal.h > +++ b/drivers/gpu/drm/drm_internal.h > @@ -142,4 +142,17
Re: [PATCH 1/5] drm: introduce sync objects (v3)
On Wed, May 24, 2017 at 05:06:11PM +1000, Dave Airlie wrote: > From: Dave Airlie > > Sync objects are new toplevel drm object, that contain a > pointer to a fence. This fence can be updated via command > submission ioctls via drivers. > > There is also a generic wait obj API modelled on the vulkan > wait API (with code modelled on some amdgpu code). > > These objects can be converted to an opaque fd that can be > passes between processes. > > v2: rename reference/unreference to put/get (Chris) > fix leaked reference (David Zhou) > drop mutex in favour of cmpxchg (Chris) > v3: cleanups from danvet, rebase on drm_fops rename > check fd_flags is 0 in ioctls. > > Reviewed-by: Sean Paul > Signed-off-by: Dave Airlie > --- > diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h > index 42d9f64..96c5c78 100644 > --- a/include/uapi/drm/drm.h > +++ b/include/uapi/drm/drm.h > @@ -648,6 +648,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 { > @@ -697,6 +698,24 @@ struct drm_prime_handle { > __s32 fd; > }; > > +struct drm_syncobj_create { > + __u32 handle; > + __u32 flags; > +}; > + > +struct drm_syncobj_destroy { > + __u32 handle; > + __u32 pad; > +}; > + > +struct drm_syncobj_handle { > + __u32 handle; > + __u32 flags; > + > + __s32 fd; > + __u32 pad; > +}; > + > #if defined(__cplusplus) > } > #endif > @@ -815,6 +834,11 @@ extern "C" { > #define DRM_IOCTL_MODE_CREATEPROPBLOBDRM_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_DESTROYDRM_IOWR(0xC0, struct > drm_syncobj_destroy) These two only need DRM_IOW. > +#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) With that, Reviewed-by: Chris Wilson -Chris -- Chris Wilson, Intel Open Source Technology Centre ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 1/5] drm: introduce sync objects (v3)
On 25 May 2017 at 18:30, Chris Wilson wrote: > On Wed, May 24, 2017 at 05:06:11PM +1000, Dave Airlie wrote: >> From: Dave Airlie >> >> Sync objects are new toplevel drm object, that contain a >> pointer to a fence. This fence can be updated via command >> submission ioctls via drivers. >> >> There is also a generic wait obj API modelled on the vulkan >> wait API (with code modelled on some amdgpu code). >> >> These objects can be converted to an opaque fd that can be >> passes between processes. >> >> v2: rename reference/unreference to put/get (Chris) >> fix leaked reference (David Zhou) >> drop mutex in favour of cmpxchg (Chris) >> v3: cleanups from danvet, rebase on drm_fops rename >> check fd_flags is 0 in ioctls. >> >> Reviewed-by: Sean Paul >> Signed-off-by: Dave Airlie >> --- >> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h >> index 42d9f64..96c5c78 100644 >> --- a/include/uapi/drm/drm.h >> +++ b/include/uapi/drm/drm.h >> @@ -648,6 +648,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 { >> @@ -697,6 +698,24 @@ struct drm_prime_handle { >> __s32 fd; >> }; >> >> +struct drm_syncobj_create { >> + __u32 handle; >> + __u32 flags; >> +}; >> + >> +struct drm_syncobj_destroy { >> + __u32 handle; >> + __u32 pad; >> +}; >> + >> +struct drm_syncobj_handle { >> + __u32 handle; >> + __u32 flags; >> + >> + __s32 fd; >> + __u32 pad; >> +}; >> + >> #if defined(__cplusplus) >> } >> #endif >> @@ -815,6 +834,11 @@ extern "C" { >> #define DRM_IOCTL_MODE_CREATEPROPBLOBDRM_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_DESTROYDRM_IOWR(0xC0, struct >> drm_syncobj_destroy) > > These two only need DRM_IOW. They do now, but at least create takes some flags, destroy is probably fine. are we okay to change these flags later? I can never remember and I'd rather not have to think about it too much. > > With that, > Reviewed-by: Chris Wilson Thanks, Dave. ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx