From patchwork Mon Dec 12 20:48:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9471275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 75682607D3 for ; Mon, 12 Dec 2016 20:48:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69BB52851B for ; Mon, 12 Dec 2016 20:48:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C60D28518; Mon, 12 Dec 2016 20:48:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 11E0528518 for ; Mon, 12 Dec 2016 20:48:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2DE06E3FE; Mon, 12 Dec 2016 20:48:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ua0-f195.google.com (mail-ua0-f195.google.com [209.85.217.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F7536E3FE for ; Mon, 12 Dec 2016 20:48:41 +0000 (UTC) Received: by mail-ua0-f195.google.com with SMTP id 50so9834827uae.2 for ; Mon, 12 Dec 2016 12:48:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Go11qex44ixl3Idr3dlc5BF+uiM0QPuwhQQ3PfQgeVo=; b=TTxlOWWnSJFtQZaiMyPpmTuSPpynyeEkhHmKRXid+SenDomc+rf42iyqH4ngBE7Ug+ yyHu7fbSgCOOy/3pxgTvxyRGsPcIyQMDPggtEESjhs3n/dpVsb8i9ZQ57Klv3tx88LFL +ppAwlxlEQ99wwO/Bg0oTf6imHNWKo8kVBuMEl4bLcoEVGF92BJrCRgF0UfDKhdbGM1B LqgK6jIjNJEZm1JnP3c2shSd0pijhhzlWh3in+u4ZV2tGtek93p+iZjvjuu8Pb8iImuT K+doLjC4eQvNQg0T14O9rwciihP67FingM28ZC4KSf0il6nZtY0bd5GOJeLS5Sd8j20P CSJA== X-Gm-Message-State: AKaTC03EyzhZXq+uwezR/AsVKoIFd9r/tefjIDU6TiKS0UDDRNf22blG7LQNvF/IwRn13w== X-Received: by 10.159.32.8 with SMTP id 8mr62366259uam.129.1481575719924; Mon, 12 Dec 2016 12:48:39 -0800 (PST) Received: from jade.localdomain ([187.64.235.185]) by smtp.gmail.com with ESMTPSA id y6sm12496436vkc.12.2016.12.12.12.48.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 12:48:39 -0800 (PST) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [RFC 2/5] drm/virtio: add uapi for in and out explicit fences Date: Mon, 12 Dec 2016 18:48:26 -0200 Message-Id: <1481575710-12535-2-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1481575710-12535-1-git-send-email-gustavo@padovan.org> References: <1481575710-12535-1-git-send-email-gustavo@padovan.org> Cc: open list , "open list:VIRTIO GPU DRIVER" , Gerd Hoffmann , Gustavo Padovan X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan 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 --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 2 ++ include/uapi/drm/virtgpu_drm.h | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index da281103..d164b54 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -113,6 +113,8 @@ 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; diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index 91a31ff..d1d69be 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 */ @@ -136,7 +143,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 \