Skip to contentSkip to conversation

drm/amdgpu: add VM update fences back to the root PD v2

PATCH In review Christian König 5 participants 10 messages Feb 19, 2020 – Feb 25, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: add VM update fences back to the root PD v2

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
 {
 	entry->priority = 0;
 	entry->tv.bo = &vm->root.base.bo->tbo;
-	/* One for TTM and one for the CS job */
-	entry->tv.num_shared = 2;
+	/* Two for VM updates, one for TTM and one for the CS job */
+	entry->tv.num_shared = 4;
 	entry->user_pages = NULL;
 	list_add(&entry->tv.head, validated);
 }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
 		goto error_unlock;
 	}
 
+	if (flags & AMDGPU_PTE_VALID) {
+		struct amdgpu_bo *root = vm->root.base.bo;
+
+		if (!dma_fence_is_signaled(vm->last_direct))
+			amdgpu_bo_fence(root, vm->last_direct, true);
+
+		if (!dma_fence_is_signaled(vm->last_delayed))
+			amdgpu_bo_fence(root, vm->last_delayed, true);
+	}
+
 	r = vm->update_funcs->prepare(&params, owner, exclusive);
 	if (r)
 		goto error_unlock;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

I get this conflict on top of drm-next

++<<<<<<< HEAD
 +      r = vm->update_funcs->prepare(&params, resv, sync_mode);
++=======
+       if (flags & AMDGPU_PTE_VALID) {
+               struct amdgpu_bo *root = vm->root.base.bo; +
+               if (!dma_fence_is_signaled(vm->last_direct)) +                       amdgpu_bo_fence(root, vm->last_direct, true); +
+               if (!dma_fence_is_signaled(vm->last_delayed)) +                       amdgpu_bo_fence(root, vm->last_delayed, true); +       }
+
+       r = vm->update_funcs->prepare(&params, owner, exclusive); ++>>>>>>> drm/amdgpu: add VM update fences back to the root PD v2

Should I keep the prepare call before or after your block?

Tom

Quoted 35 lines · Christian König

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
  {
  	entry->priority = 0;
  	entry->tv.bo = &vm->root.base.bo->tbo;
-	/* One for TTM and one for the CS job */
-	entry->tv.num_shared = 2;
+	/* Two for VM updates, one for TTM and one for the CS job */
+	entry->tv.num_shared = 4;
  	entry->user_pages = NULL;
  	list_add(&entry->tv.head, validated);
  }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
  		goto error_unlock;
  	}
 
+	if (flags & AMDGPU_PTE_VALID) {
+		struct amdgpu_bo *root = vm->root.base.bo;
+

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 1606

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -0
+		if (!dma_fence_is_signaled(vm->last_direct))
+			amdgpu_bo_fence(root, vm->last_direct, true);
+
+		if (!dma_fence_is_signaled(vm->last_delayed))
+			amdgpu_bo_fence(root, vm->last_delayed, true);
+	}
+
  	r = vm->update_funcs->prepare(&params, owner, exclusive);
  	if (r)
  		goto error_unlock;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw

Ignore that my brain wasn't engaged in the process.  It's clear where you wanted the prepare call.

Tom

Quoted 60 lines · Tom St Denis

I get this conflict on top of drm-next

++<<<<<<< HEAD
 +      r = vm->update_funcs->prepare(&params, resv, sync_mode);
++=======
+       if (flags & AMDGPU_PTE_VALID) {
+               struct amdgpu_bo *root = vm->root.base.bo;

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10 -0
+
+               if (!dma_fence_is_signaled(vm->last_direct))
+                       amdgpu_bo_fence(root, vm->last_direct, true);
+
+               if (!dma_fence_is_signaled(vm->last_delayed))
+                       amdgpu_bo_fence(root, vm->last_delayed, true);
+       }
+
+       r = vm->update_funcs->prepare(&params, owner, exclusive);
++>>>>>>> drm/amdgpu: add VM update fences back to the root PD v2

Should I keep the prepare call before or after your block?

Tom

