diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 5b99214d0ba6..677266b90c74 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -200,19 +200,29 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, | |||
200 | */ | 200 | */ |
201 | void amdgpu_vm_flush(struct amdgpu_ring *ring, | 201 | void amdgpu_vm_flush(struct amdgpu_ring *ring, |
202 | struct amdgpu_vm *vm, | 202 | struct amdgpu_vm *vm, |
203 | struct amdgpu_fence *updates) | 203 | struct fence *updates) |
204 | { | 204 | { |
205 | uint64_t pd_addr = amdgpu_bo_gpu_offset(vm->page_directory); | 205 | uint64_t pd_addr = amdgpu_bo_gpu_offset(vm->page_directory); |
206 | struct amdgpu_vm_id *vm_id = &vm->ids[ring->idx]; | 206 | struct amdgpu_vm_id *vm_id = &vm->ids[ring->idx]; |
207 | struct amdgpu_fence *flushed_updates = vm_id->flushed_updates; | 207 | struct fence *flushed_updates = vm_id->flushed_updates; |
208 | bool is_earlier = false; | ||
209 | |||
210 | if (flushed_updates && updates) { | ||
211 | BUG_ON(flushed_updates->context != updates->context); | ||
212 | is_earlier = (updates->seqno - flushed_updates->seqno <= | ||
213 | INT_MAX) ? true : false; | ||
214 | } | ||
208 | 215 | ||
209 | if (pd_addr != vm_id->pd_gpu_addr || !flushed_updates || | 216 | if (pd_addr != vm_id->pd_gpu_addr || !flushed_updates || |
210 | (updates && amdgpu_fence_is_earlier(flushed_updates, updates))) { | 217 | is_earlier) { |
211 | 218 | ||
212 | trace_amdgpu_vm_flush(pd_addr, ring->idx, vm_id->id); | 219 | trace_amdgpu_vm_flush(pd_addr, ring->idx, vm_id->id); |
213 | vm_id->flushed_updates = amdgpu_fence_ref( | 220 | if (is_earlier) { |
214 | amdgpu_fence_later(flushed_updates, updates)); | 221 | vm_id->flushed_updates = fence_get(updates); |
215 | amdgpu_fence_unref(&flushed_updates); | 222 | fence_put(flushed_updates); |
223 | } | ||
224 | if (!flushed_updates) | ||
225 | vm_id->flushed_updates = fence_get(updates); | ||
216 | vm_id->pd_gpu_addr = pd_addr; | 226 | vm_id->pd_gpu_addr = pd_addr; |
217 | amdgpu_ring_emit_vm_flush(ring, vm_id->id, vm_id->pd_gpu_addr); | 227 | amdgpu_ring_emit_vm_flush(ring, vm_id->id, vm_id->pd_gpu_addr); |
218 | } | 228 | } |
@@ -1347,7 +1357,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) | |||
1347 | fence_put(vm->page_directory_fence); | 1357 | fence_put(vm->page_directory_fence); |
1348 | 1358 | ||
1349 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { | 1359 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { |
1350 | amdgpu_fence_unref(&vm->ids[i].flushed_updates); | 1360 | fence_put(vm->ids[i].flushed_updates); |
1351 | amdgpu_fence_unref(&vm->ids[i].last_id_use); | 1361 | amdgpu_fence_unref(&vm->ids[i].last_id_use); |
1352 | } | 1362 | } |
1353 | 1363 | ||