diff options
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/bitmap_allocator.c | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/buddy_allocator.c | 18 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/lockless_allocator.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/page_allocator.c | 7 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm.c | 46 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/allocator.h | 33 |
7 files changed, 54 insertions, 64 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c index 1edfda51..6b9db23c 100644 --- a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c | |||
@@ -174,7 +174,7 @@ static struct nvgpu_bitmap_alloc *find_alloc_metadata( | |||
174 | /* | 174 | /* |
175 | * Tree of alloc meta data stores the address of the alloc not the bit offset. | 175 | * Tree of alloc meta data stores the address of the alloc not the bit offset. |
176 | */ | 176 | */ |
177 | static int __nvgpu_bitmap_store_alloc(struct nvgpu_bitmap_allocator *a, | 177 | static int nvgpu_bitmap_store_alloc(struct nvgpu_bitmap_allocator *a, |
178 | u64 addr, u64 len) | 178 | u64 addr, u64 len) |
179 | { | 179 | { |
180 | struct nvgpu_bitmap_alloc *alloc = | 180 | struct nvgpu_bitmap_alloc *alloc = |
@@ -244,7 +244,7 @@ static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *na, u64 len) | |||
244 | * data it needs around to successfully free this allocation. | 244 | * data it needs around to successfully free this allocation. |
245 | */ | 245 | */ |
246 | if (!(a->flags & GPU_ALLOC_NO_ALLOC_PAGE) && | 246 | if (!(a->flags & GPU_ALLOC_NO_ALLOC_PAGE) && |
247 | __nvgpu_bitmap_store_alloc(a, addr, blks * a->blk_size)) { | 247 | nvgpu_bitmap_store_alloc(a, addr, blks * a->blk_size)) { |
248 | goto fail_reset_bitmap; | 248 | goto fail_reset_bitmap; |
249 | } | 249 | } |
250 | 250 | ||
@@ -401,7 +401,7 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | |||
401 | return -ENOMEM; | 401 | return -ENOMEM; |
402 | } | 402 | } |
403 | 403 | ||
404 | err = __nvgpu_alloc_common_init(na, g, name, a, false, &bitmap_ops); | 404 | err = nvgpu_alloc_common_init(na, g, name, a, false, &bitmap_ops); |
405 | if (err) { | 405 | if (err) { |
406 | goto fail; | 406 | goto fail; |
407 | } | 407 | } |
diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c index b29045ba..3b8d9939 100644 --- a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c | |||
@@ -1281,10 +1281,10 @@ static const struct nvgpu_allocator_ops buddy_ops = { | |||
1281 | * will try and pick a reasonable max order. | 1281 | * will try and pick a reasonable max order. |
1282 | * @flags: Extra flags necessary. See GPU_BALLOC_*. | 1282 | * @flags: Extra flags necessary. See GPU_BALLOC_*. |
1283 | */ | 1283 | */ |
1284 | int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | 1284 | int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, |
1285 | struct vm_gk20a *vm, const char *name, | 1285 | struct vm_gk20a *vm, const char *name, |
1286 | u64 base, u64 size, u64 blk_size, | 1286 | u64 base, u64 size, u64 blk_size, |
1287 | u64 max_order, u64 flags) | 1287 | u64 max_order, u64 flags) |
1288 | { | 1288 | { |
1289 | int err; | 1289 | int err; |
1290 | u64 pde_size; | 1290 | u64 pde_size; |
@@ -1312,7 +1312,7 @@ int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | |||
1312 | return -ENOMEM; | 1312 | return -ENOMEM; |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | err = __nvgpu_alloc_common_init(na, g, name, a, false, &buddy_ops); | 1315 | err = nvgpu_alloc_common_init(na, g, name, a, false, &buddy_ops); |
1316 | if (err) { | 1316 | if (err) { |
1317 | goto fail; | 1317 | goto fail; |
1318 | } | 1318 | } |
@@ -1396,11 +1396,3 @@ fail: | |||
1396 | nvgpu_kfree(g, a); | 1396 | nvgpu_kfree(g, a); |
1397 | return err; | 1397 | return err; |
1398 | } | 1398 | } |
1399 | |||
1400 | int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | ||
1401 | const char *name, u64 base, u64 size, | ||
1402 | u64 blk_size, u64 flags) | ||
1403 | { | ||
1404 | return __nvgpu_buddy_allocator_init(g, na, NULL, name, | ||
1405 | base, size, blk_size, 0, 0); | ||
1406 | } | ||
diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c index eec661bc..79bf4cd6 100644 --- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c | |||
@@ -187,7 +187,7 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | |||
187 | return -ENOMEM; | 187 | return -ENOMEM; |
188 | } | 188 | } |
189 | 189 | ||
190 | err = __nvgpu_alloc_common_init(na, g, name, a, false, &pool_ops); | 190 | err = nvgpu_alloc_common_init(na, g, name, a, false, &pool_ops); |
191 | if (err) { | 191 | if (err) { |
192 | goto fail; | 192 | goto fail; |
193 | } | 193 | } |
diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c index ec0aa888..bf624162 100644 --- a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c | |||
@@ -145,9 +145,9 @@ void nvgpu_alloc_print_stats(struct nvgpu_allocator *na, | |||
145 | /* | 145 | /* |
146 | * Handle the common init stuff for a nvgpu_allocator. | 146 | * Handle the common init stuff for a nvgpu_allocator. |
147 | */ | 147 | */ |
148 | int __nvgpu_alloc_common_init(struct nvgpu_allocator *a, struct gk20a *g, | 148 | int nvgpu_alloc_common_init(struct nvgpu_allocator *a, struct gk20a *g, |
149 | const char *name, void *priv, bool dbg, | 149 | const char *name, void *priv, bool dbg, |
150 | const struct nvgpu_allocator_ops *ops) | 150 | const struct nvgpu_allocator_ops *ops) |
151 | { | 151 | { |
152 | int err; | 152 | int err; |
153 | 153 | ||
diff --git a/drivers/gpu/nvgpu/common/mm/page_allocator.c b/drivers/gpu/nvgpu/common/mm/page_allocator.c index e559cb60..c8bc17c7 100644 --- a/drivers/gpu/nvgpu/common/mm/page_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/page_allocator.c | |||
@@ -1022,7 +1022,7 @@ int nvgpu_page_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | |||
1022 | return -ENOMEM; | 1022 | return -ENOMEM; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | err = __nvgpu_alloc_common_init(na, g, name, a, false, &page_ops); | 1025 | err = nvgpu_alloc_common_init(na, g, name, a, false, &page_ops); |
1026 | if (err) { | 1026 | if (err) { |
1027 | goto fail; | 1027 | goto fail; |
1028 | } | 1028 | } |
@@ -1053,8 +1053,9 @@ int nvgpu_page_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | |||
1053 | 1053 | ||
1054 | snprintf(buddy_name, sizeof(buddy_name), "%s-src", name); | 1054 | snprintf(buddy_name, sizeof(buddy_name), "%s-src", name); |
1055 | 1055 | ||
1056 | err = nvgpu_buddy_allocator_init(g, &a->source_allocator, buddy_name, | 1056 | err = nvgpu_buddy_allocator_init(g, &a->source_allocator, NULL, |
1057 | base, length, blk_size, 0); | 1057 | buddy_name, base, length, blk_size, |
1058 | 0ULL, 0ULL); | ||
1058 | if (err) { | 1059 | if (err) { |
1059 | goto fail; | 1060 | goto fail; |
1060 | } | 1061 | } |
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index 57d9afb5..b2b83767 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c | |||
@@ -420,14 +420,14 @@ int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
420 | */ | 420 | */ |
421 | if (user_vma_start < user_vma_limit) { | 421 | if (user_vma_start < user_vma_limit) { |
422 | snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s", name); | 422 | snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s", name); |
423 | err = __nvgpu_buddy_allocator_init(g, &vm->user, | 423 | err = nvgpu_buddy_allocator_init(g, &vm->user, |
424 | vm, alloc_name, | 424 | vm, alloc_name, |
425 | user_vma_start, | 425 | user_vma_start, |
426 | user_vma_limit - | 426 | user_vma_limit - |
427 | user_vma_start, | 427 | user_vma_start, |
428 | SZ_4K, | 428 | SZ_4K, |
429 | GPU_BALLOC_MAX_ORDER, | 429 | GPU_BALLOC_MAX_ORDER, |
430 | GPU_ALLOC_GVA_SPACE); | 430 | GPU_ALLOC_GVA_SPACE); |
431 | if (err) { | 431 | if (err) { |
432 | goto clean_up_page_tables; | 432 | goto clean_up_page_tables; |
433 | } | 433 | } |
@@ -446,14 +446,14 @@ int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
446 | */ | 446 | */ |
447 | if (user_lp_vma_start < user_lp_vma_limit) { | 447 | if (user_lp_vma_start < user_lp_vma_limit) { |
448 | snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s_lp", name); | 448 | snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s_lp", name); |
449 | err = __nvgpu_buddy_allocator_init(g, &vm->user_lp, | 449 | err = nvgpu_buddy_allocator_init(g, &vm->user_lp, |
450 | vm, alloc_name, | 450 | vm, alloc_name, |
451 | user_lp_vma_start, | 451 | user_lp_vma_start, |
452 | user_lp_vma_limit - | 452 | user_lp_vma_limit - |
453 | user_lp_vma_start, | 453 | user_lp_vma_start, |
454 | vm->big_page_size, | 454 | vm->big_page_size, |
455 | GPU_BALLOC_MAX_ORDER, | 455 | GPU_BALLOC_MAX_ORDER, |
456 | GPU_ALLOC_GVA_SPACE); | 456 | GPU_ALLOC_GVA_SPACE); |
457 | if (err) { | 457 | if (err) { |
458 | goto clean_up_allocators; | 458 | goto clean_up_allocators; |
459 | } | 459 | } |
@@ -463,13 +463,13 @@ int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
463 | * Kernel VMA. Must always exist for an address space. | 463 | * Kernel VMA. Must always exist for an address space. |
464 | */ | 464 | */ |
465 | snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s-sys", name); | 465 | snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s-sys", name); |
466 | err = __nvgpu_buddy_allocator_init(g, &vm->kernel, | 466 | err = nvgpu_buddy_allocator_init(g, &vm->kernel, |
467 | vm, alloc_name, | 467 | vm, alloc_name, |
468 | kernel_vma_start, | 468 | kernel_vma_start, |
469 | kernel_vma_limit - kernel_vma_start, | 469 | kernel_vma_limit - kernel_vma_start, |
470 | SZ_4K, | 470 | SZ_4K, |
471 | GPU_BALLOC_MAX_ORDER, | 471 | GPU_BALLOC_MAX_ORDER, |
472 | kernel_vma_flags); | 472 | kernel_vma_flags); |
473 | if (err) { | 473 | if (err) { |
474 | goto clean_up_allocators; | 474 | goto clean_up_allocators; |
475 | } | 475 | } |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/allocator.h b/drivers/gpu/nvgpu/include/nvgpu/allocator.h index 2d9b3d32..2bff0efd 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/allocator.h +++ b/drivers/gpu/nvgpu/include/nvgpu/allocator.h | |||
@@ -129,11 +129,11 @@ nvgpu_alloc_carveout_from_co_entry(struct nvgpu_list_node *node) | |||
129 | ((uintptr_t)node - offsetof(struct nvgpu_alloc_carveout, co_entry)); | 129 | ((uintptr_t)node - offsetof(struct nvgpu_alloc_carveout, co_entry)); |
130 | }; | 130 | }; |
131 | 131 | ||
132 | #define NVGPU_CARVEOUT(__name, __base, __length) \ | 132 | #define NVGPU_CARVEOUT(local_name, local_base, local_length) \ |
133 | { \ | 133 | { \ |
134 | .name = (__name), \ | 134 | .name = (local_name), \ |
135 | .base = (__base), \ | 135 | .base = (local_base), \ |
136 | .length = (__length) \ | 136 | .length = (local_length) \ |
137 | } | 137 | } |
138 | 138 | ||
139 | /* | 139 | /* |
@@ -207,13 +207,10 @@ static inline void alloc_unlock(struct nvgpu_allocator *a) | |||
207 | /* | 207 | /* |
208 | * Buddy allocator specific initializers. | 208 | * Buddy allocator specific initializers. |
209 | */ | 209 | */ |
210 | int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | 210 | int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, |
211 | struct vm_gk20a *vm, const char *name, | 211 | struct vm_gk20a *vm, const char *name, |
212 | u64 base, u64 size, u64 blk_size, | 212 | u64 base, u64 size, u64 blk_size, |
213 | u64 max_order, u64 flags); | 213 | u64 max_order, u64 flags); |
214 | int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, | ||
215 | const char *name, u64 base, u64 size, | ||
216 | u64 blk_size, u64 flags); | ||
217 | 214 | ||
218 | /* | 215 | /* |
219 | * Bitmap initializers. | 216 | * Bitmap initializers. |
@@ -282,9 +279,9 @@ void nvgpu_init_alloc_debug(struct gk20a *g, struct nvgpu_allocator *a); | |||
282 | void nvgpu_fini_alloc_debug(struct nvgpu_allocator *a); | 279 | void nvgpu_fini_alloc_debug(struct nvgpu_allocator *a); |
283 | #endif | 280 | #endif |
284 | 281 | ||
285 | int __nvgpu_alloc_common_init(struct nvgpu_allocator *a, struct gk20a *g, | 282 | int nvgpu_alloc_common_init(struct nvgpu_allocator *a, struct gk20a *g, |
286 | const char *name, void *priv, bool dbg, | 283 | const char *name, void *priv, bool dbg, |
287 | const struct nvgpu_allocator_ops *ops); | 284 | const struct nvgpu_allocator_ops *ops); |
288 | 285 | ||
289 | static inline void nvgpu_alloc_enable_dbg(struct nvgpu_allocator *a) | 286 | static inline void nvgpu_alloc_enable_dbg(struct nvgpu_allocator *a) |
290 | { | 287 | { |
@@ -309,7 +306,7 @@ static inline void nvgpu_alloc_disable_dbg(struct nvgpu_allocator *a) | |||
309 | } while (0) | 306 | } while (0) |
310 | #endif | 307 | #endif |
311 | 308 | ||
312 | #define __alloc_dbg(a, fmt, arg...) \ | 309 | #define do_alloc_dbg(a, fmt, arg...) \ |
313 | nvgpu_log((a)->g, gpu_dbg_alloc, "%25s " fmt, (a)->name, ##arg) | 310 | nvgpu_log((a)->g, gpu_dbg_alloc, "%25s " fmt, (a)->name, ##arg) |
314 | 311 | ||
315 | /* | 312 | /* |
@@ -325,10 +322,10 @@ static inline void nvgpu_alloc_disable_dbg(struct nvgpu_allocator *a) | |||
325 | #define alloc_dbg(a, fmt, arg...) \ | 322 | #define alloc_dbg(a, fmt, arg...) \ |
326 | do { \ | 323 | do { \ |
327 | if ((a)->debug) \ | 324 | if ((a)->debug) \ |
328 | __alloc_dbg((a), fmt, ##arg); \ | 325 | do_alloc_dbg((a), fmt, ##arg); \ |
329 | } while (0) | 326 | } while (0) |
330 | #else | 327 | #else |
331 | #define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg) | 328 | #define alloc_dbg(a, fmt, arg...) do_alloc_dbg(a, fmt, ##arg) |
332 | #endif | 329 | #endif |
333 | 330 | ||
334 | #endif /* NVGPU_ALLOCATOR_H */ | 331 | #endif /* NVGPU_ALLOCATOR_H */ |