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/buddy_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/buddy_allocator.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/buddy_allocator.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c index 6f4c670a..246be974 100644 --- a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | 19 | ||
20 | #include <nvgpu/allocator.h> | 20 | #include <nvgpu/allocator.h> |
21 | #include <nvgpu/kmem.h> | ||
21 | 22 | ||
22 | #include "gk20a/mm_gk20a.h" | 23 | #include "gk20a/mm_gk20a.h" |
23 | #include "gk20a/platform_gk20a.h" | 24 | #include "gk20a/platform_gk20a.h" |
@@ -304,7 +305,7 @@ static void nvgpu_buddy_allocator_destroy(struct nvgpu_allocator *__a) | |||
304 | } | 305 | } |
305 | 306 | ||
306 | nvgpu_kmem_cache_destroy(a->buddy_cache); | 307 | nvgpu_kmem_cache_destroy(a->buddy_cache); |
307 | kfree(a); | 308 | nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a); |
308 | 309 | ||
309 | alloc_unlock(__a); | 310 | alloc_unlock(__a); |
310 | } | 311 | } |
@@ -809,7 +810,7 @@ static void __balloc_do_free_fixed(struct nvgpu_buddy_allocator *a, | |||
809 | balloc_coalesce(a, bud); | 810 | balloc_coalesce(a, bud); |
810 | } | 811 | } |
811 | 812 | ||
812 | kfree(falloc); | 813 | nvgpu_kfree(nvgpu_alloc_to_gpu(a->owner), falloc); |
813 | } | 814 | } |
814 | 815 | ||
815 | /* | 816 | /* |
@@ -893,7 +894,7 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, | |||
893 | goto fail; | 894 | goto fail; |
894 | } | 895 | } |
895 | 896 | ||
896 | falloc = kmalloc(sizeof(*falloc), GFP_KERNEL); | 897 | falloc = nvgpu_kmalloc(nvgpu_alloc_to_gpu(__a), sizeof(*falloc)); |
897 | if (!falloc) | 898 | if (!falloc) |
898 | goto fail; | 899 | goto fail; |
899 | 900 | ||
@@ -932,7 +933,7 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, | |||
932 | fail_unlock: | 933 | fail_unlock: |
933 | alloc_unlock(__a); | 934 | alloc_unlock(__a); |
934 | fail: | 935 | fail: |
935 | kfree(falloc); | 936 | nvgpu_kfree(nvgpu_alloc_to_gpu(__a), falloc); |
936 | nvgpu_alloc_trace_func_done(); | 937 | nvgpu_alloc_trace_func_done(); |
937 | return 0; | 938 | return 0; |
938 | } | 939 | } |
@@ -1261,11 +1262,11 @@ int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
1261 | if (flags & GPU_ALLOC_GVA_SPACE && !vm) | 1262 | if (flags & GPU_ALLOC_GVA_SPACE && !vm) |
1262 | return -EINVAL; | 1263 | return -EINVAL; |
1263 | 1264 | ||
1264 | a = kzalloc(sizeof(struct nvgpu_buddy_allocator), GFP_KERNEL); | 1265 | a = nvgpu_kzalloc(g, sizeof(struct nvgpu_buddy_allocator)); |
1265 | if (!a) | 1266 | if (!a) |
1266 | return -ENOMEM; | 1267 | return -ENOMEM; |
1267 | 1268 | ||
1268 | err = __nvgpu_alloc_common_init(__a, name, a, false, &buddy_ops); | 1269 | err = __nvgpu_alloc_common_init(__a, g, name, a, false, &buddy_ops); |
1269 | if (err) | 1270 | if (err) |
1270 | goto fail; | 1271 | goto fail; |
1271 | 1272 | ||
@@ -1339,7 +1340,7 @@ int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
1339 | fail: | 1340 | fail: |
1340 | if (a->buddy_cache) | 1341 | if (a->buddy_cache) |
1341 | nvgpu_kmem_cache_destroy(a->buddy_cache); | 1342 | nvgpu_kmem_cache_destroy(a->buddy_cache); |
1342 | kfree(a); | 1343 | nvgpu_kfree(g, a); |
1343 | return err; | 1344 | return err; |
1344 | } | 1345 | } |
1345 | 1346 | ||