From: Robert Foss <robert.foss@collabora.com>
To: airlied@linux.ie, kraxel@redhat.com,
dri-devel@lists.freedesktop.org,
virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, Rob Herring <robh@kernel.org>,
Gustavo Padovan <gustavo.padovan@collabora.com>,
Emil Velikov <emil.velikov@collabora.com>
Cc: Robert Foss <robert.foss@collabora.com>
Subject: [PATCH 2/5] drm/virtio: add uapi for in and out explicit fences
Date: Thu, 25 Oct 2018 20:37:36 +0200 [thread overview]
Message-ID: <20181025183739.9375-3-robert.foss@collabora.com> (raw)
In-Reply-To: <20181025183739.9375-1-robert.foss@collabora.com>
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 <gustavo.padovan@collabora.com>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
---
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
next prev parent reply other threads:[~2018-10-25 18:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 18:37 [PATCH 0/5] virgl: fence fd support Robert Foss
2018-10-25 18:37 ` [PATCH 1/5] drm/virtio: add virtio_gpu_alloc_fence() Robert Foss
2018-10-31 9:38 ` Emil Velikov
2018-11-01 12:43 ` Robert Foss
2018-11-05 6:38 ` Gerd Hoffmann
2018-10-25 18:37 ` Robert Foss [this message]
2018-10-30 6:11 ` [PATCH 2/5] drm/virtio: add uapi for in and out explicit fences Gerd Hoffmann
2018-10-30 11:31 ` Emil Velikov
2018-10-30 13:52 ` Gerd Hoffmann
2018-10-30 15:48 ` Emil Velikov
2018-10-31 9:38 ` Emil Velikov
2018-11-01 12:56 ` Robert Foss
2018-11-02 13:34 ` Emil Velikov
2018-11-02 14:42 ` Robert Foss
2018-10-25 18:37 ` [PATCH 3/5] drm/virtio: add in-fences support for explicit synchronization Robert Foss
2018-10-31 9:38 ` Emil Velikov
2018-10-25 18:37 ` [PATCH 4/5] drm/virtio: add out-fences " Robert Foss
2018-10-31 9:39 ` Emil Velikov
2018-10-25 18:37 ` [PATCH 5/5] drm/virtio: bump driver version after explicit synchronization addition Robert Foss
2018-10-31 9:39 ` Emil Velikov
2018-10-31 9:45 ` [PATCH 0/5] virgl: fence fd support Emil Velikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181025183739.9375-3-robert.foss@collabora.com \
--to=robert.foss@collabora.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.velikov@collabora.com \
--cc=gustavo.padovan@collabora.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).