aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorChunming Zhou <David1.Zhou@amd.com>2015-11-13 00:43:22 -0500
committerAlex Deucher <alexander.deucher@amd.com>2015-11-18 11:41:02 -0500
commitef9f0a83d68cecca241ee5d61b797d598722772e (patch)
tree16f33168fa5dbb276df19a07cac73577bee0b256 /drivers/gpu/drm/amd/amdgpu
parentc25867dfabf045a8148fd179fa759bb17f670e42 (diff)
drm/amdgpu: move bo_reserve out of amdgpu_vm_clear_bo
Change-Id: Ifbb0c06680494bfa04d0be5e5941d31ae2e5ef28 Signed-off-by: Chunming Zhou <David1.Zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 0513f3fed2c2..e6dc19bc2dd8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -332,6 +332,8 @@ int amdgpu_vm_free_job(struct amdgpu_job *job)
332 * 332 *
333 * @adev: amdgpu_device pointer 333 * @adev: amdgpu_device pointer
334 * @bo: bo to clear 334 * @bo: bo to clear
335 *
336 * need to reserve bo first before calling it.
335 */ 337 */
336static int amdgpu_vm_clear_bo(struct amdgpu_device *adev, 338static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
337 struct amdgpu_bo *bo) 339 struct amdgpu_bo *bo)
@@ -343,24 +345,20 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
343 uint64_t addr; 345 uint64_t addr;
344 int r; 346 int r;
345 347
346 r = amdgpu_bo_reserve(bo, false);
347 if (r)
348 return r;
349
350 r = reservation_object_reserve_shared(bo->tbo.resv); 348 r = reservation_object_reserve_shared(bo->tbo.resv);
351 if (r) 349 if (r)
352 return r; 350 return r;
353 351
354 r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); 352 r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false);
355 if (r) 353 if (r)
356 goto error_unreserve; 354 goto error;
357 355
358 addr = amdgpu_bo_gpu_offset(bo); 356 addr = amdgpu_bo_gpu_offset(bo);
359 entries = amdgpu_bo_size(bo) / 8; 357 entries = amdgpu_bo_size(bo) / 8;
360 358
361 ib = kzalloc(sizeof(struct amdgpu_ib), GFP_KERNEL); 359 ib = kzalloc(sizeof(struct amdgpu_ib), GFP_KERNEL);
362 if (!ib) 360 if (!ib)
363 goto error_unreserve; 361 goto error;
364 362
365 r = amdgpu_ib_get(ring, NULL, entries * 2 + 64, ib); 363 r = amdgpu_ib_get(ring, NULL, entries * 2 + 64, ib);
366 if (r) 364 if (r)
@@ -378,16 +376,14 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
378 if (!r) 376 if (!r)
379 amdgpu_bo_fence(bo, fence, true); 377 amdgpu_bo_fence(bo, fence, true);
380 fence_put(fence); 378 fence_put(fence);
381 if (amdgpu_enable_scheduler) { 379 if (amdgpu_enable_scheduler)
382 amdgpu_bo_unreserve(bo);
383 return 0; 380 return 0;
384 } 381
385error_free: 382error_free:
386 amdgpu_ib_free(adev, ib); 383 amdgpu_ib_free(adev, ib);
387 kfree(ib); 384 kfree(ib);
388 385
389error_unreserve: 386error:
390 amdgpu_bo_unreserve(bo);
391 return r; 387 return r;
392} 388}
393 389
@@ -1087,11 +1083,12 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
1087 AMDGPU_GEM_DOMAIN_VRAM, 1083 AMDGPU_GEM_DOMAIN_VRAM,
1088 AMDGPU_GEM_CREATE_NO_CPU_ACCESS, 1084 AMDGPU_GEM_CREATE_NO_CPU_ACCESS,
1089 NULL, resv, &pt); 1085 NULL, resv, &pt);
1090 ww_mutex_unlock(&resv->lock); 1086 if (r) {
1091 if (r) 1087 ww_mutex_unlock(&resv->lock);
1092 goto error_free; 1088 goto error_free;
1093 1089 }
1094 r = amdgpu_vm_clear_bo(adev, pt); 1090 r = amdgpu_vm_clear_bo(adev, pt);
1091 ww_mutex_unlock(&resv->lock);
1095 if (r) { 1092 if (r) {
1096 amdgpu_bo_unref(&pt); 1093 amdgpu_bo_unref(&pt);
1097 goto error_free; 1094 goto error_free;
@@ -1280,8 +1277,14 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
1280 NULL, NULL, &vm->page_directory); 1277 NULL, NULL, &vm->page_directory);
1281 if (r) 1278 if (r)
1282 return r; 1279 return r;
1283 1280 r = amdgpu_bo_reserve(vm->page_directory, false);
1281 if (r) {
1282 amdgpu_bo_unref(&vm->page_directory);
1283 vm->page_directory = NULL;
1284 return r;
1285 }
1284 r = amdgpu_vm_clear_bo(adev, vm->page_directory); 1286 r = amdgpu_vm_clear_bo(adev, vm->page_directory);
1287 amdgpu_bo_unreserve(vm->page_directory);
1285 if (r) { 1288 if (r) {
1286 amdgpu_bo_unref(&vm->page_directory); 1289 amdgpu_bo_unref(&vm->page_directory);
1287 vm->page_directory = NULL; 1290 vm->page_directory = NULL;