From eb19f0daa3a09e64511f4a8a9086f55afc1ccb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 21 Dec 2023 00:58:19 -0500 Subject: [PATCH] winsys/amdgpu: don't use gpu_address to compute slab entry offset in bo_map use the code we have in amdgpu_bo_get_va Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c index 08c0ca198f6..7cb9b3cfb93 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c @@ -124,6 +124,16 @@ static bool amdgpu_bo_wait(struct radeon_winsys *rws, } } +static inline unsigned get_slab_entry_offset(struct amdgpu_winsys_bo *bo) +{ + struct amdgpu_bo_slab_entry *slab_entry_bo = get_slab_entry_bo(bo); + struct amdgpu_bo_real_reusable_slab *slab_bo = + (struct amdgpu_bo_real_reusable_slab *)get_slab_entry_real_bo(bo); + unsigned entry_index = slab_entry_bo - slab_bo->entries; + + return slab_bo->slab.entry_size * entry_index; +} + static enum radeon_bo_domain amdgpu_bo_get_initial_domain( struct pb_buffer *buf) { @@ -360,7 +370,7 @@ void *amdgpu_bo_map(struct radeon_winsys *rws, real = get_real_bo(bo); } else { real = get_slab_entry_real_bo(bo); - offset = amdgpu_bo_get_va(buf) - real->gpu_address; + offset = get_slab_entry_offset(bo); } if (usage & RADEON_MAP_TEMPORARY) { @@ -1755,12 +1765,10 @@ uint64_t amdgpu_bo_get_va(struct pb_buffer *buf) struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(buf); if (bo->type == AMDGPU_BO_SLAB_ENTRY) { - struct amdgpu_bo_slab_entry *slab_entry_bo = get_slab_entry_bo(bo); struct amdgpu_bo_real_reusable_slab *slab_bo = (struct amdgpu_bo_real_reusable_slab *)get_slab_entry_real_bo(bo); - unsigned entry_index = slab_entry_bo - slab_bo->entries; - return slab_bo->b.b.gpu_address + slab_bo->slab.entry_size * entry_index; + return slab_bo->b.b.gpu_address + get_slab_entry_offset(bo); } else if (bo->type == AMDGPU_BO_SPARSE) { return get_sparse_bo(bo)->gpu_address; } else {