Re: [PATCH 4/5] drm/virtio: add out-fences support for explicit synchronization
From: Emil Velikov
Date: Wed Oct 31 2018 - 05:40:52 EST
Hi Rob,
On Thu, 25 Oct 2018 at 19:38, Robert Foss <robert.foss@xxxxxxxxxxxxx> wrote:
>
> From: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxx>
>
> On the out-fence side we get fence returned by the submitted draw call
> and attach it to a sync_file and send the sync_file fd to userspace. On
> error -1 is returned to userspace.
>
Can we have both an IN and OUT fence at the same time? Either way, please
mention that in the commit message.
> Signed-off-by: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxx>
> Signed-off-by: Robert Foss <robert.foss@xxxxxxxxxxxxx>
> Suggested-by: Rob Herring <robh@xxxxxxxxxx>
> ---
> drivers/gpu/drm/virtio/virtgpu_ioctl.c | 50 +++++++++++++++++++-------
> 1 file changed, 38 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index 0368195966aa..32e714a1c753 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> @@ -106,7 +106,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
> struct virtio_gpu_device *vgdev = dev->dev_private;
> struct virtio_gpu_fpriv *vfpriv = drm_file->driver_priv;
> struct drm_gem_object *gobj;
> - struct virtio_gpu_fence *fence;
> + struct virtio_gpu_fence *out_fence;
> struct virtio_gpu_object *qobj;
> int ret;
> uint32_t *bo_handles = NULL;
> @@ -116,7 +116,9 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
> int i;
> struct ww_acquire_ctx ticket;
> struct dma_fence *in_fence = NULL;
> + struct sync_file *sync_file;
> int in_fence_fd = exbuf->fence_fd;
> + int out_fence_fd = -1;
> void *buf;
>
> exbuf->fence_fd = -1;
> @@ -143,6 +145,14 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
> }
> }
>
> + if (exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_OUT) {
> + out_fence_fd = get_unused_fd_flags(O_CLOEXEC);
> + if (out_fence_fd < 0) {
> + ret = out_fence_fd;
> + goto out_in_fence;
> + }
> + }
> +
If the answer to the above is "no" we want a check around here.
With that the patch is
Reviewed-by: Emil Velikov <emil.velikov@xxxxxxxxxxxxx>
-Emil