diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index b33a7fdea7f2..cac65e32a0b9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
| @@ -191,14 +191,21 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev, | |||
| 191 | u32 domain, struct amdgpu_bo **bo_ptr, | 191 | u32 domain, struct amdgpu_bo **bo_ptr, |
| 192 | u64 *gpu_addr, void **cpu_addr) | 192 | u64 *gpu_addr, void **cpu_addr) |
| 193 | { | 193 | { |
| 194 | struct amdgpu_bo_param bp; | ||
| 194 | bool free = false; | 195 | bool free = false; |
| 195 | int r; | 196 | int r; |
| 196 | 197 | ||
| 198 | memset(&bp, 0, sizeof(bp)); | ||
| 199 | bp.size = size; | ||
| 200 | bp.byte_align = align; | ||
| 201 | bp.domain = domain; | ||
| 202 | bp.flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | | ||
| 203 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; | ||
| 204 | bp.type = ttm_bo_type_kernel; | ||
| 205 | bp.resv = NULL; | ||
| 206 | |||
| 197 | if (!*bo_ptr) { | 207 | if (!*bo_ptr) { |
| 198 | r = amdgpu_bo_create(adev, size, align, domain, | 208 | r = amdgpu_bo_create(adev, &bp, bo_ptr); |
| 199 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | | ||
| 200 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, | ||
| 201 | ttm_bo_type_kernel, NULL, bo_ptr); | ||
| 202 | if (r) { | 209 | if (r) { |
| 203 | dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", | 210 | dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", |
| 204 | r); | 211 | r); |
| @@ -470,20 +477,21 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev, | |||
| 470 | unsigned long size, int byte_align, | 477 | unsigned long size, int byte_align, |
| 471 | struct amdgpu_bo *bo) | 478 | struct amdgpu_bo *bo) |
| 472 | { | 479 | { |
| 473 | struct amdgpu_bo_param bp = { | 480 | struct amdgpu_bo_param bp; |
| 474 | .size = size, | ||
| 475 | .byte_align = byte_align, | ||
| 476 | .domain = AMDGPU_GEM_DOMAIN_GTT, | ||
| 477 | .flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC | | ||
| 478 | AMDGPU_GEM_CREATE_SHADOW, | ||
| 479 | .type = ttm_bo_type_kernel, | ||
| 480 | .resv = bo->tbo.resv | ||
| 481 | }; | ||
| 482 | int r; | 481 | int r; |
| 483 | 482 | ||
| 484 | if (bo->shadow) | 483 | if (bo->shadow) |
| 485 | return 0; | 484 | return 0; |
| 486 | 485 | ||
| 486 | memset(&bp, 0, sizeof(bp)); | ||
| 487 | bp.size = size; | ||
| 488 | bp.byte_align = byte_align; | ||
| 489 | bp.domain = AMDGPU_GEM_DOMAIN_GTT; | ||
| 490 | bp.flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC | | ||
| 491 | AMDGPU_GEM_CREATE_SHADOW; | ||
| 492 | bp.type = ttm_bo_type_kernel; | ||
| 493 | bp.resv = bo->tbo.resv; | ||
| 494 | |||
| 487 | r = amdgpu_bo_do_create(adev, &bp, &bo->shadow); | 495 | r = amdgpu_bo_do_create(adev, &bp, &bo->shadow); |
| 488 | if (!r) { | 496 | if (!r) { |
| 489 | bo->shadow->parent = amdgpu_bo_ref(bo); | 497 | bo->shadow->parent = amdgpu_bo_ref(bo); |
| @@ -495,34 +503,26 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev, | |||
| 495 | return r; | 503 | return r; |
| 496 | } | 504 | } |
| 497 | 505 | ||
| 498 | int amdgpu_bo_create(struct amdgpu_device *adev, unsigned long size, | 506 | int amdgpu_bo_create(struct amdgpu_device *adev, |
| 499 | int byte_align, u32 domain, | 507 | struct amdgpu_bo_param *bp, |
| 500 | u64 flags, enum ttm_bo_type type, | ||
| 501 | struct reservation_object *resv, | ||
| 502 | struct amdgpu_bo **bo_ptr) | 508 | struct amdgpu_bo **bo_ptr) |
| 503 | { | 509 | { |
| 504 | struct amdgpu_bo_param bp = { | 510 | u64 flags = bp->flags; |
| 505 | .size = size, | ||
| 506 | .byte_align = byte_align, | ||
| 507 | .domain = domain, | ||
| 508 | .flags = flags & ~AMDGPU_GEM_CREATE_SHADOW, | ||
| 509 | .type = type, | ||
| 510 | .resv = resv | ||
| 511 | }; | ||
| 512 | int r; | 511 | int r; |
| 513 | 512 | ||
| 514 | r = amdgpu_bo_do_create(adev, &bp, bo_ptr); | 513 | bp->flags = bp->flags & ~AMDGPU_GEM_CREATE_SHADOW; |
| 514 | r = amdgpu_bo_do_create(adev, bp, bo_ptr); | ||
| 515 | if (r) | 515 | if (r) |
| 516 | return r; | 516 | return r; |
| 517 | 517 | ||
| 518 | if ((flags & AMDGPU_GEM_CREATE_SHADOW) && amdgpu_need_backup(adev)) { | 518 | if ((flags & AMDGPU_GEM_CREATE_SHADOW) && amdgpu_need_backup(adev)) { |
| 519 | if (!resv) | 519 | if (!bp->resv) |
| 520 | WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, | 520 | WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, |
| 521 | NULL)); | 521 | NULL)); |
| 522 | 522 | ||
| 523 | r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr)); | 523 | r = amdgpu_bo_create_shadow(adev, bp->size, bp->byte_align, (*bo_ptr)); |
| 524 | 524 | ||
| 525 | if (!resv) | 525 | if (!bp->resv) |
| 526 | reservation_object_unlock((*bo_ptr)->tbo.resv); | 526 | reservation_object_unlock((*bo_ptr)->tbo.resv); |
| 527 | 527 | ||
| 528 | if (r) | 528 | if (r) |
