[PATCH v1 6/7] drm/amdgpu: add VA ranges to amdgpu_bo_print_info output
Pierre-Eric Pelloux-Prayer
pierre-eric.pelloux-prayer at amd.com
Wed May 21 09:49:08 UTC 2025
This information is useful when investigating page faults.
Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 25 +++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 3 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++------
4 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 35457f44a089..e8ae93cc2cc7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -1173,7 +1173,7 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused)
idr_for_each_entry(&file->object_idr, gobj, id) {
struct amdgpu_bo *bo = gem_to_amdgpu_bo(gobj);
- amdgpu_bo_print_info(id, bo, &p);
+ amdgpu_bo_print_info(id, bo, NULL, &p);
}
spin_unlock(&file->table_lock);
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 568c2cd95703..fb581cd38998 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1565,6 +1565,7 @@ uint32_t amdgpu_bo_get_preferred_domain(struct amdgpu_device *adev,
*
* @id: Index or Id of the BO
* @bo: Requested BO for printing info
+ * @bo_va: optional VA allocations for the BO
* @p: drm_printer to use
*
* Print BO information in debugfs file
@@ -1572,7 +1573,8 @@ uint32_t amdgpu_bo_get_preferred_domain(struct amdgpu_device *adev,
* Returns:
* Size of the BO in bytes.
*/
-u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct drm_printer *p)
+u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct amdgpu_bo_va *bo_va,
+ struct drm_printer *p)
{
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
struct dma_buf_attachment *attachment;
@@ -1645,6 +1647,27 @@ u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct drm_printer *p)
amdgpu_bo_print_flag(p, bo, VM_ALWAYS_VALID);
amdgpu_bo_print_flag(p, bo, EXPLICIT_SYNC);
+ if (dma_resv_trylock(bo->tbo.base.resv)) {
+ if (bo_va) {
+ struct amdgpu_bo_va_mapping *mapping;
+
+ drm_puts(p, " VA:[ ");
+ list_for_each_entry(mapping, &bo_va->valids, list) {
+ drm_printf(p, "0x%llx-0x%llx ",
+ mapping->start * AMDGPU_GPU_PAGE_SIZE,
+ (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE - 1);
+ }
+ list_for_each_entry(mapping, &bo_va->invalids, list) {
+ drm_printf(p, "0x%llx-0x%llx! ",
+ mapping->start * AMDGPU_GPU_PAGE_SIZE,
+ (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE - 1);
+ }
+ drm_puts(p, "]");
+ }
+
+ dma_resv_unlock(bo->tbo.base.resv);
+ }
+
drm_puts(p, "\n");
return size;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index f411a8c3199c..1eb78ebfced0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -348,7 +348,8 @@ void amdgpu_sa_bo_free(struct drm_suballoc **sa_bo,
void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
struct seq_file *m);
#endif
-u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct drm_printer *p);
+u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct amdgpu_bo_va *bo_va,
+ struct drm_printer *p);
void amdgpu_debugfs_sa_init(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 327ce9e883cc..7e9d26805f9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -3020,7 +3020,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct drm_printer *p)
list_for_each_entry_safe(bo_va, tmp, &vm->idle, base.vm_status) {
if (!bo_va->base.bo)
continue;
- total_idle += amdgpu_bo_print_info(id++, bo_va->base.bo, p);
+ total_idle += amdgpu_bo_print_info(id++, bo_va->base.bo, bo_va, p);
}
total_idle_objs = id;
id = 0;
@@ -3029,7 +3029,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct drm_printer *p)
list_for_each_entry_safe(bo_va, tmp, &vm->evicted, base.vm_status) {
if (!bo_va->base.bo)
continue;
- total_evicted += amdgpu_bo_print_info(id++, bo_va->base.bo, p);
+ total_evicted += amdgpu_bo_print_info(id++, bo_va->base.bo, bo_va, p);
}
total_evicted_objs = id;
id = 0;
@@ -3038,7 +3038,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct drm_printer *p)
list_for_each_entry_safe(bo_va, tmp, &vm->relocated, base.vm_status) {
if (!bo_va->base.bo)
continue;
- total_relocated += amdgpu_bo_print_info(id++, bo_va->base.bo, p);
+ total_relocated += amdgpu_bo_print_info(id++, bo_va->base.bo, bo_va, p);
}
total_relocated_objs = id;
id = 0;
@@ -3047,7 +3047,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct drm_printer *p)
list_for_each_entry_safe(bo_va, tmp, &vm->moved, base.vm_status) {
if (!bo_va->base.bo)
continue;
- total_moved += amdgpu_bo_print_info(id++, bo_va->base.bo, p);
+ total_moved += amdgpu_bo_print_info(id++, bo_va->base.bo, bo_va, p);
}
total_moved_objs = id;
id = 0;
@@ -3056,7 +3056,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct drm_printer *p)
list_for_each_entry_safe(bo_va, tmp, &vm->invalidated, base.vm_status) {
if (!bo_va->base.bo)
continue;
- total_invalidated += amdgpu_bo_print_info(id++, bo_va->base.bo, p);
+ total_invalidated += amdgpu_bo_print_info(id++, bo_va->base.bo, bo_va, p);
}
total_invalidated_objs = id;
id = 0;
@@ -3065,7 +3065,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct drm_printer *p)
list_for_each_entry_safe(bo_va, tmp, &vm->done, base.vm_status) {
if (!bo_va->base.bo)
continue;
- total_done += amdgpu_bo_print_info(id++, bo_va->base.bo, p);
+ total_done += amdgpu_bo_print_info(id++, bo_va->base.bo, bo_va, p);
}
spin_unlock(&vm->status_lock);
total_done_objs = id;
--
2.43.0
More information about the amd-gfx
mailing list