From 6d17577b646f54a7b3e82b6b09a0de8c88192ba7 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 2 Apr 2024 09:33:36 -0700 Subject: [PATCH] freedreno/drm/virtio: Fix deadlock on exit We don't want the retire work to be the one to drop the last reference to the pipe, as that would result in trying to free the retire_queue from the retire_queue thread. Signed-off-by: Rob Clark Part-of: --- src/freedreno/drm/freedreno_pipe.c | 3 +++ src/freedreno/drm/freedreno_priv.h | 1 + src/freedreno/drm/virtio/virtio_pipe.c | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/src/freedreno/drm/freedreno_pipe.c b/src/freedreno/drm/freedreno_pipe.c index 13e8ad979e858..c3fc7db41f51a 100644 --- a/src/freedreno/drm/freedreno_pipe.c +++ b/src/freedreno/drm/freedreno_pipe.c @@ -152,6 +152,9 @@ fd_pipe_purge(struct fd_pipe *pipe) fd_fence_flush(unflushed_fence); fd_fence_del(unflushed_fence); } + + if (pipe->funcs->finish) + pipe->funcs->finish(pipe); } int diff --git a/src/freedreno/drm/freedreno_priv.h b/src/freedreno/drm/freedreno_priv.h index 7e6b3c22ce44c..b59629a7ee5e7 100644 --- a/src/freedreno/drm/freedreno_priv.h +++ b/src/freedreno/drm/freedreno_priv.h @@ -314,6 +314,7 @@ struct fd_pipe_funcs { * the pipe implementation) */ void (*flush)(struct fd_pipe *pipe, uint32_t fence); + void (*finish)(struct fd_pipe *pipe); int (*get_param)(struct fd_pipe *pipe, enum fd_param_id param, uint64_t *value); diff --git a/src/freedreno/drm/virtio/virtio_pipe.c b/src/freedreno/drm/virtio/virtio_pipe.c index 8b4644777acd6..f91344c7644b2 100644 --- a/src/freedreno/drm/virtio/virtio_pipe.c +++ b/src/freedreno/drm/virtio/virtio_pipe.c @@ -112,6 +112,14 @@ virtio_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param, } } +static void +virtio_pipe_finish(struct fd_pipe *pipe) +{ + struct virtio_pipe *virtio_pipe = to_virtio_pipe(pipe); + if (util_queue_is_initialized(&virtio_pipe->retire_queue)) + util_queue_finish(&virtio_pipe->retire_queue); +} + static int virtio_pipe_wait(struct fd_pipe *pipe, const struct fd_fence *fence, uint64_t timeout) { @@ -208,6 +216,7 @@ static const struct fd_pipe_funcs funcs = { .ringbuffer_new_object = fd_ringbuffer_sp_new_object, .submit_new = virtio_submit_new, .flush = fd_pipe_sp_flush, + .finish = virtio_pipe_finish, .get_param = virtio_pipe_get_param, .wait = virtio_pipe_wait, .destroy = virtio_pipe_destroy,