Mesa (main): v3dv/bo: unmap any bo that goes to the bo cache

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 25 11:17:58 UTC 2022


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

Author: Alejandro Piñeiro <apinheiro at igalia.com>
Date:   Tue May 24 16:54:37 2022 +0200

v3dv/bo: unmap any bo that goes to the bo cache

As it could happens that when a bo is reused from the cache, it is
being mapped with a smaller size that needed. So let's just unmap it,
and let be remapped with the needed size.

Even if we could try to be smarter when deciding when to unmap or not,
to avoid uneeded re-mappings later, it is also true that doing the
unmap would help to reduce the memory used.

This fixes an assert when running the following tests in a row (same
deqp-vk execution):
   dEQP-VK.pipeline.creation_feedback.graphics_tests.vertex_stage_fragment_stage
   dEQP-VK.pipeline.executable_properties.graphics.vertex_stage_geometry_stage_fragment_stage
   dEQP-VK.pipeline.executable_properties.graphics.vertex_stage_fragment_stage_internal_representations

That hits the following assertion:
   assert(qpu_bo && qpu_bo->map_size >= variant->assembly_offset +
                                        variant->qpu_insts_size);
at v3dv_pipeline.c, pipeline_get_qpu.

v2: use just one call to v3dv_bo_unmap (move call at v3dv_bo_free,
    replace call at bo_free for assert) (Iago)

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16678>

---

 src/broadcom/vulkan/v3dv_bo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_bo.c b/src/broadcom/vulkan/v3dv_bo.c
index 2dde2e6898e..d6c86157dfc 100644
--- a/src/broadcom/vulkan/v3dv_bo.c
+++ b/src/broadcom/vulkan/v3dv_bo.c
@@ -132,9 +132,7 @@ bo_free(struct v3dv_device *device,
       return true;
 
    assert(p_atomic_read(&bo->refcnt) == 0);
-
-   if (bo->map)
-      v3dv_bo_unmap(device, bo);
+   assert(bo->map == NULL);
 
    /* Our BO structs are stored in a sparse array in the physical device,
     * so we don't want to free the BO pointer, instead we want to reset it
@@ -460,6 +458,9 @@ v3dv_bo_free(struct v3dv_device *device,
    if (!p_atomic_dec_zero(&bo->refcnt))
       return true;
 
+   if (bo->map)
+      v3dv_bo_unmap(device, bo);
+
    struct timespec time;
    struct v3dv_bo_cache *cache = &device->bo_cache;
    uint32_t page_index = bo->size / 4096 - 1;



More information about the mesa-commit mailing list