diff options
author | Alex Waterman <alexw@nvidia.com> | 2016-12-20 16:55:48 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-01-09 15:33:16 -0500 |
commit | 6df3992b60959d32c7113cb77e131a2547174f3a (patch) | |
tree | efbdc9e6ccd2330d5c469ca0783ecb0137da8fc4 /drivers/gpu/nvgpu/gk20a/page_allocator_priv.h | |
parent | e229514bece5a109cdbfe263f6329efe987e5939 (diff) |
gpu: nvgpu: Move allocators to common/mm/
Move the GPU allocators to common/mm/ since the allocators are common
code across all GPUs. Also rename the allocator code to move away from
gk20a_ prefixed structs and functions.
This caused one issue with the nvgpu_alloc() and nvgpu_free() functions.
There was a function for allocating either with kmalloc() or vmalloc()
depending on the size of the allocation. Those have now been renamed to
nvgpu_kalloc() and nvgpu_kfree().
Bug 1799159
Change-Id: Iddda92c013612bcb209847084ec85b8953002fa5
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1274400
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/page_allocator_priv.h')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/page_allocator_priv.h | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h b/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h deleted file mode 100644 index 7d7f43c2..00000000 --- a/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h +++ /dev/null | |||
@@ -1,164 +0,0 @@ | |||
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 PAGE_ALLOCATOR_PRIV_H | ||
18 | #define PAGE_ALLOCATOR_PRIV_H | ||
19 | |||
20 | #include <linux/list.h> | ||
21 | #include <linux/rbtree.h> | ||
22 | |||
23 | #include "gk20a_allocator.h" | ||
24 | |||
25 | struct gk20a_allocator; | ||
26 | |||
27 | /* | ||
28 | * This allocator implements the ability to do SLAB style allocation since the | ||
29 | * GPU has two page sizes available - 4k and 64k/128k. When the default | ||
30 | * granularity is the large page size (64k/128k) small allocations become very | ||
31 | * space inefficient. This is most notable in PDE and PTE blocks which are 4k | ||
32 | * in size. | ||
33 | * | ||
34 | * Thus we need the ability to suballocate in 64k pages. The way we do this for | ||
35 | * the GPU is as follows. We have several buckets for sub-64K allocations: | ||
36 | * | ||
37 | * B0 - 4k | ||
38 | * B1 - 8k | ||
39 | * B3 - 16k | ||
40 | * B4 - 32k | ||
41 | * B5 - 64k (for when large pages are 128k) | ||
42 | * | ||
43 | * When an allocation comes in for less than the large page size (from now on | ||
44 | * assumed to be 64k) the allocation is satisfied by one of the buckets. | ||
45 | */ | ||
46 | struct page_alloc_slab { | ||
47 | struct list_head empty; | ||
48 | struct list_head partial; | ||
49 | struct list_head full; | ||
50 | |||
51 | int nr_empty; | ||
52 | int nr_partial; | ||
53 | int nr_full; | ||
54 | |||
55 | u32 slab_size; | ||
56 | }; | ||
57 | |||
58 | enum slab_page_state { | ||
59 | SP_EMPTY, | ||
60 | SP_PARTIAL, | ||
61 | SP_FULL, | ||
62 | SP_NONE | ||
63 | }; | ||
64 | |||
65 | struct page_alloc_slab_page { | ||
66 | unsigned long bitmap; | ||
67 | u64 page_addr; | ||
68 | u32 slab_size; | ||
69 | |||
70 | u32 nr_objects; | ||
71 | u32 nr_objects_alloced; | ||
72 | |||
73 | enum slab_page_state state; | ||
74 | |||
75 | struct page_alloc_slab *owner; | ||
76 | struct list_head list_entry; | ||
77 | }; | ||
78 | |||
79 | struct page_alloc_chunk { | ||
80 | struct list_head list_entry; | ||
81 | |||
82 | u64 base; | ||
83 | u64 length; | ||
84 | }; | ||
85 | |||
86 | /* | ||
87 | * Struct to handle internal management of page allocation. It holds a list | ||
88 | * of the chunks of pages that make up the overall allocation - much like a | ||
89 | * scatter gather table. | ||
90 | */ | ||
91 | struct gk20a_page_alloc { | ||
92 | struct list_head alloc_chunks; | ||
93 | |||
94 | int nr_chunks; | ||
95 | u64 length; | ||
96 | |||
97 | /* | ||
98 | * Only useful for the RB tree - since the alloc may have discontiguous | ||
99 | * pages the base is essentially irrelevant except for the fact that it | ||
100 | * is guarenteed to be unique. | ||
101 | */ | ||
102 | u64 base; | ||
103 | |||
104 | struct rb_node tree_entry; | ||
105 | |||
106 | /* | ||
107 | * Set if this is a slab alloc. Points back to the slab page that owns | ||
108 | * this particular allocation. nr_chunks will always be 1 if this is | ||
109 | * set. | ||
110 | */ | ||
111 | struct page_alloc_slab_page *slab_page; | ||
112 | }; | ||
113 | |||
114 | struct gk20a_page_allocator { | ||
115 | struct gk20a_allocator *owner; /* Owner of this allocator. */ | ||
116 | |||
117 | /* | ||
118 | * Use a buddy allocator to manage the allocation of the underlying | ||
119 | * pages. This lets us abstract the discontiguous allocation handling | ||
120 | * out of the annoyingly complicated buddy allocator. | ||
121 | */ | ||
122 | struct gk20a_allocator source_allocator; | ||
123 | |||
124 | /* | ||
125 | * Page params. | ||
126 | */ | ||
127 | u64 base; | ||
128 | u64 length; | ||
129 | u64 page_size; | ||
130 | u32 page_shift; | ||
131 | |||
132 | struct rb_root allocs; /* Outstanding allocations. */ | ||
133 | |||
134 | struct page_alloc_slab *slabs; | ||
135 | int nr_slabs; | ||
136 | |||
137 | u64 flags; | ||
138 | |||
139 | /* | ||
140 | * Stat tracking. | ||
141 | */ | ||
142 | u64 nr_allocs; | ||
143 | u64 nr_frees; | ||
144 | u64 nr_fixed_allocs; | ||
145 | u64 nr_fixed_frees; | ||
146 | u64 nr_slab_allocs; | ||
147 | u64 nr_slab_frees; | ||
148 | u64 pages_alloced; | ||
149 | u64 pages_freed; | ||
150 | }; | ||
151 | |||
152 | static inline struct gk20a_page_allocator *page_allocator( | ||
153 | struct gk20a_allocator *a) | ||
154 | { | ||
155 | return (struct gk20a_page_allocator *)(a)->priv; | ||
156 | } | ||
157 | |||
158 | static inline struct gk20a_allocator *palloc_owner( | ||
159 | struct gk20a_page_allocator *a) | ||
160 | { | ||
161 | return a->owner; | ||
162 | } | ||
163 | |||
164 | #endif | ||