diff options
author | Christian König <christian.koenig@amd.com> | 2017-09-08 08:09:41 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-09-12 14:30:39 -0400 |
commit | d5884513a31df072879c89c80306d544467ee770 (patch) | |
tree | 599d8ad641fa0824f4854eb410469abaedf9a0d2 | |
parent | 50811c71fa1b7c2f8b422ad532d75a6860f15a8b (diff) |
drm/amdgpu: fix VM sync with always valid BOs v2
All users of a VM must always wait for updates with always
valid BOs to be completed.
v2: remove debugging leftovers, rename struct member
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Roger He <Hongbo.He@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 |
3 files changed, 17 insertions, 10 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 5f19227b35e9..ff61073b7181 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -761,10 +761,6 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p) | |||
761 | if (r) | 761 | if (r) |
762 | return r; | 762 | return r; |
763 | 763 | ||
764 | r = amdgpu_sync_fence(adev, &p->job->sync, vm->last_dir_update); | ||
765 | if (r) | ||
766 | return r; | ||
767 | |||
768 | r = amdgpu_vm_clear_freed(adev, vm, NULL); | 764 | r = amdgpu_vm_clear_freed(adev, vm, NULL); |
769 | if (r) | 765 | if (r) |
770 | return r; | 766 | return r; |
@@ -819,6 +815,12 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p) | |||
819 | } | 815 | } |
820 | 816 | ||
821 | r = amdgpu_vm_handle_moved(adev, vm, &p->job->sync); | 817 | r = amdgpu_vm_handle_moved(adev, vm, &p->job->sync); |
818 | if (r) | ||
819 | return r; | ||
820 | |||
821 | r = amdgpu_sync_fence(adev, &p->job->sync, vm->last_update); | ||
822 | if (r) | ||
823 | return r; | ||
822 | 824 | ||
823 | if (amdgpu_vm_debug && p->bo_list) { | 825 | if (amdgpu_vm_debug && p->bo_list) { |
824 | /* Invalidate all BOs to test for userspace bugs */ | 826 | /* Invalidate all BOs to test for userspace bugs */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 758bbb9e77f3..64baa3138965 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -1141,9 +1141,8 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev, | |||
1141 | goto error_free; | 1141 | goto error_free; |
1142 | 1142 | ||
1143 | amdgpu_bo_fence(parent->base.bo, fence, true); | 1143 | amdgpu_bo_fence(parent->base.bo, fence, true); |
1144 | dma_fence_put(vm->last_dir_update); | 1144 | dma_fence_put(vm->last_update); |
1145 | vm->last_dir_update = dma_fence_get(fence); | 1145 | vm->last_update = fence; |
1146 | dma_fence_put(fence); | ||
1147 | } | 1146 | } |
1148 | } | 1147 | } |
1149 | 1148 | ||
@@ -1804,6 +1803,12 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, | |||
1804 | trace_amdgpu_vm_bo_mapping(mapping); | 1803 | trace_amdgpu_vm_bo_mapping(mapping); |
1805 | } | 1804 | } |
1806 | 1805 | ||
1806 | if (bo_va->base.bo && | ||
1807 | bo_va->base.bo->tbo.resv == vm->root.base.bo->tbo.resv) { | ||
1808 | dma_fence_put(vm->last_update); | ||
1809 | vm->last_update = dma_fence_get(bo_va->last_pt_update); | ||
1810 | } | ||
1811 | |||
1807 | return 0; | 1812 | return 0; |
1808 | } | 1813 | } |
1809 | 1814 | ||
@@ -2587,7 +2592,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
2587 | vm->use_cpu_for_update ? "CPU" : "SDMA"); | 2592 | vm->use_cpu_for_update ? "CPU" : "SDMA"); |
2588 | WARN_ONCE((vm->use_cpu_for_update & !amdgpu_vm_is_large_bar(adev)), | 2593 | WARN_ONCE((vm->use_cpu_for_update & !amdgpu_vm_is_large_bar(adev)), |
2589 | "CPU update of VM recommended only for large BAR system\n"); | 2594 | "CPU update of VM recommended only for large BAR system\n"); |
2590 | vm->last_dir_update = NULL; | 2595 | vm->last_update = NULL; |
2591 | 2596 | ||
2592 | flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | | 2597 | flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | |
2593 | AMDGPU_GEM_CREATE_VRAM_CLEARED; | 2598 | AMDGPU_GEM_CREATE_VRAM_CLEARED; |
@@ -2693,7 +2698,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) | |||
2693 | } | 2698 | } |
2694 | 2699 | ||
2695 | amdgpu_vm_free_levels(&vm->root); | 2700 | amdgpu_vm_free_levels(&vm->root); |
2696 | dma_fence_put(vm->last_dir_update); | 2701 | dma_fence_put(vm->last_update); |
2697 | for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) | 2702 | for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) |
2698 | amdgpu_vm_free_reserved_vmid(adev, vm, i); | 2703 | amdgpu_vm_free_reserved_vmid(adev, vm, i); |
2699 | } | 2704 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index c1accd15efc8..cb6a6222fc3f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | |||
@@ -140,7 +140,7 @@ struct amdgpu_vm { | |||
140 | 140 | ||
141 | /* contains the page directory */ | 141 | /* contains the page directory */ |
142 | struct amdgpu_vm_pt root; | 142 | struct amdgpu_vm_pt root; |
143 | struct dma_fence *last_dir_update; | 143 | struct dma_fence *last_update; |
144 | 144 | ||
145 | /* protecting freed */ | 145 | /* protecting freed */ |
146 | spinlock_t freed_lock; | 146 | spinlock_t freed_lock; |