Quoted 37 lines · Christian König

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj

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

  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
   {
       entry->priority = 0;
       entry->tv.bo = &vm->root.base.bo->tbo;
-    /* One for TTM and one for the CS job */
-    entry->tv.num_shared = 2;
+    /* Two for VM updates, one for TTM and one for the CS job */
+    entry->tv.num_shared = 4;
       entry->user_pages = NULL;
       list_add(&entry->tv.head, validated);
   }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct 
 amdgpu_device *adev,
           goto error_unlock;
       }
   +    if (flags & AMDGPU_PTE_VALID) {
+        struct amdgpu_bo *root = vm->root.base.bo;
+
+        if (!dma_fence_is_signaled(vm->last_direct))
+            amdgpu_bo_fence(root, vm->last_direct, true);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -0
+
+        if (!dma_fence_is_signaled(vm->last_delayed))
+            amdgpu_bo_fence(root, vm->last_delayed, true);
+    }
+
       r = vm->update_funcs->prepare(&params, owner, exclusive);
       if (r)

          goto error_unlock;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to Christian König

Doesn't build even with conflict resolved:

[root@raven linux]# make
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  CHK     include/generated/compile.h
  CC [M]  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function ‘amdgpu_vm_bo_update_mapping’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:41: error: ‘owner’ undeclared (first use in this function)
 1612 |  r = vm->update_funcs->prepare(&params, owner, exclusive);
      |                                         ^~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:41: note: each undeclared identifier is reported only once for each function it appears in drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:48: error: ‘exclusive’ undeclared (first use in this function)
 1612 |  r = vm->update_funcs->prepare(&params, owner, exclusive);
      |                                                ^~~~~~~~~
make[4]: *** [scripts/Makefile.build:266: drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o] Error 1
make[3]: *** [scripts/Makefile.build:509: drivers/gpu/drm/amd/amdgpu] Error 2
make[2]: *** [scripts/Makefile.build:509: drivers/gpu/drm] Error 2
make[1]: *** [scripts/Makefile.build:509: drivers/gpu] Error 2
make: *** [Makefile:1649: drivers] Error 2

Should I just move to drm-misc-next?

tom

Quoted 35 lines · Christian König

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
  {
  	entry->priority = 0;
  	entry->tv.bo = &vm->root.base.bo->tbo;
-	/* One for TTM and one for the CS job */
-	entry->tv.num_shared = 2;
+	/* Two for VM updates, one for TTM and one for the CS job */
+	entry->tv.num_shared = 4;
  	entry->user_pages = NULL;
  	list_add(&entry->tv.head, validated);
  }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
  		goto error_unlock;
  	}
 
+	if (flags & AMDGPU_PTE_VALID) {
+		struct amdgpu_bo *root = vm->root.base.bo;
+

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 1606

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -0
+		if (!dma_fence_is_signaled(vm->last_direct))
+			amdgpu_bo_fence(root, vm->last_direct, true);
+
+		if (!dma_fence_is_signaled(vm->last_delayed))
+			amdgpu_bo_fence(root, vm->last_delayed, true);
+	}
+
  	r = vm->update_funcs->prepare(&params, owner, exclusive);
  	if (r)
  		goto error_unlock;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw

Well what branch are you trying to merge that into?

The conflict resolution should be simple, just keep the vm->update_funcs->prepare(...) line as it is in your branch.

When you get those errors then something went wrong in your rebase.

Christian.

Am 19.02.20 um 16:14 schrieb Tom St Denis:

Quoted 64 lines

Doesn't build even with conflict resolved:

[root@raven linux]# make
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  CHK     include/generated/compile.h
  CC [M]  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function ‘amdgpu_vm_bo_update_mapping’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:41: error: ‘owner’ undeclared (first use in this function)
 1612 |  r = vm->update_funcs->prepare(&params, owner, exclusive);
      |                                         ^~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:41: note: each undeclared identifier is reported only once for each function it appears in drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:48: error: ‘exclusive’ undeclared (first use in this function)
 1612 |  r = vm->update_funcs->prepare(&params, owner, exclusive);
      |                                                ^~~~~~~~~
make[4]: *** [scripts/Makefile.build:266: drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o] Error 1
make[3]: *** [scripts/Makefile.build:509: drivers/gpu/drm/amd/amdgpu] Error 2
make[2]: *** [scripts/Makefile.build:509: drivers/gpu/drm] Error 2
make[1]: *** [scripts/Makefile.build:509: drivers/gpu] Error 2
make: *** [Makefile:1649: drivers] Error 2

