<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 16, 2023 at 4:53 AM Dmitry Osipenko <<a href="mailto:dmitry.osipenko@collabora.com">dmitry.osipenko@collabora.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We have multiple Vulkan context types that are awaiting for the addition<br>
of the sync object DRM UAPI support to the VirtIO-GPU kernel driver:<br>
<br>
1. Venus context<br>
2. Native contexts (virtio-freedreno, virtio-intel, virtio-amdgpu)<br>
<br>
Mesa core supports DRM sync object UAPI, providing Vulkan drivers with a<br>
generic fencing implementation that we want to utilize.<br>
<br>
This patch adds initial sync objects support. It creates fundament for a<br>
further fencing improvements. Later on we will want to extend the VirtIO-GPU<br>
fencing API with passing fence IDs to host for waiting, it will be a new<br>
additional VirtIO-GPU IOCTL and more. Today we have several VirtIO-GPU context<br>
drivers in works that require VirtIO-GPU to support sync objects UAPI.<br>
<br>
The patch is heavily inspired by the sync object UAPI implementation of the<br>
MSM driver.<br></blockquote><div><br></div><div>The changes seem good, but I would recommend getting a full end-to-end solution (i.e, you've proxied the host fence with these changes and shared with the host compositor) working first. You'll never know what you'll find after completing this exercise. Or is that the plan already? </div><div><br></div><div>Typically, you want to land the uAPI and virtio spec changes last. Mesa/gfxstream/virglrenderer/crosvm all have the ability to test out unstable uAPIs ... </div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Changelog:<br>
<br>
v6: - Added zeroing out of syncobj_desc, as was suggested by Emil Velikov.<br>
<br>
- Fixed memleak in error code path which was spotted by Emil Velikov.<br>
<br>
- Switched to u32/u64 instead of uint_t. Previously was keeping<br>
uint_t style of the virtgpu_ioctl.c, in the end decided to change<br>
it because it's not a proper kernel coding style after all.<br>
<br>
- Kept single drm_virtgpu_execbuffer_syncobj struct for both in/out<br>
sync objects. There was a little concern about whether it would be<br>
worthwhile to have separate in/out descriptors, in practice it's<br>
unlikely that we will extend the descs in a foreseeable future.<br>
There is no overhead in using same struct since we want to pad it<br>
to 64b anyways and it shouldn't be a problem to separate the descs<br>
later on if we will want to do that.<br>
<br>
- Added r-b from Emil Velikov.<br>
<br>
v5: - Factored out dma-fence unwrap API usage into separate patch as was<br>
suggested by Emil Velikov.<br>
<br>
- Improved and documented the job submission reorderings as was<br>
requested by Emil Velikov. Sync file FD is now installed after<br>
job is submitted to virtio to further optimize reorderings.<br>
<br>
- Added comment for the kvalloc, as was requested by Emil Velikov.<br>
<br>
- The num_in/out_syncobjs now is set only after completed parsing<br>
of pre/post deps, as was requested by Emil Velikov.<br>
<br>
v4: - Added r-b from Rob Clark to the "refactoring" patch.<br>
<br>
- Replaced for/while(ptr && itr) with if (ptr), like was suggested by<br>
Rob Clark.<br>
<br>
- Dropped NOWARN and NORETRY GFP flags and switched syncobj patch<br>
to use kvmalloc.<br>
<br>
- Removed unused variables from syncobj patch that were borrowed by<br>
accident from another (upcoming) patch after one of git rebases.<br>
<br>
v3: - Switched to use dma_fence_unwrap_for_each(), like was suggested by<br>
Rob Clark.<br>
<br>
- Fixed missing dma_fence_put() in error code path that was spotted by<br>
Rob Clark.<br>
<br>
- Removed obsoleted comment to virtio_gpu_execbuffer_ioctl(), like was<br>
suggested by Rob Clark.<br>
<br>
v2: - Fixed chain-fence context matching by making use of<br>
dma_fence_chain_contained().<br>
<br>
- Fixed potential uninitialized var usage in error code patch of<br>
parse_post_deps(). MSM driver had a similar issue that is fixed<br>
already in upstream.<br>
<br>
- Added new patch that refactors job submission code path. I found<br>
that it was very difficult to add a new/upcoming host-waits feature<br>
because of how variables are passed around the code, the virtgpu_ioctl.c<br>
also was growing to unmanageable size.<br>
<br>
Dmitry Osipenko (3):<br>
drm/virtio: Refactor and optimize job submission code path<br>
drm/virtio: Wait for each dma-fence of in-fence array individually<br>
drm/virtio: Support sync objects<br>
<br>
drivers/gpu/drm/virtio/Makefile | 2 +-<br>
drivers/gpu/drm/virtio/virtgpu_drv.c | 3 +-<br>
drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +<br>
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 182 --------<br>
drivers/gpu/drm/virtio/virtgpu_submit.c | 530 ++++++++++++++++++++++++<br>
include/uapi/drm/virtgpu_drm.h | 16 +-<br>
6 files changed, 552 insertions(+), 185 deletions(-)<br>
create mode 100644 drivers/gpu/drm/virtio/virtgpu_submit.c<br>
<br>
-- <br>
2.39.2<br>
<br>
</blockquote></div></div>