drm/amdgpu: Use atomic64_t type for pdd->tlb_seq
Subsystems (3)
PATCH 1/2 drm/amdgpu: Use atomic64_t type for pdd->tlb_seq
To support multi-thread update page table.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -1
@@ -705,7 +705,7 @@ struct kfd_process_device {/* VM context for GPUVM allocations */ struct file *drm_file;void *drm_priv; -uint64_t tlb_seq; +atomic64_t tlb_seq;/* GPUVM allocations storage */ struct idr alloc_idr;
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3 -3
@@ -1560,7 +1560,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd,return ret; } pdd->drm_priv = drm_file->private_data; - pdd->tlb_seq =0 ; +atomic64_set (&pdd->tlb_seq,0 ); ret =kfd_process_device_reserve_ib_mem (pdd);if (ret)
@@ -1954,10 +1954,10 @@ void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type)uint64_t tlb_seq =amdgpu_vm_tlb_seq (vm);struct kfd_dev *dev = pdd->dev; -if (pdd->tlb_seq == tlb_seq) +if (atomic64_read (&pdd->tlb_seq) == tlb_seq)return ; - pdd->tlb_seq = tlb_seq; +atomic64_set (&pdd->tlb_seq, tlb_seq);if (dev->dqm->sched_policy ==KFD_SCHED_POLICY_NO_HWS ) {/* Nothing to flush until a VMID is assigned, which * only happens when the first queue is created.
Signature · 1 line
2.35.1
PATCH 2/2 drm/amdgpu: Use last_unlocked fence for unlocked update
MMU callback update page table set unlocked flag, add callback tlb_cb to vm->last_unlocked fence, and pass it back to upper layer to wait for page table update done.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -1
@@ -927,7 +927,10 @@ int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, r = vm->update_funcs->commit (¶ms, fence); - if (!unlocked && (!(flags & AMDGPU_PTE_VALID) || params.table_freed)) { + if (!(flags & AMDGPU_PTE_VALID) || params.table_freed) { + if (unlocked && fence) + *fence = dma_fence_get(vm->last_unlocked); + tlb_cb->vm = vm; if (!fence || !*fence || dma_fence_add_callback(*fence, &tlb_cb->cb,
Signature · 1 line
2.35.1
Christian König
maintainerRe: [PATCH 2/2] drm/amdgpu: Use last_unlocked fence for unlocked update
Am 26.03.22 um 01:56 schrieb Philip Yang:
Quoted 14 lines
MMU callback update page table set unlocked flag, add callback
tlb_cbtovm->last_unlockedfence, and pass it back to upper layer to wait for page table update done.Signed-off-by Philip Yang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 930
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -927,7 +927,10 @@ int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, r = vm->update_funcs->commit (¶ms, fence); -if (!unlocked && (!(flags &AMDGPU_PTE_VALID ) || params.table_freed)) { +if (!(flags &AMDGPU_PTE_VALID ) || params.table_freed) {
Dropping the check for the unlocked flag here seems to be ok.
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 933
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3
-0+if (unlocked && fence) + *fence =dma_fence_get (vm->last_unlocked); +
But that doesn't seems to make sense, fence should already contain the necessary fence object if any.
Regards,
Christian.
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0tlb_cb->vm = vm;if (!fence || !*fence || dma_fence_add_callback(*fence, &tlb_cb->cb,
Re: [PATCH 2/2] drm/amdgpu: Use last_unlocked fence for unlocked update
On 2022-03-28 5:21 a.m., Christian König wrote:
Am 26.03.22 um 01:56 schrieb Philip Yang:
MMU callback update page table set unlocked flag, add callback tlb_cb to vm->last_unlocked fence, and pass it back to upper layer to wait for page table update done.
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
@@ -927,7 +927,10 @@ int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
r = vm->update_funcs->commit(¶ms, fence);
- if (!unlocked && (!(flags & AMDGPU_PTE_VALID) || params.table_freed)) { + if (!(flags & AMDGPU_PTE_VALID) || params.table_freed) {
Dropping the check for the unlocked flag here seems to be ok.
+ if (unlocked && fence)
+ *fence = dma_fence_get(vm->last_unlocked); +
But that doesn't seems to make sense, fence should already contain the necessary fence object if any. You are right, seems there is another bug, will send out v2 patch to fix the bug and remove this.
Regards,
Philip
Regards,
Christian.
tlb_cb->vm = vm;
if (!fence || !*fence || dma_fence_add_callback(*fence, &tlb_cb->cb,