Should I just move to drm-misc-next?

tom

Quoted 37 lines · Christian König

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj

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

  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
   {
       entry->priority = 0;
       entry->tv.bo = &vm->root.base.bo->tbo;
-    /* One for TTM and one for the CS job */
-    entry->tv.num_shared = 2;
+    /* Two for VM updates, one for TTM and one for the CS job */
+    entry->tv.num_shared = 4;
       entry->user_pages = NULL;
       list_add(&entry->tv.head, validated);
   }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct 
 amdgpu_device *adev,
           goto error_unlock;
       }
   +    if (flags & AMDGPU_PTE_VALID) {
+        struct amdgpu_bo *root = vm->root.base.bo;
+
+        if (!dma_fence_is_signaled(vm->last_direct))
+            amdgpu_bo_fence(root, vm->last_direct, true);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -0
+
+        if (!dma_fence_is_signaled(vm->last_delayed))
+            amdgpu_bo_fence(root, vm->last_delayed, true);
+    }
+
       r = vm->update_funcs->prepare(&params, owner, exclusive);
       if (r)

          goto error_unlock;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Acked-by Hawking Zhang
#5 lore raw

The tip of origin/amd-staging-drm-next for me is:

commit 7fd3b632e17e55c5ffd008f9f025754e7daa1b66
Refs: {origin/amd-staging-drm-next}, v5.4-rc7-2847-g7fd3b632e17e Author:     Monk Liu <[email protected]>
AuthorDate: Thu Feb 6 23:55:58 2020 +0800
Commit:     Monk Liu <[email protected]>
CommitDate: Wed Feb 19 13:33:02 2020 +0800

    drm/amdgpu: fix colliding of preemption

    what:
    some os preemption path is messed up with world switch preemption

    fix:
    cleanup those logics so os preemption not mixed with world switch

    this patch is a general fix for issues comes from SRIOV MCBP, but there is still UMD side issues not resovlved yet, so this patch cannot fix all world switch bug.

Which I had fetched just an hour ago.

Quoted 73 lines · Christian König

Well what branch are you trying to merge that into?

The conflict resolution should be simple, just keep the vm->update_funcs->prepare(...) line as it is in your branch.

When you get those errors then something went wrong in your rebase.

Christian.

Am 19.02.20 um 16:14 schrieb Tom St Denis:

Quoted 64 lines

Doesn't build even with conflict resolved:

[root@raven linux]# make
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  CHK     include/generated/compile.h
  CC [M]  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function ‘amdgpu_vm_bo_update_mapping’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:41: error: ‘owner’ undeclared (first use in this function)
 1612 |  r = vm->update_funcs->prepare(&params, owner, exclusive);
      |                                         ^~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:41: note: each undeclared identifier is reported only once for each function it appears in drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:48: error: ‘exclusive’ undeclared (first use in this function)
 1612 |  r = vm->update_funcs->prepare(&params, owner, exclusive);
      |                                                ^~~~~~~~~
make[4]: *** [scripts/Makefile.build:266: drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o] Error 1
make[3]: *** [scripts/Makefile.build:509: drivers/gpu/drm/amd/amdgpu] Error 2
make[2]: *** [scripts/Makefile.build:509: drivers/gpu/drm] Error 2
make[1]: *** [scripts/Makefile.build:509: drivers/gpu] Error 2
make: *** [Makefile:1649: drivers] Error 2

Should I just move to drm-misc-next?

tom

Quoted 37 lines · Christian König

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj

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

  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
   {
       entry->priority = 0;
       entry->tv.bo = &vm->root.base.bo->tbo;
-    /* One for TTM and one for the CS job */
-    entry->tv.num_shared = 2;
+    /* Two for VM updates, one for TTM and one for the CS job */
+    entry->tv.num_shared = 4;
       entry->user_pages = NULL;
       list_add(&entry->tv.head, validated);
   }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct 
 amdgpu_device *adev,
           goto error_unlock;
       }
   +    if (flags & AMDGPU_PTE_VALID) {
+        struct amdgpu_bo *root = vm->root.base.bo;
+
+        if (!dma_fence_is_signaled(vm->last_direct))
+            amdgpu_bo_fence(root, vm->last_direct, true);
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -0
+
+        if (!dma_fence_is_signaled(vm->last_delayed))
+            amdgpu_bo_fence(root, vm->last_delayed, true);
+    }
+
       r = vm->update_funcs->prepare(&params, owner, exclusive);
       if (r)

          goto error_unlock;

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#6 lore raw

