diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/pramin_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/pramin_gk20a.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c b/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c new file mode 100644 index 00000000..05d0473e --- /dev/null +++ b/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #include <nvgpu/page_allocator.h> | ||
24 | #include <nvgpu/bug.h> | ||
25 | |||
26 | #include "gk20a/gk20a.h" | ||
27 | #include "gk20a/mm_gk20a.h" | ||
28 | #include "gk20a/pramin_gk20a.h" | ||
29 | |||
30 | #include <nvgpu/hw/gk20a/hw_bus_gk20a.h> | ||
31 | #include <nvgpu/hw/gk20a/hw_pram_gk20a.h> | ||
32 | |||
33 | /* WARNING: returns pramin_window_lock taken, complement with pramin_exit() */ | ||
34 | u32 gk20a_pramin_enter(struct gk20a *g, struct nvgpu_mem *mem, | ||
35 | struct nvgpu_sgt *sgt, void *sgl, u32 w) | ||
36 | { | ||
37 | u64 bufbase = nvgpu_sgt_get_phys(sgt, sgl); | ||
38 | u64 addr = bufbase + w * sizeof(u32); | ||
39 | u32 hi = (u32)((addr & ~(u64)0xfffff) | ||
40 | >> bus_bar0_window_target_bar0_window_base_shift_v()); | ||
41 | u32 lo = (u32)(addr & 0xfffff); | ||
42 | u32 win = nvgpu_aperture_mask(g, mem, | ||
43 | bus_bar0_window_target_sys_mem_noncoherent_f(), | ||
44 | bus_bar0_window_target_vid_mem_f()) | | ||
45 | bus_bar0_window_base_f(hi); | ||
46 | |||
47 | gk20a_dbg(gpu_dbg_mem, | ||
48 | "0x%08x:%08x begin for %p,%p at [%llx,%llx] (sz %llx)", | ||
49 | hi, lo, mem, sgl, bufbase, | ||
50 | bufbase + nvgpu_sgt_get_phys(sgt, sgl), | ||
51 | nvgpu_sgt_get_length(sgt, sgl)); | ||
52 | |||
53 | WARN_ON(!bufbase); | ||
54 | |||
55 | nvgpu_spinlock_acquire(&g->mm.pramin_window_lock); | ||
56 | |||
57 | if (g->mm.pramin_window != win) { | ||
58 | gk20a_writel(g, bus_bar0_window_r(), win); | ||
59 | gk20a_readl(g, bus_bar0_window_r()); | ||
60 | g->mm.pramin_window = win; | ||
61 | } | ||
62 | |||
63 | return lo; | ||
64 | } | ||
65 | |||
66 | void gk20a_pramin_exit(struct gk20a *g, struct nvgpu_mem *mem, | ||
67 | void *sgl) | ||
68 | { | ||
69 | gk20a_dbg(gpu_dbg_mem, "end for %p,%p", mem, sgl); | ||
70 | |||
71 | nvgpu_spinlock_release(&g->mm.pramin_window_lock); | ||
72 | } | ||