summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-03-08 19:51:33 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-03-26 12:55:10 -0400
commitc11228d48be1825e1ec84afd38c6938504fa4100 (patch)
treeea8bb9c874ba14b7c06a4de11d6619f88e2a4104 /drivers/gpu/nvgpu/common/mm/lockless_allocator.c
parente0f2afe5eb43fb32490ccabd504879c3e3e54623 (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/lockless_allocator.c')
-rw-r--r--drivers/gpu/nvgpu/common/mm/lockless_allocator.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
index e3063a42..6fd9bc48 100644
--- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
@@ -20,6 +20,7 @@
20#include <linux/atomic.h> 20#include <linux/atomic.h>
21 21
22#include <nvgpu/allocator.h> 22#include <nvgpu/allocator.h>
23#include <nvgpu/kmem.h>
23 24
24#include "lockless_allocator_priv.h" 25#include "lockless_allocator_priv.h"
25 26
@@ -106,7 +107,7 @@ static void nvgpu_lockless_alloc_destroy(struct nvgpu_allocator *a)
106 nvgpu_fini_alloc_debug(a); 107 nvgpu_fini_alloc_debug(a);
107 108
108 vfree(pa->next); 109 vfree(pa->next);
109 kfree(pa); 110 nvgpu_kfree(nvgpu_alloc_to_gpu(a), pa);
110} 111}
111 112
112static void nvgpu_lockless_print_stats(struct nvgpu_allocator *a, 113static void nvgpu_lockless_print_stats(struct nvgpu_allocator *a,
@@ -154,7 +155,7 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a,
154 return -EINVAL; 155 return -EINVAL;
155 156
156 /* 157 /*
157 * Ensure we have space for atleast one node & there's no overflow. 158 * Ensure we have space for at least one node & there's no overflow.
158 * In order to control memory footprint, we require count < INT_MAX 159 * In order to control memory footprint, we require count < INT_MAX
159 */ 160 */
160 count = length; 161 count = length;
@@ -162,11 +163,11 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a,
162 if (!base || !count || count > INT_MAX) 163 if (!base || !count || count > INT_MAX)
163 return -EINVAL; 164 return -EINVAL;
164 165
165 a = kzalloc(sizeof(struct nvgpu_lockless_allocator), GFP_KERNEL); 166 a = nvgpu_kzalloc(g, sizeof(struct nvgpu_lockless_allocator));
166 if (!a) 167 if (!a)
167 return -ENOMEM; 168 return -ENOMEM;
168 169
169 err = __nvgpu_alloc_common_init(__a, name, a, false, &pool_ops); 170 err = __nvgpu_alloc_common_init(__a, g, name, a, false, &pool_ops);
170 if (err) 171 if (err)
171 goto fail; 172 goto fail;
172 173
@@ -202,6 +203,6 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a,
202 return 0; 203 return 0;
203 204
204fail: 205fail:
205 kfree(a); 206 nvgpu_kfree(g, a);
206 return err; 207 return err;
207} 208}