[RFC PATCH v1 0/1] Support passing VirtIO-GPU fences to host for waiting

From: Dmitry Osipenko
Date: Sat Oct 07 2023 - 16:00:10 EST


Today's VirtIO-GPU driver always has to wait for in-fences on the guest
side, creating bottleneck for workloads that produce lots of job submissions
or require lower submission latency. This bottleneck is caused by a need
to do extra round trips between host and guest for the fence signalling.

The solution is to move fence signalling and waiting entierly to the host
side, where it can be done more efficiently, without holding the guest side.
The proposed patch introduces new "fence passing" VirtIO-GPU protocol
feature, which extends VIRTIO_GPU_CMD_SUBMIT_3D with array of in-fence IDs
that are passed from guest to host along with the 3D commands. Host then
takes the in-fence IDs and passes them to virglrender, where the fence IDs
are resolved into sync file fences and handled (waited) by a corresponding
virglrender context.

The patch is RFC because we want to do more testing with crosvm and
CrOS first, support fence-passing for Venus and virtio-wl. The new
virglrender experimental fence-passing API already has been merged [1]
and crosvm support began to pick it up [2]. Qemu patch is available at [3].

Fence passing was tested using WIP amdgpu and intel native contexts,
where it proved to be useful by increasing FPS up to 3x times.

[1] https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1138
[2] https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679609
[3] https://gitlab.freedesktop.org/digetx/qemu/-/commits/native-context-iris

Dmitry Osipenko (1):
drm/virtio: Support fence-passing feature

drivers/gpu/drm/virtio/virtgpu_drv.c | 1 +
drivers/gpu/drm/virtio/virtgpu_drv.h | 11 ++-
drivers/gpu/drm/virtio/virtgpu_fence.c | 15 +++-
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 11 ++-
drivers/gpu/drm/virtio/virtgpu_kms.c | 8 +-
drivers/gpu/drm/virtio/virtgpu_submit.c | 99 ++++++++++++++++++++++++-
drivers/gpu/drm/virtio/virtgpu_vq.c | 7 +-
include/uapi/drm/virtgpu_drm.h | 3 +
include/uapi/linux/virtio_gpu.h | 11 ++-
9 files changed, 152 insertions(+), 14 deletions(-)

--
2.41.0