summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-10-06 14:30:29 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-10-24 18:16:49 -0400
commit2a285d0607a20694476399f5719e74dbc26fcd58 (patch)
treeef0246e3ca7b933ce3ea4c74061f61cc2e394b8b /drivers/gpu/nvgpu/gk20a/mm_gk20a.h
parent748331cbab1c7af26ab1fbae5ead2cdaff22806a (diff)
gpu: nvgpu: Cleanup generic MM code in gk20a/mm_gk20a.c
Move much of the remaining generic MM code to a new common location: common/mm/mm.c. Also add a corresponding <nvgpu/mm.h> header. This mostly consists of init and cleanup code to handle the common MM data structures like the VIDMEM code, address spaces for various engines, etc. A few more indepth changes were made as well. 1. alloc_inst_block() has been added to the MM HAL. This used to be defined directly in the gk20a code but it used a register. As a result, if this register hypothetically changes in the future, it would need to become a HAL anyway. This path preempts that and for now just defines all HALs to use the gk20a version. 2. Rename as much as possible: global functions are, for the most part, prepended with nvgpu (there are a few exceptions which I have yet to decide what to do with). Functions that are static are renamed to be as consistent with their functionality as possible since in some cases function effect and function name have diverged. JIRA NVGPU-30 Change-Id: Ic948f1ecc2f7976eba4bb7169a44b7226bb7c0b5 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1574499 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.h208
1 files changed, 4 insertions, 204 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
index 15876b10..434fc422 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h
@@ -35,11 +35,6 @@
35#include <nvgpu/list.h> 35#include <nvgpu/list.h>
36#include <nvgpu/rbtree.h> 36#include <nvgpu/rbtree.h>
37#include <nvgpu/kref.h> 37#include <nvgpu/kref.h>
38#include <nvgpu/atomic.h>
39#include <nvgpu/cond.h>
40#include <nvgpu/thread.h>
41
42struct nvgpu_pd_cache;
43 38
44#ifdef CONFIG_ARM64 39#ifdef CONFIG_ARM64
45#define outer_flush_range(a, b) 40#define outer_flush_range(a, b)
@@ -138,218 +133,23 @@ struct priv_cmd_entry {
138struct gk20a; 133struct gk20a;
139struct channel_gk20a; 134struct channel_gk20a;
140 135
141int gk20a_init_mm_support(struct gk20a *g);
142int gk20a_init_mm_setup_sw(struct gk20a *g);
143int gk20a_init_mm_setup_hw(struct gk20a *g);
144void gk20a_init_mm_ce_context(struct gk20a *g);
145
146int gk20a_mm_fb_flush(struct gk20a *g); 136int gk20a_mm_fb_flush(struct gk20a *g);
147void gk20a_mm_l2_flush(struct gk20a *g, bool invalidate); 137void gk20a_mm_l2_flush(struct gk20a *g, bool invalidate);
148void gk20a_mm_cbc_clean(struct gk20a *g); 138void gk20a_mm_cbc_clean(struct gk20a *g);
149void gk20a_mm_l2_invalidate(struct gk20a *g); 139void gk20a_mm_l2_invalidate(struct gk20a *g);
150 140
151#define FAULT_TYPE_NUM 2 /* replay and nonreplay faults */
152
153struct mmu_fault_info {
154 u64 inst_ptr;
155 u32 inst_aperture;
156 u64 fault_addr;
157 u32 fault_addr_aperture;
158 u32 timestamp_lo;
159 u32 timestamp_hi;
160 u32 mmu_engine_id;
161 u32 gpc_id;
162 u32 client_type;
163 u32 client_id;
164 u32 fault_type;
165 u32 access_type;
166 u32 protected_mode;
167 u32 replayable_fault;
168 u32 replay_fault_en;
169 u32 valid;
170 u32 faulted_pbdma;
171 u32 faulted_engine;
172 u32 faulted_subid;
173 u32 chid;
174 struct channel_gk20a *refch;
175 const char *client_type_desc;
176 const char *fault_type_desc;
177 const char *client_id_desc;
178};
179
180struct mm_gk20a {
181 struct gk20a *g;
182
183 /* GPU VA default sizes address spaces for channels */
184 struct {
185 u64 user_size; /* userspace-visible GPU VA region */
186 u64 kernel_size; /* kernel-only GPU VA region */
187 } channel;
188
189 struct {
190 u32 aperture_size;
191 struct vm_gk20a *vm;
192 struct nvgpu_mem inst_block;
193 } bar1;
194
195 struct {
196 u32 aperture_size;
197 struct vm_gk20a *vm;
198 struct nvgpu_mem inst_block;
199 } bar2;
200
201 struct {
202 u32 aperture_size;
203 struct vm_gk20a *vm;
204 struct nvgpu_mem inst_block;
205 } pmu;
206
207 struct {
208 /* using pmu vm currently */
209 struct nvgpu_mem inst_block;
210 } hwpm;
211
212 struct {
213 struct vm_gk20a *vm;
214 struct nvgpu_mem inst_block;
215 } perfbuf;
216
217 struct {
218 struct vm_gk20a *vm;
219 } cde;
220
221 struct {
222 struct vm_gk20a *vm;
223 } ce;
224
225 struct nvgpu_pd_cache *pd_cache;
226
227 struct nvgpu_mutex l2_op_lock;
228 struct nvgpu_mutex tlb_lock;
229 struct nvgpu_mutex priv_lock;
230
231 struct nvgpu_mem bar2_desc;
232
233#ifdef CONFIG_TEGRA_19x_GPU
234 struct nvgpu_mem hw_fault_buf[FAULT_TYPE_NUM];
235 unsigned int hw_fault_buf_status[FAULT_TYPE_NUM];
236 struct mmu_fault_info *fault_info[FAULT_TYPE_NUM];
237 struct nvgpu_mutex hub_isr_mutex;
238 u32 hub_intr_types;
239#endif
240 /*
241 * Separate function to cleanup the CE since it requires a channel to
242 * be closed which must happen before fifo cleanup.
243 */
244 void (*remove_ce_support)(struct mm_gk20a *mm);
245 void (*remove_support)(struct mm_gk20a *mm);
246 bool sw_ready;
247 int physical_bits;
248 bool use_full_comp_tag_line;
249 bool ltc_enabled_current;
250 bool ltc_enabled_target;
251 bool bypass_smmu;
252 bool disable_bigpage;
253 bool has_physical_mode;
254
255 struct nvgpu_mem sysmem_flush;
256
257 u32 pramin_window;
258 struct nvgpu_spinlock pramin_window_lock;
259 bool force_pramin; /* via debugfs */
260
261 struct {
262 size_t size;
263 u64 base;
264 size_t bootstrap_size;
265 u64 bootstrap_base;
266
267 struct nvgpu_allocator allocator;
268 struct nvgpu_allocator bootstrap_allocator;
269
270 u32 ce_ctx_id;
271 volatile bool cleared;
272 struct nvgpu_mutex first_clear_mutex;
273
274 struct nvgpu_list_node clear_list_head;
275 struct nvgpu_mutex clear_list_mutex;
276
277 struct nvgpu_cond clearing_thread_cond;
278 struct nvgpu_thread clearing_thread;
279 struct nvgpu_mutex clearing_thread_lock;
280 nvgpu_atomic_t pause_count;
281
282 nvgpu_atomic64_t bytes_pending;
283 } vidmem;
284};
285
286int gk20a_mm_init(struct mm_gk20a *mm);
287
288#define gk20a_from_mm(mm) ((mm)->g)
289#define gk20a_from_vm(vm) ((vm)->mm->g)
290
291#define dev_from_vm(vm) dev_from_gk20a(vm->mm->g) 141#define dev_from_vm(vm) dev_from_gk20a(vm->mm->g)
292 142
293#define DEFAULT_ALLOC_ALIGNMENT (4*1024) 143void gk20a_mm_ltc_isr(struct gk20a *g);
294
295static inline int bar1_aperture_size_mb_gk20a(void)
296{
297 return 16; /* 16MB is more than enough atm. */
298}
299
300/* The maximum GPU VA range supported */
301#define NV_GMMU_VA_RANGE 38
302
303/* The default userspace-visible GPU VA size */
304#define NV_MM_DEFAULT_USER_SIZE (1ULL << 37)
305
306/* The default kernel-reserved GPU VA size */
307#define NV_MM_DEFAULT_KERNEL_SIZE (1ULL << 32)
308
309/*
310 * When not using unified address spaces, the bottom 56GB of the space are used
311 * for small pages, and the remaining high memory is used for large pages.
312 */
313static inline u64 __nv_gmmu_va_small_page_limit(void)
314{
315 return ((u64)SZ_1G * 56);
316}
317
318enum nvgpu_flush_op {
319 NVGPU_FLUSH_DEFAULT,
320 NVGPU_FLUSH_FB,
321 NVGPU_FLUSH_L2_INV,
322 NVGPU_FLUSH_L2_FLUSH,
323 NVGPU_FLUSH_CBC_CLEAN,
324};
325 144
326enum gmmu_pgsz_gk20a __get_pte_size_fixed_map(struct vm_gk20a *vm, 145bool gk20a_mm_mmu_debug_mode_enabled(struct gk20a *g);
327 u64 base, u64 size);
328enum gmmu_pgsz_gk20a __get_pte_size(struct vm_gk20a *vm, u64 base, u64 size);
329 146
330#if 0 /*related to addr bits above, concern below TBD on which is accurate */ 147int gk20a_mm_mmu_vpr_info_fetch(struct gk20a *g);
331#define bar1_instance_block_shift_gk20a() (max_physaddr_bits_gk20a() -\
332 bus_bar1_block_ptr_s())
333#else
334#define bar1_instance_block_shift_gk20a() bus_bar1_block_ptr_shift_v()
335#endif
336 148
337int gk20a_alloc_inst_block(struct gk20a *g, struct nvgpu_mem *inst_block); 149int gk20a_alloc_inst_block(struct gk20a *g, struct nvgpu_mem *inst_block);
338void gk20a_free_inst_block(struct gk20a *g, struct nvgpu_mem *inst_block);
339void gk20a_init_inst_block(struct nvgpu_mem *inst_block, struct vm_gk20a *vm, 150void gk20a_init_inst_block(struct nvgpu_mem *inst_block, struct vm_gk20a *vm,
340 u32 big_page_size); 151 u32 big_page_size);
341u64 gk20a_mm_inst_block_addr(struct gk20a *g, struct nvgpu_mem *mem); 152int gk20a_init_mm_setup_hw(struct gk20a *g);
342
343void gk20a_mm_dump_vm(struct vm_gk20a *vm,
344 u64 va_begin, u64 va_end, char *label);
345
346int gk20a_mm_suspend(struct gk20a *g);
347
348void gk20a_mm_ltc_isr(struct gk20a *g);
349
350bool gk20a_mm_mmu_debug_mode_enabled(struct gk20a *g);
351
352int gk20a_mm_mmu_vpr_info_fetch(struct gk20a *g);
353 153
354u64 gk20a_locked_gmmu_map(struct vm_gk20a *vm, 154u64 gk20a_locked_gmmu_map(struct vm_gk20a *vm,
355 u64 map_offset, 155 u64 map_offset,