summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h b/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h
new file mode 100644
index 00000000..053a6425
--- /dev/null
+++ b/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h
@@ -0,0 +1,61 @@
1/*
2 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef BITMAP_ALLOCATOR_PRIV_H
18#define BITMAP_ALLOCATOR_PRIV_H
19
20#include <linux/rbtree.h>
21
22struct gk20a_allocator;
23
24struct gk20a_bitmap_allocator {
25 struct gk20a_allocator *owner;
26
27 u64 base; /* Base address of the space. */
28 u64 length; /* Length of the space. */
29 u64 blk_size; /* Size that corresponds to 1 bit. */
30 u64 blk_shift; /* Bit shift to divide by blk_size. */
31 u64 num_bits; /* Number of allocatable bits. */
32 u64 bit_offs; /* Offset of bitmap. */
33
34 unsigned long *bitmap; /* The actual bitmap! */
35 struct rb_root allocs; /* Tree of outstanding allocations. */
36
37 u64 flags;
38
39 bool inited;
40
41 /* Statistics */
42 u64 nr_allocs;
43 u64 nr_fixed_allocs;
44 u64 bytes_alloced;
45 u64 bytes_freed;
46};
47
48struct gk20a_bitmap_alloc {
49 u64 base;
50 u64 length;
51 struct rb_node alloc_entry; /* RB tree of allocations. */
52};
53
54static inline struct gk20a_bitmap_allocator *bitmap_allocator(
55 struct gk20a_allocator *a)
56{
57 return (struct gk20a_bitmap_allocator *)(a)->priv;
58}
59
60
61#endif