pan/bo: Make sure we catch refcnt underflows

Recently had to debug an unbalanced ref/unref situation in some
code I added, and having an assert(refcnt > 0) in
panfrost_bo_unreference() would have made this simpler, so let's
add one.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26221>
This commit is contained in:
Boris Brezillon 2023-10-12 18:25:37 +02:00 committed by Marge Bot
parent 46d2748a93
commit 790d4422b2

View file

@ -431,6 +431,7 @@ panfrost_bo_unreference(struct panfrost_bo *bo)
return;
/* Don't return to cache if there are still references */
assert(p_atomic_read(&bo->refcnt) > 0);
if (p_atomic_dec_return(&bo->refcnt))
return;