Add sync object UAPI support to VirtIO-GPU driver
Subsystems (3)
Dmitry Osipenko
maintainercover Add sync object UAPI support to VirtIO-GPU driver
We have multiple Vulkan context types that are awaiting for the addition of the sync object DRM UAPI support to the VirtIO-GPU kernel driver:
1. Venus context
2. Native contexts (virtio-freedreno, virtio-intel, virtio-amdgpu)
Mesa core supports DRM sync object UAPI, providing Vulkan drivers with a generic fencing implementation that we want to utilize.
This patch adds initial sync objects support. It creates fundament for a further fencing improvements. Later on we will want to extend the VirtIO-GPU fencing API with passing fence IDs to host for waiting, it will be a new additional VirtIO-GPU IOCTL and more. Today we have several VirtIO-GPU context drivers in works that require VirtIO-GPU to support sync objects UAPI.
The patch is heavily inspired by the sync object UAPI implementation of the MSM driver.
Dmitry Osipenko (1):
drm/virtio: Support sync objects
drivers/gpu/drm/virtio/virtgpu_drv.c | 3 +- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 223 ++++++++++++++++++++++++- include/uapi/drm/virtgpu_drm.h | 16 +- 3 files changed, 239 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.0
Dmitry Osipenko
maintainerPATCH 1/1 drm/virtio: Support sync objects
Add sync object DRM UAPI support to VirtIO-GPU driver. It's required for enabling full-featured Vulkan fencing by Venus and native context VirtIO-GPU Mesa drivers.
--- drivers/gpu/drm/virtio/virtgpu_drv.c | 3 +- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 223 ++++++++++++++++++++++++- include/uapi/drm/virtgpu_drm.h | 16 +- 3 files changed, 239 insertions(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +2 -1
@@ -172,7 +172,8 @@ MODULE_AUTHOR("Alon Levy");DEFINE_DRM_GEM_FOPS (virtio_gpu_driver_fops);static const struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_RENDER |DRIVER_ATOMIC , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_RENDER |DRIVER_ATOMIC | +DRIVER_SYNCOBJ |DRIVER_SYNCOBJ_TIMELINE , .open = virtio_gpu_driver_open, .postclose = virtio_gpu_driver_postclose,
drivers/gpu/drm/virtio/virtgpu_ioctl.c +222 -1
268 lines not on this page · raw message
include/uapi/drm/virtgpu_drm.h +15 -1
@@ -64,6 +64,16 @@ struct drm_virtgpu_map {__u32 pad; }; +#define VIRTGPU_EXECBUF_SYNCOBJ_RESET 0x01 +#define VIRTGPU_EXECBUF_SYNCOBJ_FLAGS ( \ + VIRTGPU_EXECBUF_SYNCOBJ_RESET | \ + 0) +struct drm_virtgpu_execbuffer_syncobj { +__u32 handle; +__u32 flags; +__u64 point; +}; +struct drm_virtgpu_execbuffer {__u32 flags;__u32 size;
@@ -72,7 +82,11 @@ struct drm_virtgpu_execbuffer {__u32 num_bo_handles;__s32 fence_fd;/* in/out fence fd (see VIRTGPU_EXECBUF_FENCE_FD_IN/OUT) */ __u32 ring_idx;/* command ring index (see VIRTGPU_EXECBUF_RING_IDX) */ -__u32 pad; +__u32 syncobj_stride; +__u32 num_in_syncobjs; +__u32 num_out_syncobjs; +__u64 in_syncobjs; +__u64 out_syncobjs; };#define VIRTGPU_PARAM_3D_FEATURES 1/* do we have 3D features in the hw */
Signature · 1 line
2.39.0
Dmitry Osipenko
maintainerRe: [PATCH v1 1/1] drm/virtio: Support sync objects
drivers/gpu/drm/virtio/virtgpu_ioctl.c static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data, · line 171
Quoted 7 lines · Dmitry Osipenko
drivers/gpu/drm/virtio/virtgpu_ioctl.c +7
-0+ ret =drm_syncobj_find_fence (file, syncobj_desc.handle, + syncobj_desc.point,0 , &in_fence); +if (ret) +break ; + +if (!dma_fence_match_context (in_fence, fence_ctx + ring_idx)) + ret =dma_fence_wait (in_fence, true);
I missed to add dma_fence_chain_contained(in_fence) here, otherwise the match always fails for a chained fence.
Signature · 2 lines
Best regards, Dmitry