diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
| commit | 01e6fac4d61fdd7fff5433942ec93fc2ea1e4df1 (patch) | |
| tree | 4ef34501728a087be24f4ba0af90f91486bf780b /include/gk20a/gk20a.c | |
| parent | 306a03d18b305e4e573be3b2931978fa10679eb9 (diff) | |
Include nvgpu headers
These are needed to build on NVIDIA's Jetson boards for the time
being. Only a couple structs are required, so it should be fairly
easy to remove this dependency at some point in the future.
Diffstat (limited to 'include/gk20a/gk20a.c')
| -rw-r--r-- | include/gk20a/gk20a.c | 590 |
1 files changed, 590 insertions, 0 deletions
diff --git a/include/gk20a/gk20a.c b/include/gk20a/gk20a.c new file mode 100644 index 0000000..c3068b7 --- /dev/null +++ b/include/gk20a/gk20a.c | |||
| @@ -0,0 +1,590 @@ | |||
| 1 | /* | ||
| 2 | * GK20A Graphics | ||
| 3 | * | ||
| 4 | * Copyright (c) 2011-2020, NVIDIA CORPORATION. All rights reserved. | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 7 | * copy of this software and associated documentation files (the "Software"), | ||
| 8 | * to deal in the Software without restriction, including without limitation | ||
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
| 11 | * Software is furnished to do so, subject to the following conditions: | ||
| 12 | * | ||
| 13 | * The above copyright notice and this permission notice shall be included in | ||
| 14 | * all copies or substantial portions of the Software. | ||
| 15 | * | ||
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| 22 | * DEALINGS IN THE SOFTWARE. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include <nvgpu/nvgpu_common.h> | ||
| 26 | #include <nvgpu/kmem.h> | ||
| 27 | #include <nvgpu/allocator.h> | ||
| 28 | #include <nvgpu/timers.h> | ||
| 29 | #include <nvgpu/soc.h> | ||
| 30 | #include <nvgpu/enabled.h> | ||
| 31 | #include <nvgpu/pmu.h> | ||
| 32 | #include <nvgpu/gmmu.h> | ||
| 33 | #include <nvgpu/ltc.h> | ||
| 34 | #include <nvgpu/vidmem.h> | ||
| 35 | #include <nvgpu/mm.h> | ||
| 36 | #include <nvgpu/ctxsw_trace.h> | ||
| 37 | #include <nvgpu/soc.h> | ||
| 38 | #include <nvgpu/clk_arb.h> | ||
| 39 | #include <nvgpu/therm.h> | ||
| 40 | #include <nvgpu/mc.h> | ||
| 41 | #include <nvgpu/channel_sync.h> | ||
| 42 | |||
| 43 | #include <trace/events/gk20a.h> | ||
| 44 | |||
| 45 | #include "gk20a.h" | ||
| 46 | |||
| 47 | #include "dbg_gpu_gk20a.h" | ||
| 48 | #include "pstate/pstate.h" | ||
| 49 | |||
| 50 | void __nvgpu_check_gpu_state(struct gk20a *g) | ||
| 51 | { | ||
| 52 | u32 boot_0 = 0xffffffff; | ||
| 53 | |||
| 54 | boot_0 = nvgpu_mc_boot_0(g, NULL, NULL, NULL); | ||
| 55 | if (boot_0 == 0xffffffff) { | ||
| 56 | nvgpu_err(g, "GPU has disappeared from bus!!"); | ||
| 57 | nvgpu_err(g, "Rebooting system!!"); | ||
| 58 | nvgpu_kernel_restart(NULL); | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | void __gk20a_warn_on_no_regs(void) | ||
| 63 | { | ||
| 64 | WARN_ONCE(1, "Attempted access to GPU regs after unmapping!"); | ||
| 65 | } | ||
| 66 | |||
| 67 | static void gk20a_mask_interrupts(struct gk20a *g) | ||
| 68 | { | ||
| 69 | if (g->ops.mc.intr_mask != NULL) { | ||
| 70 | g->ops.mc.intr_mask(g); | ||
| 71 | } | ||
| 72 | |||
| 73 | if (g->ops.mc.log_pending_intrs != NULL) { | ||
| 74 | g->ops.mc.log_pending_intrs(g); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | int gk20a_prepare_poweroff(struct gk20a *g) | ||
| 79 | { | ||
| 80 | int ret = 0; | ||
| 81 | |||
| 82 | nvgpu_log_fn(g, " "); | ||
| 83 | |||
| 84 | if (g->ops.fifo.channel_suspend) { | ||
| 85 | ret = g->ops.fifo.channel_suspend(g); | ||
| 86 | if (ret) { | ||
| 87 | return ret; | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | /* disable elpg before gr or fifo suspend */ | ||
| 92 | if (g->ops.pmu.is_pmu_supported(g)) { | ||
| 93 | ret |= nvgpu_pmu_destroy(g); | ||
| 94 | } | ||
| 95 | |||
| 96 | if (nvgpu_is_enabled(g, NVGPU_SUPPORT_SEC2_RTOS)) { | ||
| 97 | ret |= nvgpu_sec2_destroy(g); | ||
| 98 | } | ||
| 99 | |||
| 100 | ret |= gk20a_gr_suspend(g); | ||
| 101 | ret |= nvgpu_mm_suspend(g); | ||
| 102 | ret |= gk20a_fifo_suspend(g); | ||
| 103 | |||
| 104 | gk20a_ce_suspend(g); | ||
| 105 | |||
| 106 | /* Disable GPCPLL */ | ||
| 107 | if (g->ops.clk.suspend_clk_support) { | ||
| 108 | ret |= g->ops.clk.suspend_clk_support(g); | ||
| 109 | } | ||
| 110 | |||
| 111 | if (nvgpu_is_enabled(g, NVGPU_PMU_PSTATE)) { | ||
| 112 | gk20a_deinit_pstate_support(g); | ||
| 113 | } | ||
| 114 | |||
| 115 | gk20a_mask_interrupts(g); | ||
| 116 | |||
| 117 | g->power_on = false; | ||
| 118 | |||
| 119 | return ret; | ||
| 120 | } | ||
| 121 | |||
| 122 | int gk20a_finalize_poweron(struct gk20a *g) | ||
| 123 | { | ||
| 124 | int err = 0; | ||
| 125 | #if defined(CONFIG_TEGRA_GK20A_NVHOST) | ||
| 126 | u32 nr_pages; | ||
| 127 | #endif | ||
| 128 | |||
| 129 | u32 fuse_status; | ||
| 130 | |||
| 131 | nvgpu_log_fn(g, " "); | ||
| 132 | |||
| 133 | if (g->power_on) { | ||
| 134 | return 0; | ||
| 135 | } | ||
| 136 | |||
| 137 | g->power_on = true; | ||
| 138 | |||
| 139 | /* | ||
| 140 | * Before probing the GPU make sure the GPU's state is cleared. This is | ||
| 141 | * relevant for rebind operations. | ||
| 142 | */ | ||
| 143 | if (g->ops.xve.reset_gpu && !g->gpu_reset_done) { | ||
| 144 | g->ops.xve.reset_gpu(g); | ||
| 145 | g->gpu_reset_done = true; | ||
| 146 | } | ||
| 147 | |||
| 148 | if (g->ops.clock_gating.slcg_acb_load_gating_prod != NULL) { | ||
| 149 | g->ops.clock_gating.slcg_acb_load_gating_prod(g, true); | ||
| 150 | } | ||
| 151 | |||
| 152 | /* | ||
| 153 | * Do this early so any early VMs that get made are capable of mapping | ||
| 154 | * buffers. | ||
| 155 | */ | ||
| 156 | err = nvgpu_pd_cache_init(g); | ||
| 157 | if (err) { | ||
| 158 | return err; | ||
| 159 | } | ||
| 160 | |||
| 161 | /* init interface layer support for PMU falcon */ | ||
| 162 | err = nvgpu_flcn_sw_init(g, FALCON_ID_PMU); | ||
| 163 | if (err != 0) { | ||
| 164 | nvgpu_err(g, "failed to sw init FALCON_ID_PMU"); | ||
| 165 | goto done; | ||
| 166 | } | ||
| 167 | err = nvgpu_flcn_sw_init(g, FALCON_ID_SEC2); | ||
| 168 | if (err != 0) { | ||
| 169 | nvgpu_err(g, "failed to sw init FALCON_ID_SEC2"); | ||
| 170 | goto done; | ||
| 171 | } | ||
| 172 | err = nvgpu_flcn_sw_init(g, FALCON_ID_NVDEC); | ||
| 173 | if (err != 0) { | ||
| 174 | nvgpu_err(g, "failed to sw init FALCON_ID_NVDEC"); | ||
| 175 | goto done; | ||
| 176 | } | ||
| 177 | err = nvgpu_flcn_sw_init(g, FALCON_ID_GSPLITE); | ||
| 178 | if (err != 0) { | ||
| 179 | nvgpu_err(g, "failed to sw init FALCON_ID_GSPLITE"); | ||
| 180 | goto done; | ||
| 181 | } | ||
| 182 | |||
| 183 | if (g->ops.acr.acr_sw_init != NULL && | ||
| 184 | nvgpu_is_enabled(g, NVGPU_SEC_PRIVSECURITY)) { | ||
| 185 | g->ops.acr.acr_sw_init(g, &g->acr); | ||
| 186 | } | ||
| 187 | |||
| 188 | if (g->ops.bios.init) { | ||
| 189 | err = g->ops.bios.init(g); | ||
| 190 | } | ||
| 191 | if (err) { | ||
| 192 | goto done; | ||
| 193 | } | ||
| 194 | |||
| 195 | g->ops.bus.init_hw(g); | ||
| 196 | |||
| 197 | if (g->ops.clk.disable_slowboot) { | ||
| 198 | g->ops.clk.disable_slowboot(g); | ||
| 199 | } | ||
| 200 | |||
| 201 | g->ops.priv_ring.enable_priv_ring(g); | ||
| 202 | |||
| 203 | /* TBD: move this after graphics init in which blcg/slcg is enabled. | ||
| 204 | This function removes SlowdownOnBoot which applies 32x divider | ||
| 205 | on gpcpll bypass path. The purpose of slowdown is to save power | ||
| 206 | during boot but it also significantly slows down gk20a init on | ||
| 207 | simulation and emulation. We should remove SOB after graphics power | ||
| 208 | saving features (blcg/slcg) are enabled. For now, do it here. */ | ||
| 209 | if (g->ops.clk.init_clk_support) { | ||
| 210 | err = g->ops.clk.init_clk_support(g); | ||
| 211 | if (err) { | ||
| 212 | nvgpu_err(g, "failed to init gk20a clk"); | ||
| 213 | goto done; | ||
| 214 | } | ||
| 215 | } | ||
| 216 | |||
| 217 | if (nvgpu_is_enabled(g, NVGPU_SUPPORT_NVLINK)) { | ||
| 218 | err = g->ops.nvlink.init(g); | ||
| 219 | if (err) { | ||
| 220 | nvgpu_err(g, "failed to init nvlink"); | ||
| 221 | goto done; | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 225 | if (g->ops.fb.init_fbpa) { | ||
