I would rather just use a single IOCTL for this and handle point 0 as distinction if we should add a new point or replace the binary one. Christian. Am 07.12.18 um 10:55 schrieb Chunming Zhou: > we need to import/export timeline point > > Signed-off-by: Chunming Zhou <david1.zhou@xxxxxxx> > --- > drivers/gpu/drm/drm_internal.h | 4 +++ > drivers/gpu/drm/drm_ioctl.c | 6 ++++ > drivers/gpu/drm/drm_syncobj.c | 66 ++++++++++++++++++++++++++++++++++ > include/uapi/drm/drm.h | 10 ++++++ > 4 files changed, 86 insertions(+) > > diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h > index dab4d5936441..ecbe3d51a702 100644 > --- a/drivers/gpu/drm/drm_internal.h > +++ b/drivers/gpu/drm/drm_internal.h > @@ -176,6 +176,10 @@ int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, > struct drm_file *file_private); > int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, > struct drm_file *file_private); > +int drm_syncobj_binary_to_timeline_ioctl(struct drm_device *dev, void *data, > + struct drm_file *file_private); > +int drm_syncobj_timeline_to_binary_ioctl(struct drm_device *dev, void *data, > + struct drm_file *file_private); > int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data, > struct drm_file *file_private); > int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data, > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > index 7578ef6dc1d1..6b417e3c3ea5 100644 > --- a/drivers/gpu/drm/drm_ioctl.c > +++ b/drivers/gpu/drm/drm_ioctl.c > @@ -673,6 +673,12 @@ static const struct drm_ioctl_desc drm_ioctls[] = { > DRM_UNLOCKED|DRM_RENDER_ALLOW), > DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, drm_syncobj_fd_to_handle_ioctl, > DRM_UNLOCKED|DRM_RENDER_ALLOW), > + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_BINARY_TO_TIMELINE, > + drm_syncobj_binary_to_timeline_ioctl, > + DRM_UNLOCKED|DRM_RENDER_ALLOW), > + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_TO_BINARY, > + drm_syncobj_timeline_to_binary_ioctl, > + DRM_UNLOCKED|DRM_RENDER_ALLOW), > DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_WAIT, drm_syncobj_wait_ioctl, > DRM_UNLOCKED|DRM_RENDER_ALLOW), > DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT, drm_syncobj_timeline_wait_ioctl, > diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c > index 282982e58dbd..cf4daa670252 100644 > --- a/drivers/gpu/drm/drm_syncobj.c > +++ b/drivers/gpu/drm/drm_syncobj.c > @@ -670,6 +670,72 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, > &args->handle); > } > > +int > +drm_syncobj_binary_to_timeline_ioctl(struct drm_device *dev, void *data, > + struct drm_file *file_private) > +{ > + struct drm_syncobj_transfer *args = data; > + struct drm_syncobj *timeline_syncobj = NULL; > + struct dma_fence *fence; > + struct dma_fence_chain *chain; > + int ret; > + > + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) > + return -ENODEV; > + > + if (args->pad) > + return -EINVAL; > + > + timeline_syncobj = drm_syncobj_find(file_private, args->timeline_handle); > + if (!timeline_syncobj) { > + return -ENOENT; > + } > + ret = drm_syncobj_find_fence(file_private, args->binary_handle, 0, 0, > + &fence); > + if (ret) > + goto err; > + chain = kzalloc(sizeof(struct dma_fence_chain), GFP_KERNEL); > + if (!chain) > + goto err1; > + drm_syncobj_add_point(timeline_syncobj, chain, fence, args->point); > +err1: > + dma_fence_put(fence); > +err: > + drm_syncobj_put(timeline_syncobj); > + > + return ret; > +} > + > +int > +drm_syncobj_timeline_to_binary_ioctl(struct drm_device *dev, void *data, > + struct drm_file *file_private) > +{ > + struct drm_syncobj_transfer *args = data; > + struct drm_syncobj *binary_syncobj = NULL; > + struct dma_fence *fence; > + int ret; > + > + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) > + return -ENODEV; > + > + if (args->pad) > + return -EINVAL; > + > + binary_syncobj = drm_syncobj_find(file_private, args->binary_handle); > + if (!binary_syncobj) > + return -ENOENT; > + ret = drm_syncobj_find_fence(file_private, args->timeline_handle, > + args->point, args->flags, &fence); > + if (ret) > + goto err; > + drm_syncobj_replace_fence(binary_syncobj, fence); > + dma_fence_put(fence); > +err: > + drm_syncobj_put(binary_syncobj); > + > + return ret; > +} > + > static void syncobj_wait_fence_func(struct dma_fence *fence, > struct dma_fence_cb *cb) > { > diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h > index b2c36f2b2599..88d6129d4a18 100644 > --- a/include/uapi/drm/drm.h > +++ b/include/uapi/drm/drm.h > @@ -735,6 +735,14 @@ struct drm_syncobj_handle { > __u32 pad; > }; > > +struct drm_syncobj_transfer { > + __u32 binary_handle; > + __u32 timeline_handle; > + __u64 point; > + __u32 flags; > + __u32 pad; > +}; > + > #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) > #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) > #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) > @@ -933,6 +941,8 @@ extern "C" { > > #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) > #define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array) > +#define DRM_IOCTL_SYNCOBJ_BINARY_TO_TIMELINE DRM_IOWR(0xCC, struct drm_syncobj_transfer) > +#define DRM_IOCTL_SYNCOBJ_TIMELINE_TO_BINARY DRM_IOWR(0xCD, struct drm_syncobj_transfer) > > /** > * Device specific ioctls should only be in their respective headers _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx