From patchwork Fri Feb 16 15:12:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 10224915 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 8DE0D603EE for ; Fri, 16 Feb 2018 15:12:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D9A727F8E for ; Fri, 16 Feb 2018 15:12:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71F39283E8; Fri, 16 Feb 2018 15:12:27 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 1DAC927F8E for ; Fri, 16 Feb 2018 15:12:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E44B6E64D; Fri, 16 Feb 2018 15:12:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id 238396E639 for ; Fri, 16 Feb 2018 15:12:20 +0000 (UTC) Received: by mail-qk0-f193.google.com with SMTP id l23so4113531qkk.11 for ; Fri, 16 Feb 2018 07:12:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ed1gRxmC5eLp48Jwp0FppXyO1PchcRLX2pKAUR9LZwQ=; b=hayVzRB5epKuVLJkkRb/DVvP+EyQfx+Q0tR6rFcXTXlRSyOzD3kmhBVxNY68GA1sBu Le7PG863/o7PGVVX+k/bVrl73MOjOxCXT3NFTDrN9OGWgXc4VFoNghAEHO8XOGs0Q0Dx 7jYkZpO9t0/DkxJvdLJCcWf6AbFttt11Qviqze9KQf9SXUUpuf9m2AbIfck8TkFgh0z5 3nuREOyY+VZ9grqcsSNSJ4ZTa/Db1d6IJCscop8hxqwZEFPG513AZ6CX1F8yGrA48vzq 1rduD8MblxeViahfZVpd39XPZKZuhPJZO2YKcyYX3O8dZ9FEcg6XL3FeUXuFDaNKIPgT 9+HQ== X-Gm-Message-State: APf1xPBJj3BNAWkYkBiR2J4WNUSbdfnrmySMojzfDwJlRKQlDwcFsoYE /GDVXieVshNzb4Te91mPlYunFFmU X-Google-Smtp-Source: AH8x226dgLKsqKzCjuo94rws48Xt/dGfHvVdphTobAoy0JaIoLOerJfGj4E01sEh4zxWrUUiYAED3Q== X-Received: by 10.55.46.69 with SMTP id u66mr9838649qkh.259.1518793939010; Fri, 16 Feb 2018 07:12:19 -0800 (PST) Received: from localhost.localdomain ([2804:14c:138:2ada:c36a:f21:635:771c]) by smtp.gmail.com with ESMTPSA id c42sm13326473qtc.42.2018.02.16.07.12.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Feb 2018 07:12:18 -0800 (PST) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/5] drm/virtio: add uapi for in and out explicit fences Date: Fri, 16 Feb 2018 13:12:04 -0200 Message-Id: <20180216151207.28912-3-gustavo@padovan.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180216151207.28912-1-gustavo@padovan.org> References: <20180216151207.28912-1-gustavo@padovan.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@collabora.com, Gerd Hoffmann , Gustavo Padovan 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 1d4aa83498ca..bd46b0d76754 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -115,6 +115,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 91a31ffed828..d1d69beba41b 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 \