From 93d5fbf23ddaa24b9c3cbc493de3ef19526bc74f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 13 May 2021 11:25:31 -0400 Subject: [PATCH] panfrost: Add reference type for unowned pool This allows implementing the common pattern of allocating from an unowned pool and immediately taking a reference. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/lib/pan_pool.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/panfrost/lib/pan_pool.h b/src/panfrost/lib/pan_pool.h index 48e6a69be28..e53ec3fe3a9 100644 --- a/src/panfrost/lib/pan_pool.h +++ b/src/panfrost/lib/pan_pool.h @@ -61,6 +61,30 @@ struct pan_pool { bool owned; }; +/* Reference to pool allocated memory for an unowned pool */ + +struct pan_pool_ref { + /* Owning BO */ + struct panfrost_bo *bo; + + /* Mapped GPU VA */ + mali_ptr gpu; +}; + +/* Take a reference to an allocation pool. Call directly after allocating from + * an unowned pool for correct operation. */ + +static inline struct pan_pool_ref +pan_take_ref(struct pan_pool *pool, mali_ptr ptr) +{ + panfrost_bo_reference(pool->transient_bo); + + return (struct pan_pool_ref) { + .gpu = ptr, + .bo = pool->transient_bo + }; +} + void panfrost_pool_init(struct pan_pool *pool, void *memctx, struct panfrost_device *dev, unsigned create_flags,