zink: correctly handle batch_id==0 in check_last_finished()

in some places this assert is used to hang check, but here we
can assume that the batch_id is always valid (i.e., not a hang) and
check it accordingly to avoid spurious crashes

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37239>
(cherry picked from commit 28342d1f11)
This commit is contained in:
Mike Blumenkrantz 2025-09-08 10:51:29 -04:00 committed by Eric Engestrom
parent f8a88724ad
commit 113db9ac20
2 changed files with 4 additions and 2 deletions

View file

@ -7394,7 +7394,7 @@
"description": "zink: correctly handle batch_id==0 in check_last_finished()",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -61,7 +61,9 @@ static inline bool
zink_screen_check_last_finished(struct zink_screen *screen, uint32_t batch_id)
{
const uint32_t check_id = (uint32_t)batch_id;
assert(check_id);
/* 0 means an in-flight batch */
if (check_id == 0)
return false;
/* last_finished may have wrapped */
if (screen->last_finished < UINT_MAX / 2) {
/* last_finished has wrapped, batch_id has not */