From: Jason Ekstrand Date: Tue, 9 Jun 2020 01:37:51 +0000 (-0500) Subject: anv/allocator: Compare to start_offset in state_pool_free_no_vg X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c37cbf807f06b6aae1f17c99d653274110bad5d;p=mesa.git anv/allocator: Compare to start_offset in state_pool_free_no_vg In d11e4738a86ec, we started using a start_offset to allow us to allocate pools where the base address isn't at the start of the pool. This is useful for binding table pools which want to be relative to surface state base address (more or less), among other things. However, we had a bug where, if you have a negative offset, everything returned to the pool would end up being returned to the "back" of the pool. This isn't what we want for binding tables in the softpin world. This was causing us to never actually re-use any binding table blocks. How this passed CTS, I have no idea. Closes: #3100 Fixes: d11e4738a86ec "anv/allocator: Add a start_offset to anv_state_pool" Reviewed-by: Lionel Landwerlin Part-of: --- diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 703fa309aac..9007cd00e85 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -1025,7 +1025,7 @@ anv_state_pool_alloc_no_vg(struct anv_state_pool *pool, state = anv_free_list_pop(&pool->buckets[bucket].free_list, &pool->table); if (state) { - assert(state->offset >= 0); + assert(state->offset >= pool->start_offset); goto done; } @@ -1120,9 +1120,12 @@ anv_state_pool_alloc_back(struct anv_state_pool *pool) struct anv_state *state; uint32_t alloc_size = pool->block_size; + /* This function is only used with pools where start_offset == 0 */ + assert(pool->start_offset == 0); + state = anv_free_list_pop(&pool->back_alloc_free_list, &pool->table); if (state) { - assert(state->offset < 0); + assert(state->offset < pool->start_offset); goto done; } @@ -1149,7 +1152,7 @@ anv_state_pool_free_no_vg(struct anv_state_pool *pool, struct anv_state state) assert(util_is_power_of_two_or_zero(state.alloc_size)); unsigned bucket = anv_state_pool_get_bucket(state.alloc_size); - if (state.offset < 0) { + if (state.offset < pool->start_offset) { assert(state.alloc_size == pool->block_size); anv_free_list_push(&pool->back_alloc_free_list, &pool->table, state.idx, 1);