From abf63b7c68114b7e93f06bc4f18fb63454c75655 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 3 Feb 2023 10:06:32 -0500 Subject: [PATCH] zink: fix more cases of heap/memtype suballocator mismatch suballocation must happen based on the memtype, so also add some asserts to ensure the slab bos are always what the caller expects Fixes: f6d3a5755f6 ("zink: zink_heap isn't 1-to-1 with memoryTypeIndex") Part-of: --- src/gallium/drivers/zink/zink_bo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c index 8e1db9117f0..646d063d2f3 100644 --- a/src/gallium/drivers/zink/zink_bo.c +++ b/src/gallium/drivers/zink/zink_bo.c @@ -301,7 +301,7 @@ bo_create_internal(struct zink_screen *screen, if (init_pb_cache) { bo->u.real.use_reusable_pool = true; - pb_cache_init_entry(&screen->pb.bo_cache, bo->cache_entry, &bo->base, heap); + pb_cache_init_entry(&screen->pb.bo_cache, bo->cache_entry, &bo->base, mem_type_idx); } else { #ifdef ZINK_USE_DMABUF list_inithead(&bo->u.real.exports); @@ -625,6 +625,7 @@ zink_bo_create(struct zink_screen *screen, uint64_t size, unsigned alignment, en return NULL; bo = container_of(entry, struct zink_bo, u.slab.entry); + assert(bo->base.placement == mem_type_idx); pipe_reference_init(&bo->base.reference, 1); bo->base.size = size; assert(alignment <= 1 << bo->base.alignment_log2); @@ -653,7 +654,8 @@ no_slab: if (use_reusable_pool) { /* Get a buffer from the cache. */ bo = (struct zink_bo*) - pb_cache_reclaim_buffer(&screen->pb.bo_cache, size, alignment, 0, heap); + pb_cache_reclaim_buffer(&screen->pb.bo_cache, size, alignment, 0, mem_type_idx); + assert(!bo || bo->base.placement == mem_type_idx); if (bo) return &bo->base; } @@ -668,6 +670,7 @@ no_slab: if (!bo) return NULL; } + assert(bo->base.placement == mem_type_idx); return &bo->base; }