aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2018-03-14 15:48:17 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-03-14 16:08:24 -0400
commiteab3de23a1639ec9419c1f9239ce651d3c82e7d6 (patch)
tree6d0ef8e3e8b892b47a2330d5803b4d35f4319c1d /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
parente3364dfc6a76e8d3432f3efd130f3dda6ddd698c (diff)
drm/amdgpu: explicit give BO type to amdgpu_bo_create
Drop the "kernel" and sg parameter and give the BO type to create explicit to amdgpu_bo_create instead of figuring it out from the parameters. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Roger He <Hongbo.He@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.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 3ad2b6c65b85..ec6ec1f8a085 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -191,10 +191,10 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
191 int r; 191 int r;
192 192
193 if (!*bo_ptr) { 193 if (!*bo_ptr) {
194 r = amdgpu_bo_create(adev, size, align, true, domain, 194 r = amdgpu_bo_create(adev, size, align, domain,
195 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 195 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
196 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 196 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
197 NULL, NULL, bo_ptr); 197 ttm_bo_type_kernel, NULL, bo_ptr);
198 if (r) { 198 if (r) {
199 dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", 199 dev_err(adev->dev, "(%d) failed to allocate kernel bo\n",
200 r); 200 r);
@@ -335,21 +335,19 @@ fail:
335 return false; 335 return false;
336} 336}
337 337
338static int amdgpu_bo_do_create(struct amdgpu_device *adev, 338static int amdgpu_bo_do_create(struct amdgpu_device *adev, unsigned long size,
339 unsigned long size, int byte_align, 339 int byte_align, u32 domain,
340 bool kernel, u32 domain, u64 flags, 340 u64 flags, enum ttm_bo_type type,
341 struct sg_table *sg,
342 struct reservation_object *resv, 341 struct reservation_object *resv,
343 struct amdgpu_bo **bo_ptr) 342 struct amdgpu_bo **bo_ptr)
344{ 343{
345 struct ttm_operation_ctx ctx = { 344 struct ttm_operation_ctx ctx = {
346 .interruptible = !kernel, 345 .interruptible = (type != ttm_bo_type_kernel),
347 .no_wait_gpu = false, 346 .no_wait_gpu = false,
348 .resv = resv, 347 .resv = resv,
349 .flags = TTM_OPT_FLAG_ALLOW_RES_EVICT 348 .flags = TTM_OPT_FLAG_ALLOW_RES_EVICT
350 }; 349 };
351 struct amdgpu_bo *bo; 350 struct amdgpu_bo *bo;
352 enum ttm_bo_type type;
353 unsigned long page_align; 351 unsigned long page_align;
354 size_t acc_size; 352 size_t acc_size;
355 int r; 353 int r;
@@ -360,13 +358,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
360 if (!amdgpu_bo_validate_size(adev, size, domain)) 358 if (!amdgpu_bo_validate_size(adev, size, domain))
361 return -ENOMEM; 359 return -ENOMEM;
362 360
363 if (kernel) {
364 type = ttm_bo_type_kernel;
365 } else if (sg) {
366 type = ttm_bo_type_sg;
367 } else {
368 type = ttm_bo_type_device;
369 }
370 *bo_ptr = NULL; 361 *bo_ptr = NULL;
371 362
372 acc_size = ttm_bo_dma_acc_size(&adev->mman.bdev, size, 363 acc_size = ttm_bo_dma_acc_size(&adev->mman.bdev, size,
@@ -385,7 +376,8 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
385 AMDGPU_GEM_DOMAIN_GWS | 376 AMDGPU_GEM_DOMAIN_GWS |
386 AMDGPU_GEM_DOMAIN_OA); 377 AMDGPU_GEM_DOMAIN_OA);
387 bo->allowed_domains = bo->preferred_domains; 378 bo->allowed_domains = bo->preferred_domains;
388 if (!kernel && bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM) 379 if (type != ttm_bo_type_kernel &&
380 bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
389 bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT; 381 bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT;
390 382
391 bo->flags = flags; 383 bo->flags = flags;
@@ -423,7 +415,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
423 415
424 r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, 416 r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type,
425 &bo->placement, page_align, &ctx, acc_size, 417 &bo->placement, page_align, &ctx, acc_size,
426 sg, resv, &amdgpu_ttm_bo_destroy); 418 NULL, resv, &amdgpu_ttm_bo_destroy);
427 if (unlikely(r != 0)) 419 if (unlikely(r != 0))
428 return r; 420 return r;
429 421
@@ -435,7 +427,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
435 else 427 else
436 amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); 428 amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0);
437 429
438 if (kernel) 430 if (type == ttm_bo_type_kernel)
439 bo->tbo.priority = 1; 431 bo->tbo.priority = 1;
440 432
441 if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && 433 if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
@@ -479,12 +471,11 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
479 if (bo->shadow) 471 if (bo->shadow)
480 return 0; 472 return 0;
481 473
482 r = amdgpu_bo_do_create(adev, size, byte_align, true, 474 r = amdgpu_bo_do_create(adev, size, byte_align, AMDGPU_GEM_DOMAIN_GTT,
483 AMDGPU_GEM_DOMAIN_GTT,
484 AMDGPU_GEM_CREATE_CPU_GTT_USWC | 475 AMDGPU_GEM_CREATE_CPU_GTT_USWC |
485 AMDGPU_GEM_CREATE_SHADOW, 476 AMDGPU_GEM_CREATE_SHADOW,
486 NULL, bo->tbo.resv, 477 ttm_bo_type_kernel,
487 &bo->shadow); 478 bo->tbo.resv, &bo->shadow);
488 if (!r) { 479 if (!r) {
489 bo->shadow->parent = amdgpu_bo_ref(bo); 480 bo->shadow->parent = amdgpu_bo_ref(bo);
490 mutex_lock(&adev->shadow_list_lock); 481 mutex_lock(&adev->shadow_list_lock);
@@ -495,18 +486,17 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
495 return r; 486 return r;
496} 487}
497 488
498int amdgpu_bo_create(struct amdgpu_device *adev, 489int amdgpu_bo_create(struct amdgpu_device *adev, unsigned long size,
499 unsigned long size, int byte_align, 490 int byte_align, u32 domain,
500 bool kernel, u32 domain, u64 flags, 491 u64 flags, enum ttm_bo_type type,
501 struct sg_table *sg,
502 struct reservation_object *resv, 492 struct reservation_object *resv,
503 struct amdgpu_bo **bo_ptr) 493 struct amdgpu_bo **bo_ptr)
504{ 494{
505 uint64_t parent_flags = flags & ~AMDGPU_GEM_CREATE_SHADOW; 495 uint64_t parent_flags = flags & ~AMDGPU_GEM_CREATE_SHADOW;
506 int r; 496 int r;
507 497
508 r = amdgpu_bo_do_create(adev, size, byte_align, kernel, domain, 498 r = amdgpu_bo_do_create(adev, size, byte_align, domain,
509 parent_flags, sg, resv, bo_ptr); 499 parent_flags, type, resv, bo_ptr);
510 if (r) 500 if (r)
511 return r; 501 return r;
512 502