Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4304270imu; Mon, 12 Nov 2018 08:53:22 -0800 (PST) X-Google-Smtp-Source: AJdET5e6a8A91/d2CIx9kJrM75WGonz5brdjPp4s6iGIFzTJw4KDbSPcq1gO4pv4mpoK9/NV5Fj+ X-Received: by 2002:a17:902:8d83:: with SMTP id v3-v6mr1651720plo.162.1542041602614; Mon, 12 Nov 2018 08:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542041602; cv=none; d=google.com; s=arc-20160816; b=CGgULFhWoaFpTZWFvvs8rIPw8ZtLnHn2848ZnBnTSQmf8SriygMU60zRB2vjj3QEWB SdQBpxKHN8u6RVpk/VI1jfTsDGrMo2rsgiJQ0TWHVN1te8oBLNfJknRGStcTJk21vULj jzsqLLwCzt8JlOCvBCJucbf10vjEzQ+SVH9xC9UFZjw17FTb7KD+HEtf8GLzXHJ+tvis b5ftPCwnGadnKJ60cRgHlX8K5H7ntq3wVd+fXmO33wV4NTHVwKzBPMB8rrJyoZzCcDDA DeWIvk73wbEpXYP4trH6Kufu6+sxb2+UOsDdx1RAspJDAhIe3k+0B19nF2QQRm7tbCRh CHRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=83lERFsY/f/QG0rZftYZghEAKomRz1WlesJRwpXoYOc=; b=RDJvbLqcaD+TV4lthdoUWc2hUCzLIOM+TyRl8wj3zUrrv9T8d79wDQdha15H+Rr0CD WK3eSbAsFKa6L9bwuvsm9LuzKmhwjEieXinSb8njrBNVbljK52JOBP7YzRXLxLBYlhDz 63O0deN9vY+gjxS/uho+njJK9RW2JKICZNlCNTFprJu1+hmbMZx7qhGredIgsnih481M xuLrn6jIOATCB/ER98tNZqYiyTfJSelTm+M1bz6/ZreV8+mQ4CcgVZQpz6lQOJfyl41i lhz2EW8lfm6XcWj6My0dWEW7UtggCM37W7UHdc6Kfn+rF8883VnyeiIDK7Ohpwc4cV7X czhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73-v6si18444421pfs.7.2018.11.12.08.53.07; Mon, 12 Nov 2018 08:53:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730122AbeKMCqN (ORCPT + 99 others); Mon, 12 Nov 2018 21:46:13 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:54988 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727185AbeKMCqM (ORCPT ); Mon, 12 Nov 2018 21:46:12 -0500 Received: from localhost.localdomain (unknown [IPv6:2a02:8109:92c0:207d:68ed:6b77:5dd1:d3e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: robertfoss) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id A5E9F27E98C; Mon, 12 Nov 2018 16:52:07 +0000 (GMT) From: Robert Foss To: airlied@linux.ie, kraxel@redhat.com, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Rob Herring , Gustavo Padovan , Emil Velikov Cc: Robert Foss Subject: [PATCH v5 2/4] drm/virtio: add uapi for in and out explicit fences Date: Mon, 12 Nov 2018 17:51:55 +0100 Message-Id: <20181112165157.32765-3-robert.foss@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181112165157.32765-1-robert.foss@collabora.com> References: <20181112165157.32765-1-robert.foss@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new field called fence_fd that will be used by userspace to send in-fences to the kernel and receive out-fences created by the kernel. This uapi enables virtio to take advantage of explicit synchronization of dma-bufs. There are two new flags: * VIRTGPU_EXECBUF_FENCE_FD_IN to be used when passing an in-fence fd. * VIRTGPU_EXECBUF_FENCE_FD_OUT to be used when requesting an out-fence fd The execbuffer IOCTL is now read-write to allow the userspace to read the out-fence. On error -1 should be returned in the fence_fd field. Signed-off-by: Gustavo Padovan Signed-off-by: Robert Foss Reviewed-by: Emil Velikov --- Changes since v4: - Emil/Gerd: Improved commit message and fence_fd comment Changes since v3: - Emil: Move fence_fd assignment to after sanity checks - Emil: Added r-b drivers/gpu/drm/virtio/virtgpu_ioctl.c | 5 +++++ include/uapi/drm/virtgpu_drm.h | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index d69fc356df0a..3d497835b0f5 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -119,6 +119,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, if (vgdev->has_virgl_3d == false) return -ENOSYS; + if ((exbuf->flags & ~VIRTGPU_EXECBUF_FLAGS)) + return -EINVAL; + + exbuf->fence_fd = -1; + INIT_LIST_HEAD(&validate_list); if (exbuf->num_bo_handles) { diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index 9a781f0611df..91062f4ac7c5 100644 --- a/include/uapi/drm/virtgpu_drm.h +++ b/include/uapi/drm/virtgpu_drm.h @@ -47,6 +47,13 @@ extern "C" { #define DRM_VIRTGPU_WAIT 0x08 #define DRM_VIRTGPU_GET_CAPS 0x09 +#define VIRTGPU_EXECBUF_FENCE_FD_IN 0x01 +#define VIRTGPU_EXECBUF_FENCE_FD_OUT 0x02 +#define VIRTGPU_EXECBUF_FLAGS (\ + VIRTGPU_EXECBUF_FENCE_FD_IN |\ + VIRTGPU_EXECBUF_FENCE_FD_OUT |\ + 0) + struct drm_virtgpu_map { __u64 offset; /* use for mmap system call */ __u32 handle; @@ -54,12 +61,12 @@ struct drm_virtgpu_map { }; struct drm_virtgpu_execbuffer { - __u32 flags; /* for future use */ + __u32 flags; __u32 size; __u64 command; /* void* */ __u64 bo_handles; __u32 num_bo_handles; - __u32 pad; + __s32 fence_fd; }; #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */ @@ -137,7 +144,7 @@ struct drm_virtgpu_get_caps { DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map) #define DRM_IOCTL_VIRTGPU_EXECBUFFER \ - DRM_IOW(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\ + DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\ struct drm_virtgpu_execbuffer) #define DRM_IOCTL_VIRTGPU_GETPARAM \ -- 2.17.1