diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-03-08 19:51:33 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-03-26 12:55:10 -0400 |
commit | c11228d48be1825e1ec84afd38c6938504fa4100 (patch) | |
tree | ea8bb9c874ba14b7c06a4de11d6619f88e2a4104 /drivers/gpu/nvgpu/common/mm/bitmap_allocator.c | |
parent | e0f2afe5eb43fb32490ccabd504879c3e3e54623 (diff) |
gpu: nvgpu: Use new kmem API functions (common/*)
Use the new kmem API functions in common/* and common/mm/*.
Add a struct gk20a pointer to struct nvgpu_allocator in order
to store the gk20a pointer used for allocating memory.
Bug 1799159
Bug 1823380
Change-Id: I881ea9545e8a8f0b75d77a1e35dd1812e0bb654e
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1318315
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/bitmap_allocator.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/bitmap_allocator.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c index 6fc508d6..6e3bad6f 100644 --- a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
20 | 20 | ||
21 | #include <nvgpu/allocator.h> | 21 | #include <nvgpu/allocator.h> |
22 | #include <nvgpu/kmem.h> | ||
22 | 23 | ||
23 | #include "bitmap_allocator_priv.h" | 24 | #include "bitmap_allocator_priv.h" |
24 | 25 | ||
@@ -248,12 +249,11 @@ static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *__a, u64 len) | |||
248 | 249 | ||
249 | /* | 250 | /* |
250 | * Only do meta-data storage if we are allowed to allocate storage for | 251 | * Only do meta-data storage if we are allowed to allocate storage for |
251 | * that meta-data. The issue with using kmalloc() and friends is that | 252 | * that meta-data. The issue with using malloc and friends is that |
252 | * in latency and success critical paths an alloc_page() call can either | 253 | * in latency and success critical paths an alloc_page() call can either |
253 | * sleep for potentially a long time or, assuming GFP_ATOMIC, fail. | 254 | * sleep for potentially a long time or fail. Since we might not want |
254 | * Since we might not want either of these possibilities assume that the | 255 | * either of these possibilities assume that the caller will keep what |
255 | * caller will keep what data it needs around to successfully free this | 256 | * data it needs around to successfully free this allocation. |
256 | * allocation. | ||
257 | */ | 257 | */ |
258 | if (!(a->flags & GPU_ALLOC_NO_ALLOC_PAGE) && | 258 | if (!(a->flags & GPU_ALLOC_NO_ALLOC_PAGE) && |
259 | __nvgpu_bitmap_store_alloc(a, addr, blks * a->blk_size)) | 259 | __nvgpu_bitmap_store_alloc(a, addr, blks * a->blk_size)) |
@@ -332,8 +332,8 @@ static void nvgpu_bitmap_alloc_destroy(struct nvgpu_allocator *__a) | |||
332 | } | 332 | } |
333 | 333 | ||
334 | nvgpu_kmem_cache_destroy(a->meta_data_cache); | 334 | nvgpu_kmem_cache_destroy(a->meta_data_cache); |
335 | kfree(a->bitmap); | 335 | nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a->bitmap); |
336 | kfree(a); | 336 | nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a); |
337 | } | 337 | } |
338 | 338 | ||
339 | static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *__a, | 339 | static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *__a, |
@@ -397,11 +397,11 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
397 | length -= blk_size; | 397 | length -= blk_size; |
398 | } | 398 | } |
399 | 399 | ||
400 | a = kzalloc(sizeof(struct nvgpu_bitmap_allocator), GFP_KERNEL); | 400 | a = nvgpu_kzalloc(g, sizeof(struct nvgpu_bitmap_allocator)); |
401 | if (!a) | 401 | if (!a) |
402 | return -ENOMEM; | 402 | return -ENOMEM; |
403 | 403 | ||
404 | err = __nvgpu_alloc_common_init(__a, name, a, false, &bitmap_ops); | 404 | err = __nvgpu_alloc_common_init(__a, g, name, a, false, &bitmap_ops); |
405 | if (err) | 405 | if (err) |
406 | goto fail; | 406 | goto fail; |
407 | 407 | ||
@@ -422,8 +422,8 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
422 | a->bit_offs = a->base >> a->blk_shift; | 422 | a->bit_offs = a->base >> a->blk_shift; |
423 | a->flags = flags; | 423 | a->flags = flags; |
424 | 424 | ||
425 | a->bitmap = kcalloc(BITS_TO_LONGS(a->num_bits), sizeof(*a->bitmap), | 425 | a->bitmap = nvgpu_kcalloc(g, BITS_TO_LONGS(a->num_bits), |
426 | GFP_KERNEL); | 426 | sizeof(*a->bitmap)); |
427 | if (!a->bitmap) { | 427 | if (!a->bitmap) { |
428 | err = -ENOMEM; | 428 | err = -ENOMEM; |
429 | goto fail; | 429 | goto fail; |
@@ -445,6 +445,6 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
445 | fail: | 445 | fail: |
446 | if (a->meta_data_cache) | 446 | if (a->meta_data_cache) |
447 | nvgpu_kmem_cache_destroy(a->meta_data_cache); | 447 | nvgpu_kmem_cache_destroy(a->meta_data_cache); |
448 | kfree(a); | 448 | nvgpu_kfree(g, a); |
449 | return err; | 449 | return err; |
450 | } | 450 | } |