aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChunming Zhou <david1.zhou@amd.com>2018-04-16 06:27:50 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-05-15 14:43:28 -0400
commit3216c6b71d1e6a7dce2fd29c531e8c99c1b88c95 (patch)
tree5c073e948136a4be7a70c64da3d97968747d9aa1 /drivers/gpu
parenta906dbb1e20f5791d728c7d9e2366b8acb4f1bb2 (diff)
drm/amdgpu: use amdgpu_bo_param for amdgpu_bo_create v2
After that, we can easily add new parameter when need. v2: a) rebase. b) Initialize struct amdgpu_bo_param, future new member could only be used in some one case, but all member should have its own initial value. Signed-off-by: Chunming Zhou <david1.zhou@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> (v1) Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Cc: christian.koenig@amd.com Cc: Felix.Kuehling@amd.com Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c12
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c11
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c15
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c17
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c11
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c58
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.h6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c12
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_test.c18
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c15
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c26
11 files changed, 130 insertions, 71 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index 4d36203ffb11..887702c59488 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -217,13 +217,19 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
217{ 217{
218 struct amdgpu_device *adev = (struct amdgpu_device *)kgd; 218 struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
219 struct amdgpu_bo *bo = NULL; 219 struct amdgpu_bo *bo = NULL;
220 struct amdgpu_bo_param bp;
220 int r; 221 int r;
221 uint64_t gpu_addr_tmp = 0; 222 uint64_t gpu_addr_tmp = 0;
222 void *cpu_ptr_tmp = NULL; 223 void *cpu_ptr_tmp = NULL;
223 224
224 r = amdgpu_bo_create(adev, size, PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT, 225 memset(&bp, 0, sizeof(bp));
225 AMDGPU_GEM_CREATE_CPU_GTT_USWC, ttm_bo_type_kernel, 226 bp.size = size;
226 NULL, &bo); 227 bp.byte_align = PAGE_SIZE;
228 bp.domain = AMDGPU_GEM_DOMAIN_GTT;
229 bp.flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC;
230 bp.type = ttm_bo_type_kernel;
231 bp.resv = NULL;
232 r = amdgpu_bo_create(adev, &bp, &bo);
227 if (r) { 233 if (r) {
228 dev_err(adev->dev, 234 dev_err(adev->dev,
229 "failed to allocate BO for amdkfd (%d)\n", r); 235 "failed to allocate BO for amdkfd (%d)\n", r);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 1d6e1479da38..c1b0cdb401dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1004,6 +1004,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
1004 struct amdgpu_device *adev = get_amdgpu_device(kgd); 1004 struct amdgpu_device *adev = get_amdgpu_device(kgd);
1005 struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; 1005 struct amdgpu_vm *avm = (struct amdgpu_vm *)vm;
1006 struct amdgpu_bo *bo; 1006 struct amdgpu_bo *bo;
1007 struct amdgpu_bo_param bp;
1007 int byte_align; 1008 int byte_align;
1008 u32 alloc_domain; 1009 u32 alloc_domain;
1009 u64 alloc_flags; 1010 u64 alloc_flags;
@@ -1069,8 +1070,14 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
1069 pr_debug("\tcreate BO VA 0x%llx size 0x%llx domain %s\n", 1070 pr_debug("\tcreate BO VA 0x%llx size 0x%llx domain %s\n",
1070 va, size, domain_string(alloc_domain)); 1071 va, size, domain_string(alloc_domain));
1071 1072
1072 ret = amdgpu_bo_create(adev, size, byte_align, 1073 memset(&bp, 0, sizeof(bp));
1073 alloc_domain, alloc_flags, ttm_bo_type_device, NULL, &bo); 1074 bp.size = size;
1075 bp.byte_align = byte_align;
1076 bp.domain = alloc_domain;
1077 bp.flags = alloc_flags;
1078 bp.type = ttm_bo_type_device;
1079 bp.resv = NULL;
1080 ret = amdgpu_bo_create(adev, &bp, &bo);
1074 if (ret) { 1081 if (ret) {
1075 pr_debug("Failed to create BO on domain %s. ret %d\n", 1082 pr_debug("Failed to create BO on domain %s. ret %d\n",
1076 domain_string(alloc_domain), ret); 1083 domain_string(alloc_domain), ret);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
index 02b849be083b..19cfff31f2e1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
@@ -75,13 +75,20 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
75{ 75{
76 struct amdgpu_bo *dobj = NULL; 76 struct amdgpu_bo *dobj = NULL;
77 struct amdgpu_bo *sobj = NULL; 77 struct amdgpu_bo *sobj = NULL;
78 struct amdgpu_bo_param bp;
78 uint64_t saddr, daddr; 79 uint64_t saddr, daddr;
79 int r, n; 80 int r, n;
80 int time; 81 int time;
81 82
83 memset(&bp, 0, sizeof(bp));
84 bp.size = size;
85 bp.byte_align = PAGE_SIZE;
86 bp.domain = sdomain;
87 bp.flags = 0;
88 bp.type = ttm_bo_type_kernel;
89 bp.resv = NULL;
82 n = AMDGPU_BENCHMARK_ITERATIONS; 90 n = AMDGPU_BENCHMARK_ITERATIONS;
83 r = amdgpu_bo_create(adev, size, PAGE_SIZE,sdomain, 0, 91 r = amdgpu_bo_create(adev, &bp, &sobj);
84 ttm_bo_type_kernel, NULL, &sobj);
85 if (r) { 92 if (r) {
86 goto out_cleanup; 93 goto out_cleanup;
87 } 94 }
@@ -93,8 +100,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
93 if (r) { 100 if (r) {
94 goto out_cleanup; 101 goto out_cleanup;
95 } 102 }
96 r = amdgpu_bo_create(adev, size, PAGE_SIZE, ddomain, 0, 103 bp.domain = ddomain;
97 ttm_bo_type_kernel, NULL, &dobj); 104 r = amdgpu_bo_create(adev, &bp, &dobj);
98 if (r) { 105 if (r) {
99 goto out_cleanup; 106 goto out_cleanup;
100 } 107 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index cf0f186c6092..17d6b9fb6d77 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -113,12 +113,17 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
113 int r; 113 int r;
114 114
115 if (adev->gart.robj == NULL) { 115 if (adev->gart.robj == NULL) {
116 r = amdgpu_bo_create(adev, adev->gart.table_size, PAGE_SIZE, 116 struct amdgpu_bo_param bp;
117 AMDGPU_GEM_DOMAIN_VRAM, 117
118 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | 118 memset(&bp, 0, sizeof(bp));
119 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 119 bp.size = adev->gart.table_size;
120 ttm_bo_type_kernel, NULL, 120 bp.byte_align = PAGE_SIZE;
121 &adev->gart.robj); 121 bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
122 bp.flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
123 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
124 bp.type = ttm_bo_type_kernel;
125 bp.resv = NULL;
126 r = amdgpu_bo_create(adev, &bp, &adev->gart.robj);
122 if (r) { 127 if (r) {
123 return r; 128 return r;
124 } 129 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 46b9ea4e6103..1200c5ba37da 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -48,17 +48,24 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
48 struct drm_gem_object **obj) 48 struct drm_gem_object **obj)
49{ 49{
50 struct amdgpu_bo *bo; 50 struct amdgpu_bo *bo;
51 struct amdgpu_bo_param bp;
51 int r; 52 int r;
52 53
54 memset(&bp, 0, sizeof(bp));
53 *obj = NULL; 55 *obj = NULL;
54 /* At least align on page size */ 56 /* At least align on page size */
55 if (alignment < PAGE_SIZE) { 57 if (alignment < PAGE_SIZE) {
56 alignment = PAGE_SIZE; 58 alignment = PAGE_SIZE;
57 } 59 }
58 60
61 bp.size = size;
62 bp.byte_align = alignment;
63 bp.type = type;
64 bp.resv = resv;
59retry: 65retry:
60 r = amdgpu_bo_create(adev, size, alignment, initial_domain, 66 bp.flags = flags;
61 flags, type, resv, &bo); 67 bp.domain = initial_domain;
68 r = amdgpu_bo_create(adev, &bp, &bo);
62 if (r) { 69 if (r) {
63 if (r != -ERESTARTSYS) { 70 if (r != -ERESTARTSYS) {
64 if (flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) { 71 if (flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
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
498int amdgpu_bo_create(struct amdgpu_device *adev, unsigned long size, 506int 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)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 4bb6f0a8d799..e9a21d991e77 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -233,10 +233,8 @@ static inline bool amdgpu_bo_explicit_sync(struct amdgpu_bo *bo)
233 return bo->flags & AMDGPU_GEM_CREATE_EXPLICIT_SYNC; 233 return bo->flags & AMDGPU_GEM_CREATE_EXPLICIT_SYNC;
234} 234}
235 235
236int amdgpu_bo_create(struct amdgpu_device *adev, unsigned long size, 236int amdgpu_bo_create(struct amdgpu_device *adev,
237 int byte_align, u32 domain, 237 struct amdgpu_bo_param *bp,
238 u64 flags, enum ttm_bo_type type,
239 struct reservation_object *resv,
240 struct amdgpu_bo **bo_ptr); 238 struct amdgpu_bo **bo_ptr);
241int amdgpu_bo_create_reserved(struct amdgpu_device *adev, 239int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
242 unsigned long size, int align, 240 unsigned long size, int align,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
index 4b584cb75bf4..713417b6d15d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
@@ -102,12 +102,18 @@ amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
102 struct reservation_object *resv = attach->dmabuf->resv; 102 struct reservation_object *resv = attach->dmabuf->resv;
103 struct amdgpu_device *adev = dev->dev_private; 103 struct amdgpu_device *adev = dev->dev_private;
104 struct amdgpu_bo *bo; 104 struct amdgpu_bo *bo;
105 struct amdgpu_bo_param bp;
105 int ret; 106 int ret;
106 107
108 memset(&bp, 0, sizeof(bp));
109 bp.size = attach->dmabuf->size;
110 bp.byte_align = PAGE_SIZE;
111 bp.domain = AMDGPU_GEM_DOMAIN_CPU;
112 bp.flags = 0;
113 bp.type = ttm_bo_type_sg;
114 bp.resv = resv;
107 ww_mutex_lock(&resv->lock, NULL); 115 ww_mutex_lock(&resv->lock, NULL);
108 ret = amdgpu_bo_create(adev, attach->dmabuf->size, PAGE_SIZE, 116 ret = amdgpu_bo_create(adev, &bp, &bo);
109 AMDGPU_GEM_DOMAIN_CPU, 0, ttm_bo_type_sg,
110 resv, &bo);
111 if (ret) 117 if (ret)
112 goto error; 118 goto error;
113 119
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
index 2dbe87591f81..d167e8ab76d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
@@ -33,6 +33,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
33 struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; 33 struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;
34 struct amdgpu_bo *vram_obj = NULL; 34 struct amdgpu_bo *vram_obj = NULL;
35 struct amdgpu_bo **gtt_obj = NULL; 35 struct amdgpu_bo **gtt_obj = NULL;
36 struct amdgpu_bo_param bp;
36 uint64_t gart_addr, vram_addr; 37 uint64_t gart_addr, vram_addr;
37 unsigned n, size; 38 unsigned n, size;
38 int i, r; 39 int i, r;
@@ -58,9 +59,15 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
58 r = 1; 59 r = 1;
59 goto out_cleanup; 60 goto out_cleanup;
60 } 61 }
61 62 memset(&bp, 0, sizeof(bp));
62 r = amdgpu_bo_create(adev, size, PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, 0, 63 bp.size = size;
63 ttm_bo_type_kernel, NULL, &vram_obj); 64 bp.byte_align = PAGE_SIZE;
65 bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
66 bp.flags = 0;
67 bp.type = ttm_bo_type_kernel;
68 bp.resv = NULL;
69
70 r = amdgpu_bo_create(adev, &bp, &vram_obj);
64 if (r) { 71 if (r) {
65 DRM_ERROR("Failed to create VRAM object\n"); 72 DRM_ERROR("Failed to create VRAM object\n");
66 goto out_cleanup; 73 goto out_cleanup;
@@ -79,9 +86,8 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
79 void **vram_start, **vram_end; 86 void **vram_start, **vram_end;
80 struct dma_fence *fence = NULL; 87 struct dma_fence *fence = NULL;
81 88
82 r = amdgpu_bo_create(adev, size, PAGE_SIZE, 89 bp.domain = AMDGPU_GEM_DOMAIN_GTT;
83 AMDGPU_GEM_DOMAIN_GTT, 0, 90 r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
84 ttm_bo_type_kernel, NULL, gtt_obj + i);
85 if (r) { 91 if (r) {
86 DRM_ERROR("Failed to create GTT object %d\n", i); 92 DRM_ERROR("Failed to create GTT object %d\n", i);
87 goto out_lclean; 93 goto out_lclean;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 29efaac6e3ed..dfd22db13fb1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1316,6 +1316,7 @@ static void amdgpu_ttm_fw_reserve_vram_fini(struct amdgpu_device *adev)
1316static int amdgpu_ttm_fw_reserve_vram_init(struct amdgpu_device *adev) 1316static int amdgpu_ttm_fw_reserve_vram_init(struct amdgpu_device *adev)
1317{ 1317{
1318 struct ttm_operation_ctx ctx = { false, false }; 1318 struct ttm_operation_ctx ctx = { false, false };
1319 struct amdgpu_bo_param bp;
1319 int r = 0; 1320 int r = 0;
1320 int i; 1321 int i;
1321 u64 vram_size = adev->gmc.visible_vram_size; 1322 u64 vram_size = adev->gmc.visible_vram_size;
@@ -1323,17 +1324,21 @@ static int amdgpu_ttm_fw_reserve_vram_init(struct amdgpu_device *adev)
1323 u64 size = adev->fw_vram_usage.size; 1324 u64 size = adev->fw_vram_usage.size;
1324 struct amdgpu_bo *bo; 1325 struct amdgpu_bo *bo;
1325 1326
1327 memset(&bp, 0, sizeof(bp));
1328 bp.size = adev->fw_vram_usage.size;
1329 bp.byte_align = PAGE_SIZE;
1330 bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
1331 bp.flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
1332 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
1333 bp.type = ttm_bo_type_kernel;
1334 bp.resv = NULL;
1326 adev->fw_vram_usage.va = NULL; 1335 adev->fw_vram_usage.va = NULL;
1327 adev->fw_vram_usage.reserved_bo = NULL; 1336 adev->fw_vram_usage.reserved_bo = NULL;
1328 1337
1329 if (adev->fw_vram_usage.size > 0 && 1338 if (adev->fw_vram_usage.size > 0 &&
1330 adev->fw_vram_usage.size <= vram_size) { 1339 adev->fw_vram_usage.size <= vram_size) {
1331 1340
1332 r = amdgpu_bo_create(adev, adev->fw_vram_usage.size, PAGE_SIZE, 1341 r = amdgpu_bo_create(adev, &bp,
1333 AMDGPU_GEM_DOMAIN_VRAM,
1334 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
1335 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
1336 ttm_bo_type_kernel, NULL,
1337 &adev->fw_vram_usage.reserved_bo); 1342 &adev->fw_vram_usage.reserved_bo);
1338 if (r) 1343 if (r)
1339 goto error_create; 1344 goto error_create;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index f0fbc331aa30..9ec7c1041df2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -412,11 +412,16 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,
412 struct amdgpu_bo *pt; 412 struct amdgpu_bo *pt;
413 413
414 if (!entry->base.bo) { 414 if (!entry->base.bo) {
415 r = amdgpu_bo_create(adev, 415 struct amdgpu_bo_param bp;
416 amdgpu_vm_bo_size(adev, level), 416
417 AMDGPU_GPU_PAGE_SIZE, 417 memset(&bp, 0, sizeof(bp));
418 AMDGPU_GEM_DOMAIN_VRAM, flags, 418 bp.size = amdgpu_vm_bo_size(adev, level);
419 ttm_bo_type_kernel, resv, &pt); 419 bp.byte_align = AMDGPU_GPU_PAGE_SIZE;
420 bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
421 bp.flags = flags;
422 bp.type = ttm_bo_type_kernel;
423 bp.resv = resv;
424 r = amdgpu_bo_create(adev, &bp, &pt);
420 if (r) 425 if (r)
421 return r; 426 return r;
422 427
@@ -2368,6 +2373,7 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size,
2368int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, 2373int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
2369 int vm_context, unsigned int pasid) 2374 int vm_context, unsigned int pasid)
2370{ 2375{
2376 struct amdgpu_bo_param bp;
2371 const unsigned align = min(AMDGPU_VM_PTB_ALIGN_SIZE, 2377 const unsigned align = min(AMDGPU_VM_PTB_ALIGN_SIZE,
2372 AMDGPU_VM_PTE_COUNT(adev) * 8); 2378 AMDGPU_VM_PTE_COUNT(adev) * 8);
2373 unsigned ring_instance; 2379 unsigned ring_instance;
@@ -2422,8 +2428,14 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
2422 flags |= AMDGPU_GEM_CREATE_SHADOW; 2428 flags |= AMDGPU_GEM_CREATE_SHADOW;
2423 2429
2424 size = amdgpu_vm_bo_size(adev, adev->vm_manager.root_level); 2430 size = amdgpu_vm_bo_size(adev, adev->vm_manager.root_level);
2425 r = amdgpu_bo_create(adev, size, align, AMDGPU_GEM_DOMAIN_VRAM, flags, 2431 memset(&bp, 0, sizeof(bp));
2426 ttm_bo_type_kernel, NULL, &vm->root.base.bo); 2432 bp.size = size;
2433 bp.byte_align = align;
2434 bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
2435 bp.flags = flags;
2436 bp.type = ttm_bo_type_kernel;
2437 bp.resv = NULL;
2438 r = amdgpu_bo_create(adev, &bp, &vm->root.base.bo);
2427 if (r) 2439 if (r)
2428 goto error_free_sched_entity; 2440 goto error_free_sched_entity;
2429 2441