Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Add a parameter to amdgpu_bo_create()

The parameter init_value contains the value to which we initialized
VRAM bo when AMDGPU_GEM_CREATE_VRAM_CLEARED flag is set.

Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Yong Zhao and committed by
Alex Deucher
2046d46d 078af1a3

+29 -20
+2 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
··· 184 184 return -ENOMEM; 185 185 186 186 r = amdgpu_bo_create(adev, size, PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_GTT, 187 - AMDGPU_GEM_CREATE_CPU_GTT_USWC, NULL, NULL, &(*mem)->bo); 187 + AMDGPU_GEM_CREATE_CPU_GTT_USWC, NULL, NULL, 0, 188 + &(*mem)->bo); 188 189 if (r) { 189 190 dev_err(adev->dev, 190 191 "failed to allocate BO for amdkfd (%d)\n", r);
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
··· 81 81 82 82 n = AMDGPU_BENCHMARK_ITERATIONS; 83 83 r = amdgpu_bo_create(adev, size, PAGE_SIZE, true, sdomain, 0, NULL, 84 - NULL, &sobj); 84 + NULL, 0, &sobj); 85 85 if (r) { 86 86 goto out_cleanup; 87 87 } ··· 94 94 goto out_cleanup; 95 95 } 96 96 r = amdgpu_bo_create(adev, size, PAGE_SIZE, true, ddomain, 0, NULL, 97 - NULL, &dobj); 97 + NULL, 0, &dobj); 98 98 if (r) { 99 99 goto out_cleanup; 100 100 }
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
··· 124 124 ret = amdgpu_bo_create_restricted(adev, size, PAGE_SIZE, 125 125 true, domain, flags, 126 126 NULL, &placement, NULL, 127 - &obj); 127 + 0, &obj); 128 128 if (ret) { 129 129 DRM_ERROR("(%d) bo create failed\n", ret); 130 130 return ret;
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
··· 144 144 PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, 145 145 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 146 146 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 147 - NULL, NULL, &adev->gart.robj); 147 + NULL, NULL, 0, &adev->gart.robj); 148 148 if (r) { 149 149 return r; 150 150 }
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 59 59 60 60 retry: 61 61 r = amdgpu_bo_create(adev, size, alignment, kernel, initial_domain, 62 - flags, NULL, NULL, &robj); 62 + flags, NULL, NULL, 0, &robj); 63 63 if (r) { 64 64 if (r != -ERESTARTSYS) { 65 65 if (initial_domain == AMDGPU_GEM_DOMAIN_VRAM) {
+9 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 247 247 r = amdgpu_bo_create(adev, size, align, true, domain, 248 248 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 249 249 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 250 - NULL, NULL, bo_ptr); 250 + NULL, NULL, 0, bo_ptr); 251 251 if (r) { 252 252 dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", 253 253 r); ··· 356 356 struct sg_table *sg, 357 357 struct ttm_placement *placement, 358 358 struct reservation_object *resv, 359 + uint64_t init_value, 359 360 struct amdgpu_bo **bo_ptr) 360 361 { 361 362 struct amdgpu_bo *bo; ··· 457 456 bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { 458 457 struct dma_fence *fence; 459 458 460 - r = amdgpu_fill_buffer(bo, 0, bo->tbo.resv, &fence); 459 + r = amdgpu_fill_buffer(bo, init_value, bo->tbo.resv, &fence); 461 460 if (unlikely(r)) 462 461 goto fail_unreserve; 463 462 ··· 509 508 AMDGPU_GEM_CREATE_CPU_GTT_USWC, 510 509 NULL, &placement, 511 510 bo->tbo.resv, 511 + 0, 512 512 &bo->shadow); 513 513 if (!r) { 514 514 bo->shadow->parent = amdgpu_bo_ref(bo); ··· 521 519 return r; 522 520 } 523 521 522 + /* init_value will only take effect when flags contains 523 + * AMDGPU_GEM_CREATE_VRAM_CLEARED. 524 + */ 524 525 int amdgpu_bo_create(struct amdgpu_device *adev, 525 526 unsigned long size, int byte_align, 526 527 bool kernel, u32 domain, u64 flags, 527 528 struct sg_table *sg, 528 529 struct reservation_object *resv, 530 + uint64_t init_value, 529 531 struct amdgpu_bo **bo_ptr) 530 532 { 531 533 struct ttm_placement placement = {0}; ··· 544 538 545 539 r = amdgpu_bo_create_restricted(adev, size, byte_align, kernel, 546 540 domain, flags, sg, &placement, 547 - resv, bo_ptr); 541 + resv, init_value, bo_ptr); 548 542 if (r) 549 543 return r; 550 544
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
··· 193 193 bool kernel, u32 domain, u64 flags, 194 194 struct sg_table *sg, 195 195 struct reservation_object *resv, 196 + uint64_t init_value, 196 197 struct amdgpu_bo **bo_ptr); 197 198 int amdgpu_bo_create_restricted(struct amdgpu_device *adev, 198 199 unsigned long size, int byte_align, ··· 201 200 struct sg_table *sg, 202 201 struct ttm_placement *placement, 203 202 struct reservation_object *resv, 203 + uint64_t init_value, 204 204 struct amdgpu_bo **bo_ptr); 205 205 int amdgpu_bo_create_reserved(struct amdgpu_device *adev, 206 206 unsigned long size, int align,
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
··· 69 69 70 70 ww_mutex_lock(&resv->lock, NULL); 71 71 ret = amdgpu_bo_create(adev, attach->dmabuf->size, PAGE_SIZE, false, 72 - AMDGPU_GEM_DOMAIN_GTT, 0, sg, resv, &bo); 72 + AMDGPU_GEM_DOMAIN_GTT, 0, sg, resv, 0, &bo); 73 73 ww_mutex_unlock(&resv->lock); 74 74 if (ret) 75 75 return ERR_PTR(ret);
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
··· 64 64 INIT_LIST_HEAD(&sa_manager->flist[i]); 65 65 66 66 r = amdgpu_bo_create(adev, size, align, true, domain, 67 - 0, NULL, NULL, &sa_manager->bo); 67 + 0, NULL, NULL, 0, &sa_manager->bo); 68 68 if (r) { 69 69 dev_err(adev->dev, "(%d) failed to allocate bo for manager\n", r); 70 70 return r;
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
··· 61 61 62 62 r = amdgpu_bo_create(adev, size, PAGE_SIZE, true, 63 63 AMDGPU_GEM_DOMAIN_VRAM, 0, 64 - NULL, NULL, &vram_obj); 64 + NULL, NULL, 0, &vram_obj); 65 65 if (r) { 66 66 DRM_ERROR("Failed to create VRAM object\n"); 67 67 goto out_cleanup; ··· 82 82 83 83 r = amdgpu_bo_create(adev, size, PAGE_SIZE, true, 84 84 AMDGPU_GEM_DOMAIN_GTT, 0, NULL, 85 - NULL, gtt_obj + i); 85 + NULL, 0, gtt_obj + i); 86 86 if (r) { 87 87 DRM_ERROR("Failed to create GTT object %d\n", i); 88 88 goto out_lclean;
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
··· 381 381 err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true, 382 382 amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, 383 383 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 384 - NULL, NULL, bo); 384 + NULL, NULL, 0, bo); 385 385 if (err) { 386 386 dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err); 387 387 goto failed;
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
··· 1051 1051 AMDGPU_GEM_DOMAIN_VRAM, 1052 1052 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 1053 1053 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 1054 - NULL, NULL, &bo); 1054 + NULL, NULL, 0, &bo); 1055 1055 if (r) 1056 1056 return r; 1057 1057 ··· 1101 1101 AMDGPU_GEM_DOMAIN_VRAM, 1102 1102 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 1103 1103 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 1104 - NULL, NULL, &bo); 1104 + NULL, NULL, 0, &bo); 1105 1105 if (r) 1106 1106 return r; 1107 1107
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
··· 359 359 AMDGPU_GEM_DOMAIN_VRAM, 360 360 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 361 361 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 362 - NULL, NULL, &bo); 362 + NULL, NULL, 0, &bo); 363 363 if (r) 364 364 return r; 365 365 ··· 411 411 AMDGPU_GEM_DOMAIN_VRAM, 412 412 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 413 413 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 414 - NULL, NULL, &bo); 414 + NULL, NULL, 0, &bo); 415 415 if (r) 416 416 return r; 417 417
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 333 333 AMDGPU_GPU_PAGE_SIZE, true, 334 334 AMDGPU_GEM_DOMAIN_VRAM, 335 335 flags, 336 - NULL, resv, &pt); 336 + NULL, resv, 0, &pt); 337 337 if (r) 338 338 return r; 339 339 ··· 2538 2538 r = amdgpu_bo_create(adev, amdgpu_vm_bo_size(adev, 0), align, true, 2539 2539 AMDGPU_GEM_DOMAIN_VRAM, 2540 2540 flags, 2541 - NULL, NULL, &vm->root.bo); 2541 + NULL, NULL, 0, &vm->root.bo); 2542 2542 if (r) 2543 2543 goto error_free_sched_entity; 2544 2544