aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
diff options
context:
space:
mode:
authorFlora Cui <Flora.Cui@amd.com>2016-07-20 02:44:38 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-08-08 11:33:01 -0400
commit4fea83ff0f61676389b17803365c1e8d2b652183 (patch)
tree5300abfc5efc83fea9966f4b6cadbe0343248772 /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
parent59b4a97742888d9d3c4daa96bd15157ebd496f81 (diff)
drm/amdgpu: expose AMDGPU_GEM_CREATE_VRAM_CLEARED to user space
V2: fix the return value for fill failure and validate bo before filling data Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Flora Cui <Flora.Cui@amd.com> Reviewed-by: Chunming Zhou <David1.Zhou@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 67de19c46ddb..d8e69a7e51f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -340,11 +340,44 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
340 if (unlikely(r != 0)) { 340 if (unlikely(r != 0)) {
341 return r; 341 return r;
342 } 342 }
343
344 if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
345 bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {
346 struct fence *fence;
347
348 if (adev->mman.buffer_funcs_ring == NULL ||
349 !adev->mman.buffer_funcs_ring->ready) {
350 r = -EBUSY;
351 goto fail_free;
352 }
353
354 r = amdgpu_bo_reserve(bo, false);
355 if (unlikely(r != 0))
356 goto fail_free;
357
358 amdgpu_ttm_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_VRAM);
359 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
360 if (unlikely(r != 0))
361 goto fail_unreserve;
362
363 amdgpu_fill_buffer(bo, 0, bo->tbo.resv, &fence);
364 amdgpu_bo_fence(bo, fence, false);
365 amdgpu_bo_unreserve(bo);
366 fence_put(bo->tbo.moving);
367 bo->tbo.moving = fence_get(fence);
368 fence_put(fence);
369 }
343 *bo_ptr = bo; 370 *bo_ptr = bo;
344 371
345 trace_amdgpu_bo_create(bo); 372 trace_amdgpu_bo_create(bo);
346 373
347 return 0; 374 return 0;
375
376fail_unreserve:
377 amdgpu_bo_unreserve(bo);
378fail_free:
379 amdgpu_bo_unref(&bo);
380 return r;
348} 381}
349 382
350int amdgpu_bo_create(struct amdgpu_device *adev, 383int amdgpu_bo_create(struct amdgpu_device *adev,