From ffa5518c45151feeba5e26a1220528f813225833 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 26 Aug 2025 13:50:46 -0400 Subject: [PATCH] zink: stop using atomics to check fence submit/complete this isn't actually achieving anything since reading a "wrong" value here isn't harmful Part-of: --- src/gallium/drivers/zink/zink_batch.c | 5 ++--- src/gallium/drivers/zink/zink_fence.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index b8d60cea6de..8ac66f93556 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -450,10 +450,9 @@ find_completed_batch_state(struct zink_context *ctx) /* states are stored sequentially, so if the first one doesn't work, none of them will */ for (struct zink_batch_state *i = ctx->batch_states, *j = i ? i->next : NULL; i; i = j, j = j ? j->next : NULL) { /* only a submitted state can be reused */ - if (p_atomic_read(&i->fence.submitted) && + if (i->fence.submitted && /* a submitted state must have completed before it can be reused */ - (zink_screen_check_last_finished(screen, i->fence.batch_id) || - p_atomic_read(&i->fence.completed))) { + (zink_screen_check_last_finished(screen, i->fence.batch_id) || i->fence.completed)) { pop_batch_state(ctx); reset_batch_state_ctx(ctx, i); simple_mtx_lock(&screen->active_batch_states_lock); diff --git a/src/gallium/drivers/zink/zink_fence.c b/src/gallium/drivers/zink/zink_fence.c index 470c4db492d..312504ae795 100644 --- a/src/gallium/drivers/zink/zink_fence.c +++ b/src/gallium/drivers/zink/zink_fence.c @@ -132,7 +132,7 @@ fence_wait(struct zink_screen *screen, struct zink_fence *fence, uint64_t timeou struct zink_batch_state *bs = zink_batch_state(fence); if (screen->device_lost) return true; - if (p_atomic_read(&fence->completed)) + if (fence->completed) return true; if (screen->threaded_submit) { @@ -147,7 +147,7 @@ fence_wait(struct zink_screen *screen, struct zink_fence *fence, uint64_t timeou bool success = zink_screen_timeline_wait(screen, fence->batch_id, timeout_ns); if (success) { - p_atomic_set(&fence->completed, true); + fence->completed = true; bs->usage.usage = 0; zink_screen_update_last_finished(screen, fence->batch_id); }