drm/amdgpu: cleanup VM shadow BO unreferencing
Subsystems (2)
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
@@ -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
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
@@ -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
PATCH 3/3 drm/amdgpu: fix initializing the VM BO shadow
In reply to a message not in the archiveFrom: 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
@@ -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
Alex Deucher
Reviewed-byRe: [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.
Signed-off-by Christian König <[email protected]>
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@@ -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
Edward O'Callaghan
Acked-bySeries 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.
Signed-off-by Christian König <[email protected]>--- 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@@ -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