From fa867cf1895bca4ec2b3f4708e6e7e4b946dafff Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 1 Jun 2026 11:10:58 -0400 Subject: [PATCH] zink/bo: check for usage before completion when reclaiming bos checking completion alone disregards submit_count, which is used to determine the validity of any existing usage pointer. this could lead to large numbers of bos with stale usage and infinite memory ballooning cc: mesa-stable Part-of: --- src/gallium/drivers/zink/zink_bo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c index 6829bce59e5..ae5cf92e2ee 100644 --- a/src/gallium/drivers/zink/zink_bo.c +++ b/src/gallium/drivers/zink/zink_bo.c @@ -135,6 +135,13 @@ bo_can_reclaim(struct zink_screen *screen, struct pb_buffer_lean *pbuf) { struct zink_bo *bo = zink_bo(pbuf); + /* ensure that submit_count is checked to determine if the usage pointer is stale */ + if (!zink_bo_has_usage(bo)) { + /* if (submit_count > 1) then the usage pointer is invalid */ + bo->reads.u = NULL; + bo->writes.u = NULL; + return true; + } return zink_screen_usage_check_completion(screen, bo->reads.u) && zink_screen_usage_check_completion(screen, bo->writes.u); }