From 4fdc7e990d68bb43e652ebdda8f3e14032d87b73 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 18 Aug 2025 15:16:12 +0200 Subject: [PATCH] aux/trace: move fence_server calls outside the locked area Multiple contexts can use those causing deadlocks if e.g. fence_get_fd gets called before fence_server_signal on another thread on the same pipe_fence_handle. Cc: mesa-stable Acked-by: Mike Blumenkrantz Part-of: (cherry picked from commit d9c3bbb08c0f4bba36536f25ec61d16f468e86d1) --- .pick_status.json | 2 +- src/gallium/auxiliary/driver_trace/tr_context.c | 8 ++++---- src/gallium/auxiliary/driver_trace/tr_screen.c | 5 +---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 44393b4d88b..20cb530f1a2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5374,7 +5374,7 @@ "description": "aux/trace: move fence_server calls outside the locked area", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/auxiliary/driver_trace/tr_context.c b/src/gallium/auxiliary/driver_trace/tr_context.c index cfee0ddaa01..1b7c68ea77d 100644 --- a/src/gallium/auxiliary/driver_trace/tr_context.c +++ b/src/gallium/auxiliary/driver_trace/tr_context.c @@ -1626,14 +1626,14 @@ trace_context_fence_server_sync(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; + pipe->fence_server_sync(pipe, fence, timeline_value); + trace_dump_call_begin("pipe_context", "fence_server_sync"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, fence); trace_dump_arg(uint, timeline_value); - pipe->fence_server_sync(pipe, fence, timeline_value); - trace_dump_call_end(); } @@ -1646,14 +1646,14 @@ trace_context_fence_server_signal(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; + pipe->fence_server_signal(pipe, fence, timeline_value); + trace_dump_call_begin("pipe_context", "fence_server_signal"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, fence); trace_dump_arg(uint, timeline_value); - pipe->fence_server_signal(pipe, fence, timeline_value); - trace_dump_call_end(); } diff --git a/src/gallium/auxiliary/driver_trace/tr_screen.c b/src/gallium/auxiliary/driver_trace/tr_screen.c index 7ba74b9a99e..0b038fbbcbd 100644 --- a/src/gallium/auxiliary/driver_trace/tr_screen.c +++ b/src/gallium/auxiliary/driver_trace/tr_screen.c @@ -965,15 +965,12 @@ trace_screen_fence_get_fd(struct pipe_screen *_screen, { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; - int result; + int result = screen->fence_get_fd(screen, fence); trace_dump_call_begin("pipe_screen", "fence_get_fd"); trace_dump_arg(ptr, screen); trace_dump_arg(ptr, fence); - - result = screen->fence_get_fd(screen, fence); - trace_dump_ret(int, result); trace_dump_call_end();