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 <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26643>
This commit is contained in:
Marek Olšák 2023-12-21 00:58:19 -05:00 committed by Marge Bot
parent a8e98882ea
commit eb19f0daa3

View file

@ -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 {