[Mesa-dev] [PATCH 1/4] gallium/radeon: Fix losing holes when allocating virtual address space.

Michel Dänzer michel at daenzer.net
Thu Apr 26 11:46:47 PDT 2012


From: Michel Dänzer <michel.daenzer at amd.com>

If a hole exactly matches the allocated size plus alignment, we would fail to
preserve the alignment as a hole. This would result in never being able to use
the alignment area for an allocation again.

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 47bbcb8..e2d990a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -221,7 +221,7 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr *mgr, uint64_t size, ui
             pipe_mutex_unlock(mgr->bo_va_mutex);
             return offset;
         }
-        if ((hole->size - waste) >= size) {
+        if ((hole->size - waste) > size) {
             if (waste) {
                 n = CALLOC_STRUCT(radeon_bo_va_hole);
                 n->size = waste;
@@ -233,6 +233,11 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr *mgr, uint64_t size, ui
             pipe_mutex_unlock(mgr->bo_va_mutex);
             return offset;
         }
+        if ((hole->size - waste) == size) {
+            hole->size = waste;
+            pipe_mutex_unlock(mgr->bo_va_mutex);
+            return offset;
+        }
     }
 
     offset = mgr->va_offset;
-- 
1.7.10



More information about the mesa-dev mailing list