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 <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28531>
This commit is contained in:
Rob Clark 2024-04-02 09:33:36 -07:00 committed by Marge Bot
parent 145a5cd414
commit 6d17577b64
3 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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);

View File

@ -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,