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/page_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/page_allocator.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/page_allocator.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/page_allocator.c b/drivers/gpu/nvgpu/common/mm/page_allocator.c index 193decc9..7d2cedc9 100644 --- a/drivers/gpu/nvgpu/common/mm/page_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/page_allocator.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <nvgpu/allocator.h> | 22 | #include <nvgpu/allocator.h> |
23 | #include <nvgpu/page_allocator.h> | 23 | #include <nvgpu/page_allocator.h> |
24 | #include <nvgpu/kmem.h> | ||
24 | 25 | ||
25 | #include "buddy_allocator_priv.h" | 26 | #include "buddy_allocator_priv.h" |
26 | 27 | ||
@@ -760,7 +761,7 @@ static void nvgpu_page_allocator_destroy(struct nvgpu_allocator *__a) | |||
760 | struct nvgpu_page_allocator *a = page_allocator(__a); | 761 | struct nvgpu_page_allocator *a = page_allocator(__a); |
761 | 762 | ||
762 | alloc_lock(__a); | 763 | alloc_lock(__a); |
763 | kfree(a); | 764 | nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a); |
764 | __a->priv = NULL; | 765 | __a->priv = NULL; |
765 | alloc_unlock(__a); | 766 | alloc_unlock(__a); |
766 | } | 767 | } |
@@ -848,9 +849,9 @@ static int nvgpu_page_alloc_init_slabs(struct nvgpu_page_allocator *a) | |||
848 | size_t nr_slabs = ilog2(a->page_size >> 12); | 849 | size_t nr_slabs = ilog2(a->page_size >> 12); |
849 | unsigned int i; | 850 | unsigned int i; |
850 | 851 | ||
851 | a->slabs = kcalloc(nr_slabs, | 852 | a->slabs = nvgpu_kcalloc(nvgpu_alloc_to_gpu(a->owner), |
852 | sizeof(struct page_alloc_slab), | 853 | nr_slabs, |
853 | GFP_KERNEL); | 854 | sizeof(struct page_alloc_slab)); |
854 | if (!a->slabs) | 855 | if (!a->slabs) |
855 | return -ENOMEM; | 856 | return -ENOMEM; |
856 | a->nr_slabs = nr_slabs; | 857 | a->nr_slabs = nr_slabs; |
@@ -881,11 +882,11 @@ int nvgpu_page_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
881 | if (blk_size < SZ_4K) | 882 | if (blk_size < SZ_4K) |
882 | return -EINVAL; | 883 | return -EINVAL; |
883 | 884 | ||
884 | a = kzalloc(sizeof(struct nvgpu_page_allocator), GFP_KERNEL); | 885 | a = nvgpu_kzalloc(g, sizeof(struct nvgpu_page_allocator)); |
885 | if (!a) | 886 | if (!a) |
886 | return -ENOMEM; | 887 | return -ENOMEM; |
887 | 888 | ||
888 | err = __nvgpu_alloc_common_init(__a, name, a, false, &page_ops); | 889 | err = __nvgpu_alloc_common_init(__a, g, name, a, false, &page_ops); |
889 | if (err) | 890 | if (err) |
890 | goto fail; | 891 | goto fail; |
891 | 892 | ||
@@ -938,6 +939,6 @@ fail: | |||
938 | nvgpu_kmem_cache_destroy(a->chunk_cache); | 939 | nvgpu_kmem_cache_destroy(a->chunk_cache); |
939 | if (a->slab_page_cache) | 940 | if (a->slab_page_cache) |
940 | nvgpu_kmem_cache_destroy(a->slab_page_cache); | 941 | nvgpu_kmem_cache_destroy(a->slab_page_cache); |
941 | kfree(a); | 942 | nvgpu_kfree(g, a); |
942 | return err; | 943 | return err; |
943 | } | 944 | } |