Module: Mesa
Branch: main
Commit: 93d5fbf23ddaa24b9c3cbc493de3ef19526bc74f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=93d5fbf23ddaa24b9c3cbc493de3ef19526bc74f

Author: Alyssa Rosenzweig <[email protected]>
Date:   Thu May 13 11:25:31 2021 -0400

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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10866>

---

 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,

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to