Skip to content

Commit

Permalink
Revert "winsys/amdgpu: remove amdgpu_bo_sparse::gpu_address, use amdg…
Browse files Browse the repository at this point in the history
…pu_va_get_start_addr"

This reverts commit 68418db.
  • Loading branch information
leonheldattoradex committed Aug 25, 2024
1 parent b02c1a0 commit f647084
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ static void amdgpu_bo_sparse_destroy(struct radeon_winsys *rws, struct pb_buffer

r = amdgpu_bo_va_op_raw(ws->dev, NULL, 0,
(uint64_t)bo->num_va_pages * RADEON_SPARSE_PAGE_SIZE,
amdgpu_va_get_start_addr(bo->va_handle), 0, AMDGPU_VA_OP_CLEAR);
bo->gpu_address, 0, AMDGPU_VA_OP_CLEAR);
if (r) {
fprintf(stderr, "amdgpu: clearing PRT VA region on destroy failed (%d)\n", r);
}
Expand Down Expand Up @@ -1060,15 +1060,14 @@ amdgpu_bo_sparse_create(struct amdgpu_winsys *ws, uint64_t size,
/* For simplicity, we always map a multiple of the page size. */
map_size = align64(size, RADEON_SPARSE_PAGE_SIZE);
va_gap_size = ws->check_vm ? 4 * RADEON_SPARSE_PAGE_SIZE : 0;

uint64_t gpu_address;
r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
map_size + va_gap_size, RADEON_SPARSE_PAGE_SIZE,
0, &gpu_address, &bo->va_handle, AMDGPU_VA_RANGE_HIGH);
0, &bo->gpu_address, &bo->va_handle,
AMDGPU_VA_RANGE_HIGH);
if (r)
goto error_va_alloc;

r = amdgpu_bo_va_op_raw(ws->dev, NULL, 0, map_size, gpu_address,
r = amdgpu_bo_va_op_raw(ws->dev, NULL, 0, map_size, bo->gpu_address,
AMDGPU_VM_PAGE_PRT, AMDGPU_VA_OP_MAP);
if (r)
goto error_va_map;
Expand Down Expand Up @@ -1141,8 +1140,7 @@ amdgpu_bo_sparse_commit(struct radeon_winsys *rws, struct pb_buffer_lean *buf,
r = amdgpu_bo_va_op_raw(ws->dev, backing->bo->bo_handle,
(uint64_t)backing_start * RADEON_SPARSE_PAGE_SIZE,
(uint64_t)backing_size * RADEON_SPARSE_PAGE_SIZE,
amdgpu_va_get_start_addr(bo->va_handle) +
(uint64_t)span_va_page * RADEON_SPARSE_PAGE_SIZE,
bo->gpu_address + (uint64_t)span_va_page * RADEON_SPARSE_PAGE_SIZE,
AMDGPU_VM_PAGE_READABLE |
AMDGPU_VM_PAGE_WRITEABLE |
AMDGPU_VM_PAGE_EXECUTABLE,
Expand All @@ -1167,8 +1165,7 @@ amdgpu_bo_sparse_commit(struct radeon_winsys *rws, struct pb_buffer_lean *buf,
} else {
r = amdgpu_bo_va_op_raw(ws->dev, NULL, 0,
(uint64_t)(end_va_page - va_page) * RADEON_SPARSE_PAGE_SIZE,
amdgpu_va_get_start_addr(bo->va_handle) +
(uint64_t)va_page * RADEON_SPARSE_PAGE_SIZE,
bo->gpu_address + (uint64_t)va_page * RADEON_SPARSE_PAGE_SIZE,
AMDGPU_VM_PAGE_PRT, AMDGPU_VA_OP_REPLACE);
if (r) {
ok = false;
Expand Down Expand Up @@ -1751,7 +1748,7 @@ uint64_t amdgpu_bo_get_va(struct pb_buffer_lean *buf)

return slab_bo->b.b.gpu_address + get_slab_entry_offset(bo);
} else if (bo->type == AMDGPU_BO_SPARSE) {
return amdgpu_va_get_start_addr(get_sparse_bo(bo)->va_handle);
return get_sparse_bo(bo)->gpu_address;
} else {
return get_real_bo(bo)->gpu_address;
}
Expand Down
1 change: 1 addition & 0 deletions src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct amdgpu_bo_real_reusable {
struct amdgpu_bo_sparse {
struct amdgpu_winsys_bo b;
amdgpu_va_handle va_handle;
uint64_t gpu_address;

uint32_t num_va_pages;
uint32_t num_backing_pages;
Expand Down

0 comments on commit f647084

Please sign in to comment.