panfrost: sanity-check alignment

The page-alignment should always be a positive power of two. Let's
assert that, to avoid confusion.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
CID: 1605086
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32380>
This commit is contained in:
Erik Faye-Lund 2024-11-11 15:12:37 +01:00 committed by Marge Bot
parent 0d51248e5d
commit 22985caf3f

View file

@ -137,7 +137,9 @@ panfrost_pool_alloc_aligned(struct panfrost_pool *pool, size_t sz,
#ifdef PAN_DBG_OVERFLOW #ifdef PAN_DBG_OVERFLOW
if (unlikely(pool->dev->debug & PAN_DBG_OVERFLOW) && if (unlikely(pool->dev->debug & PAN_DBG_OVERFLOW) &&
!(pool->create_flags & PAN_BO_INVISIBLE)) { !(pool->create_flags & PAN_BO_INVISIBLE)) {
unsigned aligned = ALIGN_POT(sz, sysconf(_SC_PAGESIZE)); long alignment = sysconf(_SC_PAGESIZE);
assert(alignment > 0 && util_is_power_of_two_nonzero(alignment));
unsigned aligned = ALIGN_POT(sz, alignment);
unsigned bo_size = aligned + PAN_GUARD_SIZE; unsigned bo_size = aligned + PAN_GUARD_SIZE;
bo = panfrost_pool_alloc_backing(pool, bo_size); bo = panfrost_pool_alloc_backing(pool, bo_size);