gallium/radeon: Delete uppermost virtual address space hole if it's at the top.
authorMichel Dänzer <michel.daenzer@amd.com>
Thu, 26 Apr 2012 18:41:17 +0000 (20:41 +0200)
committerMichel Dänzer <michel@daenzer.net>
Thu, 16 Aug 2012 09:58:23 +0000 (11:58 +0200)
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/winsys/radeon/drm/radeon_drm_bo.c

index a01cc15b1ca4f04419ff40d8e193b34fa3db0536..1bf22a71d91e33c2b9a5f6e93756940231268ae0 100644 (file)
@@ -287,11 +287,22 @@ static void radeon_bomgr_force_va(struct radeon_bomgr *mgr, uint64_t va, uint64_
 
 static void radeon_bomgr_free_va(struct radeon_bomgr *mgr, uint64_t va, uint64_t size)
 {
+    struct radeon_bo_va_hole *hole;
+
     pipe_mutex_lock(mgr->bo_va_mutex);
     if ((va + size) == mgr->va_offset) {
         mgr->va_offset = va;
+        /* Delete uppermost hole if it reaches the new top */
+        if (!LIST_IS_EMPTY(&mgr->va_holes)) {
+            hole = container_of(mgr->va_holes.next, hole, list);
+            if ((hole->offset + hole->size) == va) {
+                mgr->va_offset = hole->offset;
+                list_del(&hole->list);
+                FREE(hole);
+            }
+        }
     } else {
-        struct radeon_bo_va_hole *hole, *next;
+        struct radeon_bo_va_hole *next;
 
         hole = container_of(&mgr->va_holes, hole, list);
         LIST_FOR_EACH_ENTRY(next, &mgr->va_holes, list) {