From 2c8c151591d3cbb1b0d81470b52866d9a2809b11 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 28 Jan 2023 07:56:28 -0800 Subject: [PATCH] freedreno/drm/virtio: Limit guest handles passed to virtgpu We only need to have virtgpu in the loop for shared buffers when implicit sync is in play. The rest of the time we can rely on userspace fence waits. Signed-off-by: Rob Clark Part-of: --- src/freedreno/drm/virtio/virtio_pipe.c | 4 ++++ src/freedreno/drm/virtio/virtio_ringbuffer.c | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/freedreno/drm/virtio/virtio_pipe.c b/src/freedreno/drm/virtio/virtio_pipe.c index 0b2952c1953..caa7b3c3832 100644 --- a/src/freedreno/drm/virtio/virtio_pipe.c +++ b/src/freedreno/drm/virtio/virtio_pipe.c @@ -122,9 +122,13 @@ virtio_pipe_wait(struct fd_pipe *pipe, const struct fd_fence *fence, uint64_t ti { MESA_TRACE_FUNC(); + assert(fence->use_fence_fd); + if (fence->use_fence_fd) return sync_wait(fence->fence_fd, timeout / 1000000); + /* TODO remove !use_fence_fd path */ + struct msm_ccmd_wait_fence_req req = { .hdr = MSM_CCMD(WAIT_FENCE, sizeof(req)), .queue_id = to_virtio_pipe(pipe)->queue_id, diff --git a/src/freedreno/drm/virtio/virtio_ringbuffer.c b/src/freedreno/drm/virtio/virtio_ringbuffer.c index 0af58d476fe..b5508f74b6b 100644 --- a/src/freedreno/drm/virtio/virtio_ringbuffer.c +++ b/src/freedreno/drm/virtio/virtio_ringbuffer.c @@ -140,10 +140,12 @@ flush_submit_list(struct list_head *submit_list) guest_handles = malloc(fd_submit->nr_bos * sizeof(guest_handles[0])); } + uint32_t nr_guest_handles = 0; for (unsigned i = 0; i < fd_submit->nr_bos; i++) { struct virtio_bo *virtio_bo = to_virtio_bo(fd_submit->bos[i]); - guest_handles[i] = virtio_bo->base.handle; + if (virtio_bo->base.alloc_flags & FD_BO_SHARED) + guest_handles[nr_guest_handles++] = virtio_bo->base.handle; submit_bos[i].flags = fd_submit->bos[i]->reloc_flags; submit_bos[i].handle = virtio_bo->res_id; @@ -185,9 +187,10 @@ flush_submit_list(struct list_head *submit_list) if (pipe->no_implicit_sync) { req->flags |= MSM_SUBMIT_NO_IMPLICIT; + nr_guest_handles = 0; } - virtio_execbuf_fenced(dev, &req->hdr, guest_handles, req->nr_bos, + virtio_execbuf_fenced(dev, &req->hdr, guest_handles, nr_guest_handles, fd_submit->in_fence_fd, &out_fence->fence_fd, virtio_pipe->ring_idx);