[Mesa-dev] [PATCH 6/7] winsys/amdgpu: don't assume GTT if the VRAM flag isn't set

Marek Olšák maraeo at gmail.com
Mon Sep 12 22:44:42 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index a6d4aa4..5b099b0 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -138,21 +138,21 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf)
    amdgpu_fence_reference(&bo->fence, NULL);
 
    if (bo->initial_domain & RADEON_DOMAIN_VRAM)
       bo->ws->allocated_vram -= align64(bo->base.size, bo->ws->info.gart_page_size);
    else if (bo->initial_domain & RADEON_DOMAIN_GTT)
       bo->ws->allocated_gtt -= align64(bo->base.size, bo->ws->info.gart_page_size);
 
    if (bo->map_count >= 1) {
       if (bo->initial_domain & RADEON_DOMAIN_VRAM)
          bo->ws->mapped_vram -= bo->base.size;
-      else
+      else if (bo->initial_domain & RADEON_DOMAIN_GTT)
          bo->ws->mapped_gtt -= bo->base.size;
    }
 
    FREE(bo);
 }
 
 static void amdgpu_bo_destroy_or_cache(struct pb_buffer *_buf)
 {
    struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
 
@@ -254,37 +254,37 @@ static void *amdgpu_bo_map(struct pb_buffer *buf,
       /* Clear the cache and try again. */
       pb_cache_release_all_buffers(&bo->ws->bo_cache);
       r = amdgpu_bo_cpu_map(bo->bo, &cpu);
       if (r)
          return NULL;
    }
 
    if (p_atomic_inc_return(&bo->map_count) == 1) {
       if (bo->initial_domain & RADEON_DOMAIN_VRAM)
          bo->ws->mapped_vram += bo->base.size;
-      else
+      else if (bo->initial_domain & RADEON_DOMAIN_GTT)
          bo->ws->mapped_gtt += bo->base.size;
    }
    return cpu;
 }
 
 static void amdgpu_bo_unmap(struct pb_buffer *buf)
 {
    struct amdgpu_winsys_bo *bo = (struct amdgpu_winsys_bo*)buf;
 
    if (bo->user_ptr)
       return;
 
    if (p_atomic_dec_zero(&bo->map_count)) {
       if (bo->initial_domain & RADEON_DOMAIN_VRAM)
          bo->ws->mapped_vram -= bo->base.size;
-      else
+      else if (bo->initial_domain & RADEON_DOMAIN_GTT)
          bo->ws->mapped_gtt -= bo->base.size;
    }
 
    amdgpu_bo_cpu_unmap(bo->bo);
 }
 
 static const struct pb_vtbl amdgpu_winsys_bo_vtbl = {
    amdgpu_bo_destroy_or_cache
    /* other functions are never called */
 };
-- 
2.7.4



More information about the mesa-dev mailing list