-
-#define amdgpu_debugfs_gem_bo_print_flag(m, bo, flag) \
- if (bo->flags & (AMDGPU_GEM_CREATE_ ## flag)) { \
- seq_printf((m), " " #flag); \
- }
-
-static int amdgpu_debugfs_gem_bo_info(int id, void *ptr, void *data)
-{
- struct drm_gem_object *gobj = ptr;
- struct amdgpu_bo *bo = gem_to_amdgpu_bo(gobj);
- struct seq_file *m = data;
-
- struct dma_buf_attachment *attachment;
- struct dma_buf *dma_buf;
- unsigned domain;
- const char *placement;
- unsigned pin_count;
-
- domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
- switch (domain) {
- case AMDGPU_GEM_DOMAIN_VRAM:
- placement = "VRAM";
- break;
- case AMDGPU_GEM_DOMAIN_GTT:
- placement = " GTT";
- break;
- case AMDGPU_GEM_DOMAIN_CPU:
- default:
- placement = " CPU";
- break;
- }
- seq_printf(m, "\t0x%08x: %12ld byte %s",
- id, amdgpu_bo_size(bo), placement);
-
- pin_count = READ_ONCE(bo->pin_count);
- if (pin_count)
- seq_printf(m, " pin count %d", pin_count);
-
- dma_buf = READ_ONCE(bo->tbo.base.dma_buf);
- attachment = READ_ONCE(bo->tbo.base.import_attach);
-
- if (attachment)
- seq_printf(m, " imported from %p%s", dma_buf,
- attachment->peer2peer ? " P2P" : "");
- else if (dma_buf)
- seq_printf(m, " exported as %p", dma_buf);
-
- amdgpu_debugfs_gem_bo_print_flag(m, bo, CPU_ACCESS_REQUIRED);
- amdgpu_debugfs_gem_bo_print_flag(m, bo, NO_CPU_ACCESS);
- amdgpu_debugfs_gem_bo_print_flag(m, bo, CPU_GTT_USWC);
- amdgpu_debugfs_gem_bo_print_flag(m, bo, VRAM_CLEARED);
- amdgpu_debugfs_gem_bo_print_flag(m, bo, SHADOW);
- amdgpu_debugfs_gem_bo_print_flag(m, bo, VRAM_CONTIGUOUS);
- amdgpu_debugfs_gem_bo_print_flag(m, bo, VM_ALWAYS_VALID);
- amdgpu_debugfs_gem_bo_print_flag(m, bo, EXPLICIT_SYNC);
-
- seq_printf(m, "\n");
-
- return 0;
-}
-