Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2233993ima; Thu, 25 Oct 2018 11:38:49 -0700 (PDT) X-Google-Smtp-Source: AJdET5dVbawvtEKxvZWJKKkItv1HOuY92G3F079iaQfu3sSxcEArKe+y1H6n6jF/sqb7/080fEsf X-Received: by 2002:a62:c60a:: with SMTP id m10-v6mr338574pfg.15.1540492729545; Thu, 25 Oct 2018 11:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540492729; cv=none; d=google.com; s=arc-20160816; b=Ls0xAen96P0DiGnuBmWjBBgSCBkRf6tUtkixhayi7Cjm4Vb9+Mk7BgdJjx8vWA/ONE BcnFEWpIZuiB06l7Mk/i/LNXjOHPoKLcJ+V8BSnd3T0zZ3eniUqwz1+vcsEVAGL95/0Q QuRjhP/UUwTo9JdRMXEstKkRjtgRMdSjFIGKUFMGnWYBLtTYrYkW5arYBv5trioptTBt Rue9CeqzdsnI7g1R9+LVQ4O+BoVHrS8PM550Lw0Xm7AlPbLU77IF5SY8sHAHt9ZqgIP7 PhZCs3G14lonPqlOcdydND10pQybBBTTspPm0CjvL9JbOvbi4tMqHbUsFRwUIDJ8i9Yp k0TA== 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=m9klsukYWy82AjNBEq2eaAzbuOcpPPwtP1vAwrFmroQ=; b=yBDjnecE8eOHCPc+HBiMh3Aux1xsvFwXLxeT3ZF+0PsCBNkiqhNqrZQlt21HZd/mHo +WohILz3xCNXaNx+k3W+725QGwb96mdKmBhL7s2z40GEAkq1s05/chgRB5bgDyF+nrTW gdYNOwORKz9qRo+i6s7HPAlied08UP+pLutuHC4q9tUNPzre7esfpO5PIjh2gAIDLJsc vkC6Pw/Vp82GeYpcdQG8NXApao7dy3h3+o/hZZ9lrePKtn9dFdeep5kh4wPT4gRbDz9b dGNP7/IjauzyUlBu3qnQb39d0vQ5O7rWsml7rhV+tbq52iAtcRPzN5ZAJrq2zVyVCgLr pbaA== 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 l12-v6si8236772plc.172.2018.10.25.11.38.33; Thu, 25 Oct 2018 11:38:49 -0700 (PDT) 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 S1727658AbeJZDLm (ORCPT + 99 others); Thu, 25 Oct 2018 23:11:42 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43608 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727333AbeJZDLl (ORCPT ); Thu, 25 Oct 2018 23:11:41 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: robertfoss) with ESMTPSA id A76482756E8 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 2/5] drm/virtio: add uapi for in and out explicit fences Date: Thu, 25 Oct 2018 20:37:36 +0200 Message-Id: <20181025183739.9375-3-robert.foss@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025183739.9375-1-robert.foss@collabora.com> References: <20181025183739.9375-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 --- Changes since v2: - Since exbuf-flags is a new flag, check that unsupported flags aren't set. 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 d01a9ed100d1..1af289b28fc4 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -116,9 +116,14 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, struct ww_acquire_ctx ticket; void *buf; + exbuf->fence_fd = -1; + if (vgdev->has_virgl_3d == false) return -ENOSYS; + if ((exbuf->flags & ~VIRTGPU_EXECBUF_FLAGS)) + return -EINVAL; + 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