Skip to contentSkip to conversation

drm/amdgpu: fix invalid fence handling in amdgpu_vm_tlb_flush

PATCH In review Lang Yu 3 participants 3 messages Sep 2, 2024 – Sep 4, 2024

Subsystems (2)
lore
Share & tools
lore

Lang Yu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix invalid fence handling in amdgpu_vm_tlb_flush

Fixes 5a1c27951966 ("drm/amdgpu: implement TLB flush fence")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -2
index 1d46a5c81ec4..f93804902fd3 100644
@@ -908,10 +908,12 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params,
 {
 	struct amdgpu_vm *vm = params->vm;
 
-	if (!fence || !*fence)
+	tlb_cb->vm = vm;
+	if (!fence || !*fence) {
+		amdgpu_vm_tlb_seq_cb(NULL, &tlb_cb->cb);
 		return;
+	}
 
-	tlb_cb->vm = vm;
 	if (!dma_fence_add_callback(*fence, &tlb_cb->cb,
 				    amdgpu_vm_tlb_seq_cb)) {
 		dma_fence_put(vm->last_tlb_flush);
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Am 02.09.24 um 05:03 schrieb Lang Yu:

Quoted 3 lines
Fixes 5a1c27951966 ("drm/amdgpu: implement TLB flush fence")

Ah yes, that explains why CPU based updates doesn't work reliable any more.

You need to add some explanation to the commit message, e.g. something like "CPU based updates doesn't produce a fence."

With that done Reviewed-by: Christian König <[email protected]>

Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -2
index 1d46a5c81ec4..f93804902fd3 100644
@@ -908,10 +908,12 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params,
  {
  	struct amdgpu_vm *vm = params->vm;
 
-	if (!fence || !*fence)
+	tlb_cb->vm = vm;
+	if (!fence || !*fence) {
+		amdgpu_vm_tlb_seq_cb(NULL, &tlb_cb->cb);
  		return;
+	}
 
-	tlb_cb->vm = vm;
  	if (!dma_fence_add_callback(*fence, &tlb_cb->cb,
  				    amdgpu_vm_tlb_seq_cb)) {
  		dma_fence_put(vm->last_tlb_flush);
#2 lore raw

On 2024-09-02 05:06, Christian König wrote:
Am 02.09.24 um 05:03 schrieb Lang Yu:

Fixes 5a1c27951966 ("drm/amdgpu: implement TLB flush fence")

Ah yes, that explains why CPU based updates doesn't work reliable any more.
My understanding is amdgpu_vm_cpu_commit increase the vm->tlb_seq if needs_flush, so this patch only fix the tlb_cb memory leaking issue.
Regards,
Philip

You need to add some explanation to the commit message, e.g. something like "CPU based updates doesn't produce a fence."

With that done Reviewed-by: Christian König <[email protected]>

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++--

  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index 1d46a5c81ec4..f93804902fd3 100644
@@ -908,10 +908,12 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params,

  {
      struct amdgpu_vm *vm = params->vm;
  -    if (!fence || !*fence)
+    tlb_cb->vm = vm;
+    if (!fence || !*fence) {
+        amdgpu_vm_tlb_seq_cb(NULL, &tlb_cb->cb); return;
+    }
  -    tlb_cb->vm = vm;
      if (!dma_fence_add_callback(*fence, &tlb_cb->cb, amdgpu_vm_tlb_seq_cb)) { dma_fence_put(vm->last_tlb_flush);