For amd-staging-drm-next you need the first version of the patch.

For drm-misc-next or drm-next you need the second version of the patch.

We probably need to merge the patch through drm-misc-next anyway since there is also the patch which causes the problems.

Christian.

Am 19.02.20 um 16:47 schrieb Tom St Denis:

Quoted 21 lines

The tip of origin/amd-staging-drm-next for me is:

commit 7fd3b632e17e55c5ffd008f9f025754e7daa1b66
Refs: {origin/amd-staging-drm-next}, v5.4-rc7-2847-g7fd3b632e17e Author:     Monk Liu <[email protected]>
AuthorDate: Thu Feb 6 23:55:58 2020 +0800
Commit:     Monk Liu <[email protected]>
CommitDate: Wed Feb 19 13:33:02 2020 +0800

    drm/amdgpu: fix colliding of preemption

    what:
    some os preemption path is messed up with world switch preemption

    fix:
    cleanup those logics so os preemption not mixed with world switch

    this patch is a general fix for issues comes from SRIOV MCBP, but there is still UMD side issues not resovlved yet, so this patch cannot fix all world switch bug.

Quoted 88 lines

Which I had fetched just an hour ago.

Quoted 82 lines · Christian König

Well what branch are you trying to merge that into?

The conflict resolution should be simple, just keep the vm->update_funcs->prepare(...) line as it is in your branch.

When you get those errors then something went wrong in your rebase.

Christian.

Am 19.02.20 um 16:14 schrieb Tom St Denis:

Quoted 72 lines

Doesn't build even with conflict resolved:

[root@raven linux]# make
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  CHK     include/generated/compile.h
  CC [M]  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function ‘amdgpu_vm_bo_update_mapping’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:41: error: ‘owner’ undeclared (first use in this function)
 1612 |  r = vm->update_funcs->prepare(&params, owner, exclusive);
      |                                         ^~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:41: note: each undeclared identifier is reported only once for each function it appears in drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1612:48: error: ‘exclusive’ undeclared (first use in this function)
 1612 |  r = vm->update_funcs->prepare(&params, owner, exclusive);
      | ^~~~~~~~~
make[4]: *** [scripts/Makefile.build:266: drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o] Error 1
make[3]: *** [scripts/Makefile.build:509: drivers/gpu/drm/amd/amdgpu] Error 2
make[2]: *** [scripts/Makefile.build:509: drivers/gpu/drm] Error 2
make[1]: *** [scripts/Makefile.build:509: drivers/gpu] Error 2
make: *** [Makefile:1649: drivers] Error 2

Should I just move to drm-misc-next?

tom

Quoted 45 lines · Christian König

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj

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

  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +11 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
   {
       entry->priority = 0;
       entry->tv.bo = &vm->root.base.bo->tbo;
-    /* One for TTM and one for the CS job */
-    entry->tv.num_shared = 2;
+    /* Two for VM updates, one for TTM and one for the CS job */
+    entry->tv.num_shared = 4;
       entry->user_pages = NULL;
       list_add(&entry->tv.head, validated);
   }
@@ -1591,6 +1591,16 @@ static int 
 amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
           goto error_unlock;
       }
   +    if (flags & AMDGPU_PTE_VALID) {
+        struct amdgpu_bo *root = vm->root.base.bo;
+
+        if (!dma_fence_is_signaled(vm->last_direct))
+            amdgpu_bo_fence(root, vm->last_direct, true);
+
+        if (!dma_fence_is_signaled(vm->last_delayed))
+            amdgpu_bo_fence(root, vm->last_delayed, true);
+    }
+
       r = vm->update_funcs->prepare(&params, owner, exclusive);
       if (r)

          goto error_unlock;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw
In reply to Christian König

