freedreno/drm: Shuffle around BO init
authorRob Clark <robdclark@chromium.org>
Sat, 10 Dec 2022 17:33:51 +0000 (09:33 -0800)
committerMarge Bot <emma+marge@anholt.net>
Sat, 17 Dec 2022 19:14:12 +0000 (19:14 +0000)
Suballocated heap BOs will bypass the rest of bo_new() (as they skip the
BO cache, don't get an entry in the handle table, etc).  So move more of
the initialization into fd_bo_init_common().

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>

src/freedreno/drm/freedreno_bo.c

index ad45833..cc2f6b6 100644 (file)
@@ -68,6 +68,7 @@ fd_bo_init_common(struct fd_bo *bo, struct fd_device *dev)
    /* Backend should have initialized these: */
    assert(bo->size);
    assert(bo->handle);
+   assert(bo->funcs);
 
    bo->dev = dev;
    bo->iova = bo->funcs->iova(bo);
@@ -75,6 +76,11 @@ fd_bo_init_common(struct fd_bo *bo, struct fd_device *dev)
 
    p_atomic_set(&bo->refcnt, 1);
    list_inithead(&bo->node);
+
+   bo->max_fences = 1;
+   bo->fences = &bo->_inline_fence;
+
+   VG_BO_ALLOC(bo);
 }
 
 /* allocate a new buffer object, call w/ table_lock held */
@@ -124,10 +130,6 @@ bo_new(struct fd_device *dev, uint32_t size, uint32_t flags,
    simple_mtx_unlock(&table_lock);
 
    bo->alloc_flags = flags;
-   bo->max_fences = 1;
-   bo->fences = &bo->_inline_fence;
-
-   VG_BO_ALLOC(bo);
 
    return bo;
 }