Skip to content

Commit e9f58ff

Browse files
committed
drm/amdgpu: rework how we handle TLB fences
Add a new VM flag to indicate whether or not we need a TLB fence. Userqs (KFD or KGD) require a TLB fence. A TLB fence is not strictly required for kernel queues, but it shouldn't hurt. That said, enabling this unconditionally should be fine, but it seems to tickle some issues in KIQ/MES. Only enable them for KFD, or when KGD userq queues are enabled (currently via module parameter). Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4798 Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4749 Fixes: f3854e0 ("drm/amdgpu: attach tlb fence to the PTs update") Cc: Christian König <[email protected]> Cc: Prike Liang <[email protected]> Reviewed-by: Prike Liang <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit 69c5fbd) Cc: [email protected]
1 parent 3fc4648 commit e9f58ff

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,10 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params,
10691069
}
10701070

10711071
/* Prepare a TLB flush fence to be attached to PTs */
1072-
if (!params->unlocked) {
1072+
/* The check for need_tlb_fence should be dropped once we
1073+
* sort out the issues with KIQ/MES TLB invalidation timeouts.
1074+
*/
1075+
if (!params->unlocked && vm->need_tlb_fence) {
10731076
amdgpu_vm_tlb_fence_create(params->adev, vm, fence);
10741077

10751078
/* Makes sure no PD/PT is freed before the flush */
@@ -2602,6 +2605,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
26022605
ttm_lru_bulk_move_init(&vm->lru_bulk_move);
26032606

26042607
vm->is_compute_context = false;
2608+
vm->need_tlb_fence = amdgpu_userq_enabled(&adev->ddev);
26052609

26062610
vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
26072611
AMDGPU_VM_USE_CPU_FOR_GFX);
@@ -2739,6 +2743,7 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm)
27392743
dma_fence_put(vm->last_update);
27402744
vm->last_update = dma_fence_get_stub();
27412745
vm->is_compute_context = true;
2746+
vm->need_tlb_fence = true;
27422747

27432748
unreserve_bo:
27442749
amdgpu_bo_unreserve(vm->root.bo);

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ struct amdgpu_vm {
441441
struct ttm_lru_bulk_move lru_bulk_move;
442442
/* Flag to indicate if VM is used for compute */
443443
bool is_compute_context;
444+
/* Flag to indicate if VM needs a TLB fence (KFD or KGD) */
445+
bool need_tlb_fence;
444446

445447
/* Memory partition number, -1 means any partition */
446448
int8_t mem_id;

0 commit comments

Comments
 (0)