From b299e0323a8336c644209be95e499b6928625322 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 2 Mar 2026 11:30:43 +0100 Subject: [PATCH] mesa: don't wraparound st_context::work_counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit st->release_counter is initialized to 0, so if we happen to call st_add_releasebuf with a non-NULL releasebuf when st->work_counter is 0 due to wraparound in st_context_add_work, we might end up never calling st_prune_releasebufs. Since st_context_add_work and st_add_releasebuf both use work_counter as a "some work was done" and don't care about the actual value, we can remove the wraparound which will fix the buffer not being released issue. Fixes: b3133e250e1 ("gallium: add pipe_context::resource_release to eliminate buffer refcounting") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14955 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14499 Reviewed-by: Marek Olšák (cherry picked from commit 10d32feae8037a3b3c2fc9c5e10b7df5b78a0e21) Part-of: --- .pick_status.json | 2 +- src/mesa/state_tracker/st_context.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 3ae458f81b0..62417940e14 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3544,7 +3544,7 @@ "description": "mesa: don't wraparound st_context::work_counter", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b3133e250e1c40496d98c4ba52386b7ae423d194", "notes": null diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 9934c4e7aca..c9d57a35c2a 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -545,7 +545,6 @@ st_context_add_work(struct st_context *st) * performance. */ if (unlikely(++st->work_counter % 512 == 0)) { - st->work_counter = 0; if (!st->thread_scheduler_disabled) st_context_apply_scheduler_policy(st); }