Am 19.02.20 um 16:02 schrieb Christian König:

Quoted 9 lines

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj

Felix and Xinhui can I get an rb or at least Acked-by for this patch? It is a major problem for testing which needs to get fixed.

Thanks,
Christian.

Quoted 26 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
  {
  	entry->priority = 0;
  	entry->tv.bo = &vm->root.base.bo->tbo;
-	/* One for TTM and one for the CS job */
-	entry->tv.num_shared = 2;
+	/* Two for VM updates, one for TTM and one for the CS job */
+	entry->tv.num_shared = 4;
  	entry->user_pages = NULL;
  	list_add(&entry->tv.head, validated);
  }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
  		goto error_unlock;
  	}
 
+	if (flags & AMDGPU_PTE_VALID) {
+		struct amdgpu_bo *root = vm->root.base.bo;
+

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 1606

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -0
+		if (!dma_fence_is_signaled(vm->last_direct))
+			amdgpu_bo_fence(root, vm->last_direct, true);
+
+		if (!dma_fence_is_signaled(vm->last_delayed))
+			amdgpu_bo_fence(root, vm->last_delayed, true);
+	}
+
  	r = vm->update_funcs->prepare(&params, owner, exclusive);
  	if (r)
  		goto error_unlock;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#8 lore raw
Quoted 45 lines

2020年2月25日 20:45,Christian König <[email protected]> 写道:

Am 19.02.20 um 16:02 schrieb Christian König:

Quoted 9 lines

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj

Felix and Xinhui can I get an rb or at least Acked-by for this patch? It is a major problem for testing which needs to get fixed.

Thanks,
Christian.

Quoted 27 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
 {
 	entry->priority = 0;
 	entry->tv.bo = &vm->root.base.bo->tbo;
-	/* One for TTM and one for the CS job */
-	entry->tv.num_shared = 2;
+	/* Two for VM updates, one for TTM and one for the CS job */
+	entry->tv.num_shared = 4;
 	entry->user_pages = NULL;
 	list_add(&entry->tv.head, validated);
 }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
 		goto error_unlock;
 	}
 +	if (flags & AMDGPU_PTE_VALID) {
+		struct amdgpu_bo *root = vm->root.base.bo;
+
+		if (!dma_fence_is_signaled(vm->last_direct))
+			amdgpu_bo_fence(root, vm->last_direct, true);
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 1606

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -0
+
+		if (!dma_fence_is_signaled(vm->last_delayed))
+			amdgpu_bo_fence(root, vm->last_delayed, true);
+	}
+
 	r = vm->update_funcs->prepare(&params, owner, exclusive);
 	if (r)
 		goto error_unlock;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by on v1 1/1
#9 lore raw
In reply to Christian König
Quoted 9 lines · Christian König

Add update fences to the root PD while mapping BOs.

Otherwise PDs freed during the mapping won't wait for updates to finish and can cause corruptions.

v2: rebased on drm-misc-next

Fixes 90b69cdc5f159 drm/amdgpu: stop adding VM updates fences to the resv obj
Quoted 26 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -2
index d16231d6a790..ef73fa94f357 100644
@@ -588,8 +588,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
  {
  	entry->priority = 0;
  	entry->tv.bo = &vm->root.base.bo->tbo;
-	/* One for TTM and one for the CS job */
-	entry->tv.num_shared = 2;
+	/* Two for VM updates, one for TTM and one for the CS job */
+	entry->tv.num_shared = 4;
  	entry->user_pages = NULL;
  	list_add(&entry->tv.head, validated);
  }
@@ -1591,6 +1591,16 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
  		goto error_unlock;
  	}
 
+	if (flags & AMDGPU_PTE_VALID) {
+		struct amdgpu_bo *root = vm->root.base.bo;
+

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 1606

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -0
+		if (!dma_fence_is_signaled(vm->last_direct))
+			amdgpu_bo_fence(root, vm->last_direct, true);
+
+		if (!dma_fence_is_signaled(vm->last_delayed))
+			amdgpu_bo_fence(root, vm->last_delayed, true);
+	}
+
  	r = vm->update_funcs->prepare(&params, owner, exclusive);
  	if (r)
  		goto error_unlock;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx