winsys/amdgpu: move amdgpu_winsys_bo::cpu_ptr into the u.real union
authorMarek Olšák <marek.olsak@amd.com>
Wed, 3 Feb 2021 04:57:28 +0000 (23:57 -0500)
committerMarge Bot <eric+marge@anholt.net>
Sat, 6 Feb 2021 05:41:22 +0000 (05:41 +0000)
It's never used with slab and sparse buffers.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8849>

src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
src/gallium/winsys/amdgpu/drm/amdgpu_bo.h

index 75bfe6e..fab526d 100644 (file)
@@ -174,8 +174,8 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf)
 
    assert(bo->bo && "must not be called for slab entries");
 
-   if (!bo->is_user_ptr && bo->cpu_ptr) {
-      bo->cpu_ptr = NULL;
+   if (!bo->is_user_ptr && bo->u.real.cpu_ptr) {
+      bo->u.real.cpu_ptr = NULL;
       amdgpu_bo_unmap(&bo->base);
    }
    assert(bo->is_user_ptr || bo->u.real.map_count == 0);
@@ -378,24 +378,24 @@ void *amdgpu_bo_map(struct pb_buffer *buf,
 
    if (usage & RADEON_MAP_TEMPORARY) {
       if (real->is_user_ptr) {
-         cpu = real->cpu_ptr;
+         cpu = real->u.real.cpu_ptr;
       } else {
          if (!amdgpu_bo_do_map(real, &cpu))
             return NULL;
       }
    } else {
-      cpu = p_atomic_read(&real->cpu_ptr);
+      cpu = p_atomic_read(&real->u.real.cpu_ptr);
       if (!cpu) {
          simple_mtx_lock(&real->lock);
          /* Must re-check due to the possibility of a race. Re-check need not
           * be atomic thanks to the lock. */
-         cpu = real->cpu_ptr;
+         cpu = real->u.real.cpu_ptr;
          if (!cpu) {
             if (!amdgpu_bo_do_map(real, &cpu)) {
                simple_mtx_unlock(&real->lock);
                return NULL;
             }
-            p_atomic_set(&real->cpu_ptr, cpu);
+            p_atomic_set(&real->u.real.cpu_ptr, cpu);
          }
          simple_mtx_unlock(&real->lock);
       }
@@ -417,7 +417,7 @@ void amdgpu_bo_unmap(struct pb_buffer *buf)
    real = bo->bo ? bo : bo->u.slab.real;
    assert(real->u.real.map_count != 0 && "too many unmaps");
    if (p_atomic_dec_zero(&real->u.real.map_count)) {
-      assert(!real->cpu_ptr &&
+      assert(!real->u.real.cpu_ptr &&
              "too many unmaps or forgot RADEON_MAP_TEMPORARY flag");
 
       if (real->base.placement & RADEON_DOMAIN_VRAM)
@@ -1729,7 +1729,7 @@ static struct pb_buffer *amdgpu_bo_from_ptr(struct radeon_winsys *rws,
     bo->base.size = size;
     bo->base.vtbl = &amdgpu_winsys_bo_vtbl;
     bo->ws = ws;
-    bo->cpu_ptr = pointer;
+    bo->u.real.cpu_ptr = pointer;
     bo->va = va;
     bo->u.real.va_handle = va_handle;
     bo->base.placement = RADEON_DOMAIN_GTT;
index 9bf23a6..9eb69ea 100644 (file)
@@ -63,6 +63,7 @@ struct amdgpu_winsys_bo {
 #if DEBUG
          struct list_head global_list_item;
 #endif
+         void *cpu_ptr; /* for user_ptr and permanent maps */
          uint32_t kms_handle;
          int map_count;
       } real;
@@ -84,7 +85,6 @@ struct amdgpu_winsys_bo {
    } u;
 
    struct amdgpu_winsys *ws;
-   void *cpu_ptr; /* for user_ptr and permanent maps */
 
    amdgpu_bo_handle bo; /* NULL for slab entries and sparse buffers */
    bool is_user_ptr;