[PATCH 10/13] drm/amdgpu: doorbell support in get_memory functions
Christian König
christian.koenig at amd.com
Mon Feb 6 16:30:23 UTC 2023
Am 03.02.23 um 20:08 schrieb Shashank Sharma:
> From: Alex Deucher <alexander.deucher at amd.com>
>
> This patch adds section for doorbell memory in memory status
> reporting functions like vm/bo_get_memory.
Marek reworked this just recently to pass around a structure. You should
probably rebase the code when that patch lands.
Apart from that looks good to me.
Christian.
>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Shashank Sharma <shashank.sharma at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 4 ++--
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 9 ++++++++-
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 3 ++-
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 ++++++++-------
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 ++-
> 5 files changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
> index 99a7855ab1bc..202df09ba5de 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
> @@ -60,7 +60,7 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f)
> struct amdgpu_fpriv *fpriv = file->driver_priv;
> struct amdgpu_vm *vm = &fpriv->vm;
>
> - uint64_t vram_mem = 0, gtt_mem = 0, cpu_mem = 0;
> + uint64_t vram_mem = 0, gtt_mem = 0, cpu_mem = 0, doorbell_mem = 0;
> ktime_t usage[AMDGPU_HW_IP_NUM];
> uint32_t bus, dev, fn, domain;
> unsigned int hw_ip;
> @@ -75,7 +75,7 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f)
> if (ret)
> return;
>
> - amdgpu_vm_get_memory(vm, &vram_mem, >t_mem, &cpu_mem);
> + amdgpu_vm_get_memory(vm, &vram_mem, >t_mem, &cpu_mem, &doorbell_mem);
> amdgpu_bo_unreserve(vm->root.bo);
>
> amdgpu_ctx_mgr_usage(&fpriv->ctx_mgr, usage);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index b2cfd46c459b..ef1f3106bc69 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -1288,7 +1288,8 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
> }
>
> void amdgpu_bo_get_memory(struct amdgpu_bo *bo, uint64_t *vram_mem,
> - uint64_t *gtt_mem, uint64_t *cpu_mem)
> + uint64_t *gtt_mem, uint64_t *cpu_mem,
> + uint64_t *doorbell_mem)
> {
> unsigned int domain;
>
> @@ -1300,6 +1301,9 @@ void amdgpu_bo_get_memory(struct amdgpu_bo *bo, uint64_t *vram_mem,
> case AMDGPU_GEM_DOMAIN_GTT:
> *gtt_mem += amdgpu_bo_size(bo);
> break;
> + case AMDGPU_GEM_DOMAIN_DOORBELL:
> + *doorbell_mem += amdgpu_bo_size(bo);
> + break;
> case AMDGPU_GEM_DOMAIN_CPU:
> default:
> *cpu_mem += amdgpu_bo_size(bo);
> @@ -1578,6 +1582,9 @@ u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m)
> case AMDGPU_GEM_DOMAIN_GTT:
> placement = " GTT";
> break;
> + case AMDGPU_GEM_DOMAIN_DOORBELL:
> + placement = "DOOR";
> + break;
> case AMDGPU_GEM_DOMAIN_CPU:
> default:
> placement = " CPU";
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index 082f451d26f4..bf9759758f0d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -326,7 +326,8 @@ int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr);
> u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
> u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo);
> void amdgpu_bo_get_memory(struct amdgpu_bo *bo, uint64_t *vram_mem,
> - uint64_t *gtt_mem, uint64_t *cpu_mem);
> + uint64_t *gtt_mem, uint64_t *cpu_mem,
> + uint64_t *doorbell_mem);
> void amdgpu_bo_add_to_shadow_list(struct amdgpu_bo_vm *vmbo);
> int amdgpu_bo_restore_shadow(struct amdgpu_bo *shadow,
> struct dma_fence **fence);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index dc379dc22c77..1561d138945b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -918,7 +918,8 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> }
>
> void amdgpu_vm_get_memory(struct amdgpu_vm *vm, uint64_t *vram_mem,
> - uint64_t *gtt_mem, uint64_t *cpu_mem)
> + uint64_t *gtt_mem, uint64_t *cpu_mem,
> + uint64_t *doorbell_mem)
> {
> struct amdgpu_bo_va *bo_va, *tmp;
>
> @@ -927,37 +928,37 @@ void amdgpu_vm_get_memory(struct amdgpu_vm *vm, uint64_t *vram_mem,
> if (!bo_va->base.bo)
> continue;
> amdgpu_bo_get_memory(bo_va->base.bo, vram_mem,
> - gtt_mem, cpu_mem);
> + gtt_mem, cpu_mem, doorbell_mem);
> }
> list_for_each_entry_safe(bo_va, tmp, &vm->evicted, base.vm_status) {
> if (!bo_va->base.bo)
> continue;
> amdgpu_bo_get_memory(bo_va->base.bo, vram_mem,
> - gtt_mem, cpu_mem);
> + gtt_mem, cpu_mem, doorbell_mem);
> }
> list_for_each_entry_safe(bo_va, tmp, &vm->relocated, base.vm_status) {
> if (!bo_va->base.bo)
> continue;
> amdgpu_bo_get_memory(bo_va->base.bo, vram_mem,
> - gtt_mem, cpu_mem);
> + gtt_mem, cpu_mem, doorbell_mem);
> }
> list_for_each_entry_safe(bo_va, tmp, &vm->moved, base.vm_status) {
> if (!bo_va->base.bo)
> continue;
> amdgpu_bo_get_memory(bo_va->base.bo, vram_mem,
> - gtt_mem, cpu_mem);
> + gtt_mem, cpu_mem, doorbell_mem);
> }
> list_for_each_entry_safe(bo_va, tmp, &vm->invalidated, base.vm_status) {
> if (!bo_va->base.bo)
> continue;
> amdgpu_bo_get_memory(bo_va->base.bo, vram_mem,
> - gtt_mem, cpu_mem);
> + gtt_mem, cpu_mem, doorbell_mem);
> }
> list_for_each_entry_safe(bo_va, tmp, &vm->done, base.vm_status) {
> if (!bo_va->base.bo)
> continue;
> amdgpu_bo_get_memory(bo_va->base.bo, vram_mem,
> - gtt_mem, cpu_mem);
> + gtt_mem, cpu_mem, doorbell_mem);
> }
> spin_unlock(&vm->status_lock);
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> index 094bb4807303..b8ac7d311c8b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> @@ -458,7 +458,8 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm);
> void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev,
> struct amdgpu_vm *vm);
> void amdgpu_vm_get_memory(struct amdgpu_vm *vm, uint64_t *vram_mem,
> - uint64_t *gtt_mem, uint64_t *cpu_mem);
> + uint64_t *gtt_mem, uint64_t *cpu_mem,
> + uint64_t *doorbell_mem);
>
> int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> struct amdgpu_bo_vm *vmbo, bool immediate);
More information about the amd-gfx
mailing list