winsys/amdgpu: remove amdgpu_winsys_bo::sparse
authorMarek Olšák <marek.olsak@amd.com>
Thu, 12 Nov 2020 19:09:35 +0000 (14:09 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 19 Nov 2020 04:50:38 +0000 (23:50 -0500)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7585>

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

index f9dbf6e..623b831 100644 (file)
@@ -247,7 +247,7 @@ static void amdgpu_clean_up_buffer_managers(struct amdgpu_winsys *ws)
 
 static bool amdgpu_bo_do_map(struct amdgpu_winsys_bo *bo, void **cpu)
 {
-   assert(!bo->sparse && bo->bo && !bo->is_user_ptr);
+   assert(!(bo->flags & RADEON_FLAG_SPARSE) && bo->bo && !bo->is_user_ptr);
    int r = amdgpu_bo_cpu_map(bo->bo, cpu);
    if (r) {
       /* Clean up buffer managers and try again. */
@@ -276,7 +276,7 @@ void *amdgpu_bo_map(struct pb_buffer *buf,
    struct amdgpu_winsys_bo *real;
    struct amdgpu_cs *cs = (struct amdgpu_cs*)rcs;
 
-   assert(!bo->sparse);
+   assert(!(bo->flags & RADEON_FLAG_SPARSE));
 
    /* If it's not unsynchronized bo_map, flush CS if needed and then wait. */
    if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) {
@@ -403,7 +403,7 @@ void amdgpu_bo_unmap(struct pb_buffer *buf)
    struct amdgpu_winsys_bo *bo = (struct amdgpu_winsys_bo*)buf;
    struct amdgpu_winsys_bo *real;
 
-   assert(!bo->sparse);
+   assert(!(bo->flags & RADEON_FLAG_SPARSE));
 
    if (bo->is_user_ptr)
       return;
@@ -1015,7 +1015,7 @@ static void amdgpu_bo_sparse_destroy(struct pb_buffer *_buf)
    struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
    int r;
 
-   assert(!bo->bo && bo->sparse);
+   assert(!bo->bo && bo->flags & RADEON_FLAG_SPARSE);
 
    r = amdgpu_bo_va_op_raw(bo->ws->dev, NULL, 0,
                            (uint64_t)bo->u.sparse.num_va_pages * RADEON_SPARSE_PAGE_SIZE,
@@ -1071,7 +1071,6 @@ amdgpu_bo_sparse_create(struct amdgpu_winsys *ws, uint64_t size,
    bo->ws = ws;
    bo->initial_domain = domain;
    bo->unique_id =  __sync_fetch_and_add(&ws->next_bo_unique_id, 1);
-   bo->sparse = true;
    bo->flags = flags;
 
    bo->u.sparse.num_va_pages = DIV_ROUND_UP(size, RADEON_SPARSE_PAGE_SIZE);
@@ -1119,7 +1118,7 @@ amdgpu_bo_sparse_commit(struct pb_buffer *buf, uint64_t offset, uint64_t size,
    bool ok = true;
    int r;
 
-   assert(bo->sparse);
+   assert(bo->flags & RADEON_FLAG_SPARSE);
    assert(offset % RADEON_SPARSE_PAGE_SIZE == 0);
    assert(offset <= bo->base.size);
    assert(size <= bo->base.size - offset);
@@ -1664,7 +1663,7 @@ static bool amdgpu_bo_is_suballocated(struct pb_buffer *buf)
 {
    struct amdgpu_winsys_bo *bo = (struct amdgpu_winsys_bo*)buf;
 
-   return !bo->bo && !bo->sparse;
+   return !bo->bo && !(bo->flags & RADEON_FLAG_SPARSE);
 }
 
 static uint64_t amdgpu_bo_get_va(struct pb_buffer *buf)
index 88e01b8..c4edb58 100644 (file)
@@ -90,7 +90,6 @@ struct amdgpu_winsys_bo {
    void *cpu_ptr; /* for user_ptr and permanent maps */
 
    amdgpu_bo_handle bo; /* NULL for slab entries and sparse buffers */
-   bool sparse;
    bool is_user_ptr;
    uint32_t unique_id;
    uint64_t va;
index be297be..9658bf7 100644 (file)
@@ -420,7 +420,7 @@ int amdgpu_lookup_buffer(struct amdgpu_cs_context *cs, struct amdgpu_winsys_bo *
    if (bo->bo) {
       buffers = cs->real_buffers;
       num_buffers = cs->num_real_buffers;
-   } else if (!bo->sparse) {
+   } else if (!(bo->flags & RADEON_FLAG_SPARSE)) {
       buffers = cs->slab_buffers;
       num_buffers = cs->num_slab_buffers;
    } else {
@@ -643,7 +643,7 @@ static unsigned amdgpu_cs_add_buffer(struct radeon_cmdbuf *rcs,
        (1u << priority) & cs->last_added_bo_priority_usage)
       return cs->last_added_bo_index;
 
-   if (!bo->sparse) {
+   if (!(bo->flags & RADEON_FLAG_SPARSE)) {
       if (!bo->bo) {
          index = amdgpu_lookup_or_add_slab_buffer(acs, bo);
          if (index < 0)
index 5c8ba75..ae90814 100644 (file)
@@ -263,7 +263,7 @@ amdgpu_bo_is_referenced_by_cs_with_usage(struct amdgpu_cs *cs,
       return false;
 
    buffer = bo->bo ? &cs->csc->real_buffers[index] :
-            bo->sparse ? &cs->csc->sparse_buffers[index] :
+            bo->flags & RADEON_FLAG_SPARSE ? &cs->csc->sparse_buffers[index] :
             &cs->csc->slab_buffers[index];
 
    return (buffer->usage & usage) != 0;