From 55e3d0e25615a03c7405f3fb97d51b5957be4d40 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 6 Sep 2021 16:16:51 +0200 Subject: [PATCH] panvk: Fix a BO leak in panvk_pool_alloc_backing() When picking a BO from a BO pool, we need to add it to the memory pool otherwise it gets lost when the memory pool is reset/destroyed. Signed-off-by: Boris Brezillon Reviewed-by: Tomeu Vizoso Part-of: --- src/panfrost/vulkan/panvk_mempool.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/panfrost/vulkan/panvk_mempool.c b/src/panfrost/vulkan/panvk_mempool.c index d5d1b58ce64..a58408794c2 100644 --- a/src/panfrost/vulkan/panvk_mempool.c +++ b/src/panfrost/vulkan/panvk_mempool.c @@ -43,20 +43,23 @@ static struct panfrost_bo * panvk_pool_alloc_backing(struct panvk_pool *pool, size_t bo_sz) { + struct panfrost_bo *bo; + /* If there's a free BO in our BO pool, let's pick it. */ if (pool->bo_pool && - util_dynarray_num_elements(&pool->bo_pool->free_bos, struct panfrost_bo *)) - return util_dynarray_pop(&pool->bo_pool->free_bos, struct panfrost_bo *); - - /* We don't know what the BO will be used for, so let's flag it - * RW and attach it to both the fragment and vertex/tiler jobs. - * TODO: if we want fine grained BO assignment we should pass - * flags to this function and keep the read/write, - * fragment/vertex+tiler pools separate. - */ - struct panfrost_bo *bo = panfrost_bo_create(pool->base.dev, bo_sz, - pool->base.create_flags, - pool->base.label); + util_dynarray_num_elements(&pool->bo_pool->free_bos, struct panfrost_bo *)) { + bo = util_dynarray_pop(&pool->bo_pool->free_bos, struct panfrost_bo *); + } else { + /* We don't know what the BO will be used for, so let's flag it + * RW and attach it to both the fragment and vertex/tiler jobs. + * TODO: if we want fine grained BO assignment we should pass + * flags to this function and keep the read/write, + * fragment/vertex+tiler pools separate. + */ + bo = panfrost_bo_create(pool->base.dev, bo_sz, + pool->base.create_flags, + pool->base.label); + } util_dynarray_append(&pool->bos, struct panfrost_bo *, bo); pool->transient_bo = bo;