drm/amdgpu: fix amdgpu_vm_handle_moved as well
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix amdgpu_vm_handle_moved as well
From: Christian König <[email protected]>
There is no guarantee that the last BO_VA actually needed an update.
Additional to that all command submissions must wait for moved BOs to be cleared, not just the first one.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 ++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
@@ -805,7 +805,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p) } - r =amdgpu_vm_handle_moved (adev, vm, &p->job->sync); + r =amdgpu_vm_handle_moved (adev, vm);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -6
@@ -1997,7 +1997,6 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,* * @adev: amdgpu_device pointer * @vm: requested vm -* @sync: sync object to add fences to * * Make sure all BOs which are moved are updated in the PTs. * Returns 0 for success.
@@ -2005,8 +2004,7 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,* PTs have to be reserved! */ int amdgpu_vm_handle_moved (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -struct amdgpu_sync *sync) +struct amdgpu_vm *vm) {struct amdgpu_bo_va *bo_va =NULL ;bool clear;
@@ -2025,13 +2023,15 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,if (r)return r; +if (bo_va->base.bo->tbo.resv != vm->root.base.bo->tbo.resv) { +dma_fence_put (vm->last_update); + vm->last_update =dma_fence_get (bo_va->last_pt_update); + } +spin_lock (&vm->status_lock); }spin_unlock (&vm->status_lock); -if (bo_va) - r =amdgpu_sync_fence (adev, sync, bo_va->last_pt_update); -return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -2
@@ -250,8 +250,7 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,struct amdgpu_vm *vm, struct dma_fence **fence);int amdgpu_vm_handle_moved (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -struct amdgpu_sync *sync); +struct amdgpu_vm *vm);int amdgpu_vm_bo_update (struct amdgpu_device *adev,struct amdgpu_bo_va *bo_va,bool clear);
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1505127498-21621-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 3 lines · Christian König
From: Christian König <[email protected]>
There is no guarantee that the last
BO_VAactually needed an update.
Good catch. One comment inline
Quoted 47 lines
Additional to that all command submissions must wait for moved BOs to be cleared, not just the first one.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 ++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1@@ -805,7 +805,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p) } - r =amdgpu_vm_handle_moved (adev, vm, &p->job->sync); + r =amdgpu_vm_handle_moved (adev, vm);if (r)return r;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-3@@ -1997,7 +1997,6 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,* * @adev: amdgpu_device pointer * @vm: requested vm -* @sync: sync object to add fences to * * Make sure all BOs which are moved are updated in the PTs. * Returns 0 for success. @@ -2005,8 +2004,7 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,* PTs have to be reserved! */ int amdgpu_vm_handle_moved (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -struct amdgpu_sync *sync) +struct amdgpu_vm *vm) {struct amdgpu_bo_va *bo_va =NULL ;bool clear;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_handle_moved(struct amdgpu_device *adev, · line 2026
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0@@ -2025,13 +2023,15 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,if (r)return r; +if (bo_va->base.bo->tbo.resv != vm->root.base.bo->tbo.resv) {
When we expand mapping fence, we will sync all moved update and clear here, instead of moved update in amdgpu_vm_bo_update in previous patch. Anyway, this patch is Reviewed-by: Chunming Zhou <[email protected]>
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-3+dma_fence_put (vm->last_update); + vm->last_update =dma_fence_get (bo_va->last_pt_update); + } +spin_lock (&vm->status_lock); }spin_unlock (&vm->status_lock); -if (bo_va) - r =amdgpu_sync_fence (adev, sync, bo_va->last_pt_update); -return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h int amdgpu_vm_clear_freed(struct amdgpu_device *adev, · line 256
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1
-2@@ -250,8 +250,7 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,struct amdgpu_vm *vm, struct dma_fence **fence);int amdgpu_vm_handle_moved (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -struct amdgpu_sync *sync); +struct amdgpu_vm *vm);int amdgpu_vm_bo_update (struct amdgpu_device *adev,struct amdgpu_bo_va *bo_va,bool clear);
_______________________________________________
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): 8f74f7cb-afca-ace1-4a7c-93c533ef2923-5C7GfCeVMHo@public.gmane.org
Quoted 3 lines
Quoted 2 lines
+ if (
bo_va->base.bo->tbo.resv!=vm->root.base.bo->tbo.resv) {When we expand mapping fence, we will sync all moved update and clear here, instead of moved update in
amdgpu_vm_bo_updatein previous patch.
Yeah, turned out this patch actually didn't worked as expected because the bo_va->last_pt_update fence could be stale and old and replaces the new and fresh fence in vm->last_update resulting in VM faults.
I've send a V2 of that patch yesterday which fixes this (and is quite a bit cleaner in general).
Please take a look at that one instead.
Thanks,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx