Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp454537imu; Mon, 5 Nov 2018 03:45:22 -0800 (PST) X-Google-Smtp-Source: AJdET5f2pmukMRHnEVJxaA5TBN3BlJ0QGMcO1M9c/GRetzzTJdej3T5mPrFotD7LvEqBbHhvou9/ X-Received: by 2002:a63:e54d:: with SMTP id z13-v6mr19601592pgj.169.1541418322311; Mon, 05 Nov 2018 03:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541418322; cv=none; d=google.com; s=arc-20160816; b=RVVqS8JcbDVaE4V06zR2ZrXnAp379NHa11QxfACHKoc9hKAUWFvIKv1DPXQrVAbwm1 cCHhCFx3YW7KEp1oht27saEsMzygkFJ6Uc7hjbHtQ0RGEWMKWFV+nYeoWoJVUaJsjo1Z JiLlFLTdiBj6BTUTlEGLOwl+EolM6VPqnAjqiN7SrUXFFi5W+CC3OJUKUYfQZQSs1Mhv cmeXK0fp4qvYh/r2oNgz60K70AukglC27ge6ckhtoM3Jxe9na9OGEom0CYNBYtvduI0W EoMjZScN2FH5a3il5YCSUtHFv4sLPzgIPaaZij+FofeLk4rXmwai/mbFsCnIphjpJ7xA OcMQ== 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=17xYO8xKlyTS+TDZRC9wtxAVswS96TZcrXjQ6maHV2M=; b=gJ7R00U1iPCCbFBqrA4eS69iIRPXZx0QvNnlnsWQHdCSM6bRQTtT1HeKmijY8NRiyS ipPUla/5kEDg9bczsh6fS5mktFdtkiijjfWDM6BT8VJ6arsg9DUT9aE7KtlKS8pGNHzr v5j8C1oYMQ7zIMEo2YkNwtcjmX8OD4LNIyAJj/i/VgcaOzy8VBlHSqF16aFi1tZbg0dL dUxsZWAYIuOE3fhKCED5zolWjgX+U97nxjTdjxlF/cPSteIff/dFdbjKnqNqTh3dN19Z Li4W/mUaRKkWbsBHlHT47vii9kHjeHdu2LPxd1IyvJh0T7B7PKWsydSwV+YQErdA08eB TpUg== 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 r20-v6si43151438pgm.28.2018.11.05.03.45.07; Mon, 05 Nov 2018 03:45: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 S1729172AbeKEVBZ (ORCPT + 99 others); Mon, 5 Nov 2018 16:01:25 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:48676 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729021AbeKEVBZ (ORCPT ); Mon, 5 Nov 2018 16:01:25 -0500 Received: from localhost.localdomain (unknown [IPv6:2a02:8109:92c0:207d:59be:d485:5b1c:9e22]) (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 C186627DF2C; Mon, 5 Nov 2018 11:42:05 +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 v4 2/4] drm/virtio: add uapi for in and out explicit fences Date: Mon, 5 Nov 2018 12:41:50 +0100 Message-Id: <20181105114152.2088-3-robert.foss@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105114152.2088-1-robert.foss@collabora.com> References: <20181105114152.2088-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 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