drm/amdgpu: add user queue vm identifier
Subsystems (2)
PATCH 1/3 drm/amdgpu: add user queue vm identifier
Add a user queue vm identifier for each userqueue
kms opt accessing.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +5 -0
@@ -1249,10 +1249,13 @@ amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr,int amdgpu_userq_mgr_init (struct amdgpu_userq_mgr *userq_mgr,struct drm_file *file_priv,struct amdgpu_device *adev) { +struct amdgpu_fpriv *fpriv =uq_mgr_to_fpriv (userq_mgr); +mutex_init (&userq_mgr->userq_mutex);xa_init_flags (&userq_mgr->userq_mgr_xa,XA_FLAGS_ALLOC ); userq_mgr->adev = adev; userq_mgr->file = file_priv; + fpriv->vm.is_userq_context = true;INIT_DELAYED_WORK (&userq_mgr->resume_work, amdgpu_userq_restore_worker);return 0 ;
@@ -1262,6 +1265,7 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr) {struct amdgpu_usermode_queue *queue;unsigned long queue_id; +struct amdgpu_fpriv *fpriv =uq_mgr_to_fpriv (userq_mgr);cancel_delayed_work_sync (&userq_mgr->resume_work);
@@ -1276,6 +1280,7 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr)xa_destroy (&userq_mgr->userq_mgr_xa);mutex_unlock (&userq_mgr->userq_mutex);mutex_destroy (&userq_mgr->userq_mutex); + fpriv->vm.is_userq_context = false; }int amdgpu_userq_suspend (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -2591,7 +2591,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,ttm_lru_bulk_move_init (&vm->lru_bulk_move); vm->is_compute_context = false; - + vm->is_userq_context = false; vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &AMDGPU_VM_USE_CPU_FOR_GFX );
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -1
@@ -439,7 +439,7 @@ struct amdgpu_vm {struct ttm_lru_bulk_move lru_bulk_move;/* Flag to indicate if VM is used for compute */ bool is_compute_context; - +bool is_userq_context;/* Memory partition number, -1 means any partition */ int8_t mem_id;
Signature · 1 line
2.34.1
PATCH 2/3 drm/amdgpu: rework the userq tlb flush
The userq TLB flush should be performed after
the vm update complete and input fence signal.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -0
@@ -384,6 +384,7 @@ amdgpu_userq_wait_for_last_fence(struct amdgpu_userq_mgr *uq_mgr,return -ETIME ; } } +amdgpu_gmc_flush_gpu_tlb_pasid (uq_mgr->adev, queue->vm->pasid,2 , true,0 );return ret; }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -2
@@ -1062,7 +1062,8 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params, }/* Prepare a TLB flush fence to be attached to PTs */ -if (!params->unlocked && vm->is_compute_context) { +if (!params->unlocked && (vm->is_compute_context || + vm->is_userq_context)) {amdgpu_vm_tlb_fence_create (params->adev, vm, fence);/* Makes sure no PD/PT is freed before the flush */
@@ -2792,7 +2793,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)amdgpu_bo_unreserve (root);amdgpu_bo_unref (&root);WARN_ON (vm->root.bo); - +amdgpu_gmc_flush_gpu_tlb_pasid (adev, vm->pasid,2 , true,0 );amdgpu_vm_fini_entities (vm);if (!RB_EMPTY_ROOT (&vm->va.rb_root)) {
Signature · 1 line
2.34.1
Christian König
maintainerRe: [PATCH 2/3] drm/amdgpu: rework the userq tlb flush
Quoted 14 lines · Prike Liang
The userq TLB flush should be performed after
the vm update complete and input fence signal.Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_wait_for_last_fence(struct amdgpu_userq_mgr *uq_mgr, · line 387
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-0@@ -384,6 +384,7 @@ amdgpu_userq_wait_for_last_fence(struct amdgpu_userq_mgr *uq_mgr,return -ETIME ; } } +amdgpu_gmc_flush_gpu_tlb_pasid (uq_mgr->adev, queue->vm->pasid,2 , true,0 );
Please drop that one, it doesn't seem to make any sense at all.
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params, · line 1066
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -1062,7 +1062,8 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params, }/* Prepare a TLB flush fence to be attached to PTs */ -if (!params->unlocked && vm->is_compute_context) { +if (!params->unlocked && (vm->is_compute_context || + vm->is_userq_context)) {
Just drop the is_compute_context check here, don't add any new checks.
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) · line 2796
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1amdgpu_vm_tlb_fence_create (params->adev, vm, fence);/* Makes sure no PD/PT is freed before the flush */ @@ -2792,7 +2793,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)amdgpu_bo_unreserve (root);amdgpu_bo_unref (&root);WARN_ON (vm->root.bo); - +amdgpu_gmc_flush_gpu_tlb_pasid (adev, vm->pasid,2 , true,0 );
Please drop that one as well, it doesn't seem to make sense.
Regards,
Christian.
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0amdgpu_vm_fini_entities (vm);if (!RB_EMPTY_ROOT (&vm->va.rb_root)) {
PATCH 3/3 drm/amdgpu: fix the vm update tlb sequence
In reply to Prike LiangThe VM TLB sequence is incremented by the VM update commit invoker, so it should not be increased again in the commit callback.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -2
@@ -106,8 +106,6 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,static int amdgpu_vm_cpu_commit (struct amdgpu_vm_update_params *p,struct dma_fence **fence) { -if (p->needs_flush) -atomic64_inc (&p->vm->tlb_seq);mb ();amdgpu_device_flush_hdp (p->adev,NULL );
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +2 -0
@@ -420,6 +420,8 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto exit; r = vm->update_funcs->commit (¶ms,NULL ); +if (params.needs_flush) +atomic64_inc (&vm->tlb_seq); exit:drm_dev_exit (idx);return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +0 -3
@@ -115,9 +115,6 @@ static int amdgpu_vm_sdma_commit(struct amdgpu_vm_update_params *p,WARN_ON (ib->length_dw ==0 );amdgpu_ring_pad_ib (ring, ib); -if (p->needs_flush) -atomic64_inc (&p->vm->tlb_seq); -WARN_ON (ib->length_dw > p->num_dw_left); f =amdgpu_job_submit (p->job);
Signature · 1 line
2.34.1
Christian König
maintainerRe: [PATCH 3/3] drm/amdgpu: fix the vm update tlb sequence
Quoted 3 lines · Prike Liang
The VM TLB sequence is incremented by the VM update commit invoker, so it should not be increased again in the commit callback.
Clear NAK to that. It must be incremented by *both*!
Regards,
Christian.
Quoted 48 lines
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0
-2@@ -106,8 +106,6 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,static int amdgpu_vm_cpu_commit (struct amdgpu_vm_update_params *p,struct dma_fence **fence) { -if (p->needs_flush) -atomic64_inc (&p->vm->tlb_seq);mb ();amdgpu_device_flush_hdp (p->adev,NULL );drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +2
-0@@ -420,6 +420,8 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto exit; r = vm->update_funcs->commit (¶ms,NULL ); +if (params.needs_flush) +atomic64_inc (&vm->tlb_seq); exit:drm_dev_exit (idx);return r;drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +0
-3@@ -115,9 +115,6 @@ static int amdgpu_vm_sdma_commit(struct amdgpu_vm_update_params *p,WARN_ON (ib->length_dw ==0 );amdgpu_ring_pad_ib (ring, ib); -if (p->needs_flush) -atomic64_inc (&p->vm->tlb_seq); -WARN_ON (ib->length_dw > p->num_dw_left); f =amdgpu_job_submit (p->job);
Christian König
maintainerQuoted 2 lines · Prike Liang
Add a user queue vm identifier for each userqueue
kms opt accessing.
Clear NAK to that approach, we don't want any specialized handling in the VM if userqueues are enabled.
Christian.
Quoted 68 lines
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +5
-0@@ -1249,10 +1249,13 @@ amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr,int amdgpu_userq_mgr_init (struct amdgpu_userq_mgr *userq_mgr,struct drm_file *file_priv,struct amdgpu_device *adev) { +struct amdgpu_fpriv *fpriv =uq_mgr_to_fpriv (userq_mgr); +mutex_init (&userq_mgr->userq_mutex);xa_init_flags (&userq_mgr->userq_mgr_xa,XA_FLAGS_ALLOC ); userq_mgr->adev = adev; userq_mgr->file = file_priv; + fpriv->vm.is_userq_context = true;INIT_DELAYED_WORK (&userq_mgr->resume_work, amdgpu_userq_restore_worker);return 0 ;@@ -1262,6 +1265,7 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr) {struct amdgpu_usermode_queue *queue;unsigned long queue_id; +struct amdgpu_fpriv *fpriv =uq_mgr_to_fpriv (userq_mgr);cancel_delayed_work_sync (&userq_mgr->resume_work);@@ -1276,6 +1280,7 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr)xa_destroy (&userq_mgr->userq_mgr_xa);mutex_unlock (&userq_mgr->userq_mutex);mutex_destroy (&userq_mgr->userq_mutex); + fpriv->vm.is_userq_context = false; }int amdgpu_userq_suspend (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -2591,7 +2591,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,ttm_lru_bulk_move_init (&vm->lru_bulk_move); vm->is_compute_context = false; - + vm->is_userq_context = false; vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &AMDGPU_VM_USE_CPU_FOR_GFX );drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1
-1@@ -439,7 +439,7 @@ struct amdgpu_vm {struct ttm_lru_bulk_move lru_bulk_move;/* Flag to indicate if VM is used for compute */ bool is_compute_context; - +bool is_userq_context;/* Memory partition number, -1 means any partition */ int8_t mem_id;