diff options
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/bitmap_allocator.c | 98 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/lockless_allocator.c | 16 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c | 4 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/allocator.h | 4 |
4 files changed, 61 insertions, 61 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c index 6cdb8f3b..5316783d 100644 --- a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c | |||
@@ -61,10 +61,10 @@ static u64 nvgpu_bitmap_alloc_end(struct nvgpu_allocator *a) | |||
61 | /* | 61 | /* |
62 | * @page_size is ignored. | 62 | * @page_size is ignored. |
63 | */ | 63 | */ |
64 | static u64 nvgpu_bitmap_alloc_fixed(struct nvgpu_allocator *__a, | 64 | static u64 nvgpu_bitmap_alloc_fixed(struct nvgpu_allocator *na, |
65 | u64 base, u64 len, u32 page_size) | 65 | u64 base, u64 len, u32 page_size) |
66 | { | 66 | { |
67 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(__a); | 67 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(na); |
68 | u64 blks, offs, ret; | 68 | u64 blks, offs, ret; |
69 | 69 | ||
70 | /* Compute the bit offset and make sure it's aligned to a block. */ | 70 | /* Compute the bit offset and make sure it's aligned to a block. */ |
@@ -80,7 +80,7 @@ static u64 nvgpu_bitmap_alloc_fixed(struct nvgpu_allocator *__a, | |||
80 | blks++; | 80 | blks++; |
81 | } | 81 | } |
82 | 82 | ||
83 | alloc_lock(__a); | 83 | alloc_lock(na); |
84 | 84 | ||
85 | /* Check if the space requested is already occupied. */ | 85 | /* Check if the space requested is already occupied. */ |
86 | ret = bitmap_find_next_zero_area(a->bitmap, a->num_bits, offs, blks, 0); | 86 | ret = bitmap_find_next_zero_area(a->bitmap, a->num_bits, offs, blks, 0); |
@@ -92,15 +92,15 @@ static u64 nvgpu_bitmap_alloc_fixed(struct nvgpu_allocator *__a, | |||
92 | 92 | ||
93 | a->bytes_alloced += blks * a->blk_size; | 93 | a->bytes_alloced += blks * a->blk_size; |
94 | a->nr_fixed_allocs++; | 94 | a->nr_fixed_allocs++; |
95 | alloc_unlock(__a); | 95 | alloc_unlock(na); |
96 | 96 | ||
97 | alloc_dbg(__a, "Alloc-fixed 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", | 97 | alloc_dbg(na, "Alloc-fixed 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", |
98 | base, len, blks, blks); | 98 | base, len, blks, blks); |
99 | return base; | 99 | return base; |
100 | 100 | ||
101 | fail: | 101 | fail: |
102 | alloc_unlock(__a); | 102 | alloc_unlock(na); |
103 | alloc_dbg(__a, "Alloc-fixed failed! (0x%llx)", base); | 103 | alloc_dbg(na, "Alloc-fixed failed! (0x%llx)", base); |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
@@ -111,10 +111,10 @@ fail: | |||
111 | * Note: this function won't do much error checking. Thus you could really | 111 | * Note: this function won't do much error checking. Thus you could really |
112 | * confuse the allocator if you misuse this function. | 112 | * confuse the allocator if you misuse this function. |
113 | */ | 113 | */ |
114 | static void nvgpu_bitmap_free_fixed(struct nvgpu_allocator *__a, | 114 | static void nvgpu_bitmap_free_fixed(struct nvgpu_allocator *na, |
115 | u64 base, u64 len) | 115 | u64 base, u64 len) |
116 | { | 116 | { |
117 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(__a); | 117 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(na); |
118 | u64 blks, offs; | 118 | u64 blks, offs; |
119 | 119 | ||
120 | offs = base >> a->blk_shift; | 120 | offs = base >> a->blk_shift; |
@@ -129,12 +129,12 @@ static void nvgpu_bitmap_free_fixed(struct nvgpu_allocator *__a, | |||
129 | blks++; | 129 | blks++; |
130 | } | 130 | } |
131 | 131 | ||
132 | alloc_lock(__a); | 132 | alloc_lock(na); |
133 | bitmap_clear(a->bitmap, offs, blks); | 133 | bitmap_clear(a->bitmap, offs, blks); |
134 | a->bytes_freed += blks * a->blk_size; | 134 | a->bytes_freed += blks * a->blk_size; |
135 | alloc_unlock(__a); | 135 | alloc_unlock(na); |
136 | 136 | ||
137 | alloc_dbg(__a, "Free-fixed 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", | 137 | alloc_dbg(na, "Free-fixed 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", |
138 | base, len, blks, blks); | 138 | base, len, blks, blks); |
139 | } | 139 | } |
140 | 140 | ||
@@ -196,11 +196,11 @@ static int __nvgpu_bitmap_store_alloc(struct nvgpu_bitmap_allocator *a, | |||
196 | * @len is in bytes. This routine will figure out the right number of bits to | 196 | * @len is in bytes. This routine will figure out the right number of bits to |
197 | * actually allocate. The return is the address in bytes as well. | 197 | * actually allocate. The return is the address in bytes as well. |
198 | */ | 198 | */ |
199 | static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *__a, u64 len) | 199 | static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *na, u64 len) |
200 | { | 200 | { |
201 | u64 blks, addr; | 201 | u64 blks, addr; |
202 | unsigned long offs, adjusted_offs, limit; | 202 | unsigned long offs, adjusted_offs, limit; |
203 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(__a); | 203 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(na); |
204 | 204 | ||
205 | blks = len >> a->blk_shift; | 205 | blks = len >> a->blk_shift; |
206 | 206 | ||
@@ -208,7 +208,7 @@ static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *__a, u64 len) | |||
208 | blks++; | 208 | blks++; |
209 | } | 209 | } |
210 | 210 | ||
211 | alloc_lock(__a); | 211 | alloc_lock(na); |
212 | 212 | ||
213 | /* | 213 | /* |
214 | * First look from next_blk and onwards... | 214 | * First look from next_blk and onwards... |
@@ -248,12 +248,12 @@ static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *__a, u64 len) | |||
248 | goto fail_reset_bitmap; | 248 | goto fail_reset_bitmap; |
249 | } | 249 | } |
250 | 250 | ||
251 | alloc_dbg(__a, "Alloc 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", | 251 | alloc_dbg(na, "Alloc 0x%-10llx 0x%-5llx [bits=0x%llx (%llu)]", |
252 | addr, len, blks, blks); | 252 | addr, len, blks, blks); |
253 | 253 | ||
254 | a->nr_allocs++; | 254 | a->nr_allocs++; |
255 | a->bytes_alloced += (blks * a->blk_size); | 255 | a->bytes_alloced += (blks * a->blk_size); |
256 | alloc_unlock(__a); | 256 | alloc_unlock(na); |
257 | 257 | ||
258 | return addr; | 258 | return addr; |
259 | 259 | ||
@@ -261,18 +261,18 @@ fail_reset_bitmap: | |||
261 | bitmap_clear(a->bitmap, offs, blks); | 261 | bitmap_clear(a->bitmap, offs, blks); |
262 | fail: | 262 | fail: |
263 | a->next_blk = 0; | 263 | a->next_blk = 0; |
264 | alloc_unlock(__a); | 264 | alloc_unlock(na); |
265 | alloc_dbg(__a, "Alloc failed!"); | 265 | alloc_dbg(na, "Alloc failed!"); |
266 | return 0; | 266 | return 0; |
267 | } | 267 | } |
268 | 268 | ||
269 | static void nvgpu_bitmap_free(struct nvgpu_allocator *__a, u64 addr) | 269 | static void nvgpu_bitmap_free(struct nvgpu_allocator *na, u64 addr) |
270 | { | 270 | { |
271 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(__a); | 271 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(na); |
272 | struct nvgpu_bitmap_alloc *alloc = NULL; | 272 | struct nvgpu_bitmap_alloc *alloc = NULL; |
273 | u64 offs, adjusted_offs, blks; | 273 | u64 offs, adjusted_offs, blks; |
274 | 274 | ||
275 | alloc_lock(__a); | 275 | alloc_lock(na); |
276 | 276 | ||
277 | if (a->flags & GPU_ALLOC_NO_ALLOC_PAGE) { | 277 | if (a->flags & GPU_ALLOC_NO_ALLOC_PAGE) { |
278 | WARN(1, "Using wrong free for NO_ALLOC_PAGE bitmap allocator"); | 278 | WARN(1, "Using wrong free for NO_ALLOC_PAGE bitmap allocator"); |
@@ -294,7 +294,7 @@ static void nvgpu_bitmap_free(struct nvgpu_allocator *__a, u64 addr) | |||
294 | blks = alloc->length >> a->blk_shift; | 294 | blks = alloc->length >> a->blk_shift; |
295 | 295 | ||
296 | bitmap_clear(a->bitmap, offs, blks); | 296 | bitmap_clear(a->bitmap, offs, blks); |
297 | alloc_dbg(__a, "Free 0x%-10llx", addr); | 297 | alloc_dbg(na, "Free 0x%-10llx", addr); |
298 | 298 | ||
299 | a->bytes_freed += alloc->length; | 299 | a->bytes_freed += alloc->length; |
300 | 300 | ||
@@ -302,12 +302,12 @@ done: | |||
302 | if (a->meta_data_cache && alloc) { | 302 | if (a->meta_data_cache && alloc) { |
303 | nvgpu_kmem_cache_free(a->meta_data_cache, alloc); | 303 | nvgpu_kmem_cache_free(a->meta_data_cache, alloc); |
304 | } | 304 | } |
305 | alloc_unlock(__a); | 305 | alloc_unlock(na); |
306 | } | 306 | } |
307 | 307 | ||
308 | static void nvgpu_bitmap_alloc_destroy(struct nvgpu_allocator *__a) | 308 | static void nvgpu_bitmap_alloc_destroy(struct nvgpu_allocator *na) |
309 | { | 309 | { |
310 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(__a); | 310 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(na); |
311 | struct nvgpu_bitmap_alloc *alloc; | 311 | struct nvgpu_bitmap_alloc *alloc; |
312 | struct nvgpu_rbtree_node *node; | 312 | struct nvgpu_rbtree_node *node; |
313 | 313 | ||
@@ -325,28 +325,28 @@ static void nvgpu_bitmap_alloc_destroy(struct nvgpu_allocator *__a) | |||
325 | } | 325 | } |
326 | 326 | ||
327 | nvgpu_kmem_cache_destroy(a->meta_data_cache); | 327 | nvgpu_kmem_cache_destroy(a->meta_data_cache); |
328 | nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a->bitmap); | 328 | nvgpu_kfree(nvgpu_alloc_to_gpu(na), a->bitmap); |
329 | nvgpu_kfree(nvgpu_alloc_to_gpu(__a), a); | 329 | nvgpu_kfree(nvgpu_alloc_to_gpu(na), a); |
330 | } | 330 | } |
331 | 331 | ||
332 | #ifdef __KERNEL__ | 332 | #ifdef __KERNEL__ |
333 | static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *__a, | 333 | static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *na, |
334 | struct seq_file *s, int lock) | 334 | struct seq_file *s, int lock) |
335 | { | 335 | { |
336 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(__a); | 336 | struct nvgpu_bitmap_allocator *a = bitmap_allocator(na); |
337 | 337 | ||
338 | __alloc_pstat(s, __a, "Bitmap allocator params:"); | 338 | __alloc_pstat(s, na, "Bitmap allocator params:"); |
339 | __alloc_pstat(s, __a, " start = 0x%llx", a->base); | 339 | __alloc_pstat(s, na, " start = 0x%llx", a->base); |
340 | __alloc_pstat(s, __a, " end = 0x%llx", a->base + a->length); | 340 | __alloc_pstat(s, na, " end = 0x%llx", a->base + a->length); |
341 | __alloc_pstat(s, __a, " blks = 0x%llx", a->num_bits); | 341 | __alloc_pstat(s, na, " blks = 0x%llx", a->num_bits); |
342 | 342 | ||
343 | /* Actual stats. */ | 343 | /* Actual stats. */ |
344 | __alloc_pstat(s, __a, "Stats:"); | 344 | __alloc_pstat(s, na, "Stats:"); |
345 | __alloc_pstat(s, __a, " Number allocs = 0x%llx", a->nr_allocs); | 345 | __alloc_pstat(s, na, " Number allocs = 0x%llx", a->nr_allocs); |
346 | __alloc_pstat(s, __a, " Number fixed = 0x%llx", a->nr_fixed_allocs); | 346 | __alloc_pstat(s, na, " Number fixed = 0x%llx", a->nr_fixed_allocs); |
347 | __alloc_pstat(s, __a, " Bytes alloced = 0x%llx", a->bytes_alloced); | 347 | __alloc_pstat(s, na, " Bytes alloced = 0x%llx", a->bytes_alloced); |
348 | __alloc_pstat(s, __a, " Bytes freed = 0x%llx", a->bytes_freed); | 348 | __alloc_pstat(s, na, " Bytes freed = 0x%llx", a->bytes_freed); |
349 | __alloc_pstat(s, __a, " Outstanding = 0x%llx", | 349 | __alloc_pstat(s, na, " Outstanding = 0x%llx", |
350 | a->bytes_alloced - a->bytes_freed); | 350 | a->bytes_alloced - a->bytes_freed); |
351 | } | 351 | } |
352 | #endif | 352 | #endif |
@@ -371,7 +371,7 @@ static const struct nvgpu_allocator_ops bitmap_ops = { | |||
371 | }; | 371 | }; |
372 | 372 | ||
373 | 373 | ||
374 | int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | 374 | int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, |
375 | const char *name, u64 base, u64 length, | 375 | const char *name, u64 base, u64 length, |
376 | u64 blk_size, u64 flags) | 376 | u64 blk_size, u64 flags) |
377 | { | 377 | { |
@@ -401,7 +401,7 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
401 | return -ENOMEM; | 401 | return -ENOMEM; |
402 | } | 402 | } |
403 | 403 | ||
404 | err = __nvgpu_alloc_common_init(__a, 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 | } |
@@ -435,14 +435,14 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
435 | a->inited = true; | 435 | a->inited = true; |
436 | 436 | ||
437 | #ifdef CONFIG_DEBUG_FS | 437 | #ifdef CONFIG_DEBUG_FS |
438 | nvgpu_init_alloc_debug(g, __a); | 438 | nvgpu_init_alloc_debug(g, na); |
439 | #endif | 439 | #endif |
440 | alloc_dbg(__a, "New allocator: type bitmap"); | 440 | alloc_dbg(na, "New allocator: type bitmap"); |
441 | alloc_dbg(__a, " base 0x%llx", a->base); | 441 | alloc_dbg(na, " base 0x%llx", a->base); |
442 | alloc_dbg(__a, " bit_offs 0x%llx", a->bit_offs); | 442 | alloc_dbg(na, " bit_offs 0x%llx", a->bit_offs); |
443 | alloc_dbg(__a, " size 0x%llx", a->length); | 443 | alloc_dbg(na, " size 0x%llx", a->length); |
444 | alloc_dbg(__a, " blk_size 0x%llx", a->blk_size); | 444 | alloc_dbg(na, " blk_size 0x%llx", a->blk_size); |
445 | alloc_dbg(__a, " flags 0x%llx", a->flags); | 445 | alloc_dbg(na, " flags 0x%llx", a->flags); |
446 | 446 | ||
447 | return 0; | 447 | return 0; |
448 | 448 | ||
diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c index 7a5f67e9..eec661bc 100644 --- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c | |||
@@ -159,7 +159,7 @@ static const struct nvgpu_allocator_ops pool_ops = { | |||
159 | #endif | 159 | #endif |
160 | }; | 160 | }; |
161 | 161 | ||
162 | int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | 162 | int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, |
163 | const char *name, u64 base, u64 length, | 163 | const char *name, u64 base, u64 length, |
164 | u64 blk_size, u64 flags) | 164 | u64 blk_size, u64 flags) |
165 | { | 165 | { |
@@ -187,7 +187,7 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
187 | return -ENOMEM; | 187 | return -ENOMEM; |
188 | } | 188 | } |
189 | 189 | ||
190 | err = __nvgpu_alloc_common_init(__a, 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 | } |
@@ -216,13 +216,13 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
216 | a->inited = true; | 216 | a->inited = true; |
217 | 217 | ||
218 | #ifdef CONFIG_DEBUG_FS | 218 | #ifdef CONFIG_DEBUG_FS |
219 | nvgpu_init_alloc_debug(g, __a); | 219 | nvgpu_init_alloc_debug(g, na); |
220 | #endif | 220 | #endif |
221 | alloc_dbg(__a, "New allocator: type lockless"); | 221 | alloc_dbg(na, "New allocator: type lockless"); |
222 | alloc_dbg(__a, " base 0x%llx", a->base); | 222 | alloc_dbg(na, " base 0x%llx", a->base); |
223 | alloc_dbg(__a, " nodes %d", a->nr_nodes); | 223 | alloc_dbg(na, " nodes %d", a->nr_nodes); |
224 | alloc_dbg(__a, " blk_size 0x%llx", a->blk_size); | 224 | alloc_dbg(na, " blk_size 0x%llx", a->blk_size); |
225 | alloc_dbg(__a, " flags 0x%llx", a->flags); | 225 | alloc_dbg(na, " flags 0x%llx", a->flags); |
226 | 226 | ||
227 | return 0; | 227 | return 0; |
228 | 228 | ||
diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c index 9c487d6d..4057a599 100644 --- a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c | |||
@@ -130,10 +130,10 @@ void nvgpu_alloc_destroy(struct nvgpu_allocator *a) | |||
130 | } | 130 | } |
131 | 131 | ||
132 | #ifdef __KERNEL__ | 132 | #ifdef __KERNEL__ |
133 | void nvgpu_alloc_print_stats(struct nvgpu_allocator *__a, | 133 | void nvgpu_alloc_print_stats(struct nvgpu_allocator *na, |
134 | struct seq_file *s, int lock) | 134 | struct seq_file *s, int lock) |
135 | { | 135 | { |
136 | __a->ops->print_stats(__a, s, lock); | 136 | na->ops->print_stats(na, s, lock); |
137 | } | 137 | } |
138 | #endif | 138 | #endif |
139 | 139 | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/allocator.h b/drivers/gpu/nvgpu/include/nvgpu/allocator.h index 2ff7e950..d7a47d23 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/allocator.h +++ b/drivers/gpu/nvgpu/include/nvgpu/allocator.h | |||
@@ -216,7 +216,7 @@ int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *a, | |||
216 | /* | 216 | /* |
217 | * Bitmap initializers. | 217 | * Bitmap initializers. |
218 | */ | 218 | */ |
219 | int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *a, | 219 | int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, |
220 | const char *name, u64 base, u64 length, | 220 | const char *name, u64 base, u64 length, |
221 | u64 blk_size, u64 flags); | 221 | u64 blk_size, u64 flags); |
222 | 222 | ||
@@ -232,7 +232,7 @@ int nvgpu_page_allocator_init(struct gk20a *g, struct nvgpu_allocator *a, | |||
232 | * Note: This allocator can only allocate fixed-size structures of a | 232 | * Note: This allocator can only allocate fixed-size structures of a |
233 | * pre-defined size. | 233 | * pre-defined size. |
234 | */ | 234 | */ |
235 | int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *a, | 235 | int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, |
236 | const char *name, u64 base, u64 length, | 236 | const char *name, u64 base, u64 length, |
237 | u64 struct_size, u64 flags); | 237 | u64 struct_size, u64 flags); |
238 | 238 | ||