Skip to contentSkip to conversation

drm/amdgpu: cleanup VM shadow BO unreferencing

PATCH In review Christian König 3 participants 5 messages Sep 16, 2016 2 messages not in the archive

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

PATCH 1/3 drm/amdgpu: cleanup VM shadow BO unreferencing

From: Christian König <[email protected]>

Unreference the shadow BOs in the error path as well and drop the NULL checks.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10 -6
index 8928a2a..19c7bf7 100644
@@ -1429,6 +1429,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
 
 		r = amdgpu_vm_clear_bo(adev, vm, pt);
 		if (r) {
+			amdgpu_bo_unref(&pt->shadow);
 			amdgpu_bo_unref(&pt);
 			goto error_free;
 		}
@@ -1635,6 +1636,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	return 0;
 
 error_free_page_directory:
+	amdgpu_bo_unref(&vm->page_directory->shadow);
 	amdgpu_bo_unref(&vm->page_directory);
 	vm->page_directory = NULL;
 
@@ -1677,15 +1679,17 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	}
 
 	for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) {
-		if (vm->page_tables[i].entry.robj &&
-		    vm->page_tables[i].entry.robj->shadow)
-			amdgpu_bo_unref(&vm->page_tables[i].entry.robj->shadow);
-		amdgpu_bo_unref(&vm->page_tables[i].entry.robj);
+		struct amdgpu_bo *pt = vm->page_tables[i].entry.robj;
+
+		if (!pt)
+			continue;
+
+		amdgpu_bo_unref(&pt->shadow);
+		amdgpu_bo_unref(&pt);
 	}
 	drm_free_large(vm->page_tables);
 
-	if (vm->page_directory->shadow)
-		amdgpu_bo_unref(&vm->page_directory->shadow);
+	amdgpu_bo_unref(&vm->page_directory->shadow);
 	amdgpu_bo_unref(&vm->page_directory);
 	fence_put(vm->page_directory_fence);
 }
Signature · 6 lines
2.5.0

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

A message that is not in the archive (sent off-list or not yet received): 1474027940-2333-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#2 lore raw

PATCH 2/3 drm/amdgpu: fix initializing the VM last eviction counter

From: Christian König <[email protected]>

Close a very small window where something can go wrong.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -2
index 19c7bf7..63649c3 100644
@@ -1628,13 +1628,17 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 		goto error_free_page_directory;
 
 	r = amdgpu_vm_clear_bo(adev, vm, vm->page_directory);
-	amdgpu_bo_unreserve(vm->page_directory);
 	if (r)
-		goto error_free_page_directory;
+		goto error_unreserve;
+
 	vm->last_eviction_counter = atomic64_read(&adev->num_evictions);
+	amdgpu_bo_unreserve(vm->page_directory);
 
 	return 0;
 
+error_unreserve:
+	amdgpu_bo_unreserve(vm->page_directory);
+
 error_free_page_directory:
 	amdgpu_bo_unref(&vm->page_directory->shadow);
 	amdgpu_bo_unref(&vm->page_directory);
Signature · 6 lines
2.5.0

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

PATCH 3/3 drm/amdgpu: fix initializing the VM BO shadow

In reply to a message not in the archive

From: Christian König <[email protected]>

We need to clear the shadows as well.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +15 -0
index 63649c3..2bb78dc 100644
@@ -1434,6 +1434,15 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
 			goto error_free;
 		}
 
+		if (pt->shadow) {
+			r = amdgpu_vm_clear_bo(adev, vm, pt->shadow);
+			if (r) {
+				amdgpu_bo_unref(&pt->shadow);
+				amdgpu_bo_unref(&pt);
+				goto error_free;
+			}
+		}
+
 		entry->robj = pt;
 		entry->priority = 0;
 		entry->tv.bo = &entry->robj->tbo;
@@ -1631,6 +1640,12 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	if (r)
 		goto error_unreserve;
 
+	if (vm->page_directory->shadow) {
+		r = amdgpu_vm_clear_bo(adev, vm, vm->page_directory->shadow);
+		if (r)
+			goto error_unreserve;
+	}
+
 	vm->last_eviction_counter = atomic64_read(&adev->num_evictions);
 	amdgpu_bo_unreserve(vm->page_directory);
 
Signature · 6 lines
2.5.0

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

A message that is not in the archive (sent off-list or not yet received): 1474027940-2333-3-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

Reviewed-by
#5 lore raw

Re: [PATCH 3/3] drm/amdgpu: fix initializing the VM BO shadow

Quoted 5 lines · Christian König

From: Christian König <[email protected]>

We need to clear the shadows as well.

Series is:

Quoted 40 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +15 -1
index 63649c3..2bb78dc 100644
@@ -1434,6 +1434,15 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
                        goto error_free;
                }
 
+               if (pt->shadow) {
+                       r = amdgpu_vm_clear_bo(adev, vm, pt->shadow);
+                       if (r) {
+                               amdgpu_bo_unref(&pt->shadow);
+                               amdgpu_bo_unref(&pt);
+                               goto error_free;
+                       }
+               }
+
                entry->robj = pt;
                entry->priority = 0;
                entry->tv.bo = &entry->robj->tbo;
@@ -1631,6 +1640,12 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
        if (r)
                goto error_unreserve;
 
+       if (vm->page_directory->shadow) {
+               r = amdgpu_vm_clear_bo(adev, vm, vm->page_directory->shadow);
+               if (r)
+                       goto error_unreserve;
+       }
+
        vm->last_eviction_counter = atomic64_read(&adev->num_evictions);
        amdgpu_bo_unreserve(vm->page_directory);
 
--

2.5.0

Quoted 4 lines

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

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

#6 lore raw
In reply to a message not in the archive

Series is,

Quoted 44 lines · Christian König

From: Christian König <[email protected]>

Unreference the shadow BOs in the error path as well and drop the NULL checks.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8 -4
index 8928a2a..19c7bf7 100644
@@ -1429,6 +1429,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
 
 		r = amdgpu_vm_clear_bo(adev, vm, pt);
 		if (r) {
+			amdgpu_bo_unref(&pt->shadow);
 			amdgpu_bo_unref(&pt);
 			goto error_free;
 		}
@@ -1635,6 +1636,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	return 0;
 
 error_free_page_directory:
+	amdgpu_bo_unref(&vm->page_directory->shadow);
 	amdgpu_bo_unref(&vm->page_directory);
 	vm->page_directory = NULL;
 
@@ -1677,15 +1679,17 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	}
 
 	for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) {
-		if (vm->page_tables[i].entry.robj &&
-		    vm->page_tables[i].entry.robj->shadow)
-			amdgpu_bo_unref(&vm->page_tables[i].entry.robj->shadow);
-		amdgpu_bo_unref(&vm->page_tables[i].entry.robj);
+		struct amdgpu_bo *pt = vm->page_tables[i].entry.robj;
+
+		if (!pt)
+			continue;
+
+		amdgpu_bo_unref(&pt->shadow);

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) · line 1695

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
+		amdgpu_bo_unref(&pt);
 	}
 	drm_free_large(vm->page_tables);
 
-	if (vm->page_directory->shadow)
-		amdgpu_bo_unref(&vm->page_directory->shadow);
+	amdgpu_bo_unref(&vm->page_directory->shadow);
 	amdgpu_bo_unref(&vm->page_directory);
 	fence_put(vm->page_directory_fence);
 }

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