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/fifo_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/fifo_gk20a.c')
| -rw-r--r-- | include/gk20a/fifo_gk20a.c | 4649 |
1 files changed, 4649 insertions, 0 deletions
diff --git a/include/gk20a/fifo_gk20a.c b/include/gk20a/fifo_gk20a.c new file mode 100644 index 0000000..4477f7c --- /dev/null +++ b/include/gk20a/fifo_gk20a.c | |||
| @@ -0,0 +1,4649 @@ | |||
| 1 | /* | ||
| 2 | * GK20A Graphics FIFO (gr host) | ||
| 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 <trace/events/gk20a.h> | ||
| 26 | |||
| 27 | #include <nvgpu/mm.h> | ||
| 28 | #include <nvgpu/dma.h> | ||
| 29 | #include <nvgpu/timers.h> | ||
| 30 | #include <nvgpu/semaphore.h> | ||
| 31 | #include <nvgpu/enabled.h> | ||
| 32 | #include <nvgpu/kmem.h> | ||
| 33 | #include <nvgpu/log.h> | ||
| 34 | #include <nvgpu/soc.h> | ||
| 35 | #include <nvgpu/atomic.h> | ||
| 36 | #include <nvgpu/bug.h> | ||
| 37 | #include <nvgpu/log2.h> | ||
| 38 | #include <nvgpu/debug.h> | ||
| 39 | #include <nvgpu/nvhost.h> | ||
| 40 | #include <nvgpu/barrier.h> | ||
| 41 | #include <nvgpu/ctxsw_trace.h> | ||
| 42 | #include <nvgpu/error_notifier.h> | ||
| 43 | #include <nvgpu/ptimer.h> | ||
| 44 | #include <nvgpu/io.h> | ||
| 45 | #include <nvgpu/utils.h> | ||
| 46 | #include <nvgpu/channel.h> | ||
| 47 | #include <nvgpu/unit.h> | ||
| 48 | #include <nvgpu/power_features/power_features.h> | ||
| 49 | #include <nvgpu/power_features/cg.h> | ||
| 50 | |||
| 51 | #include "gk20a.h" | ||
| 52 | #include "mm_gk20a.h" | ||
| 53 | |||
| 54 | #include <nvgpu/hw/gk20a/hw_fifo_gk20a.h> | ||
| 55 | #include <nvgpu/hw/gk20a/hw_pbdma_gk20a.h> | ||
| 56 | #include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h> | ||
| 57 | #include <nvgpu/hw/gk20a/hw_ram_gk20a.h> | ||
| 58 | #include <nvgpu/hw/gk20a/hw_top_gk20a.h> | ||
| 59 | #include <nvgpu/hw/gk20a/hw_gr_gk20a.h> | ||
| 60 | |||
| 61 | #include <os/linux/os_linux.h> | ||
| 62 | |||
| 63 | #define FECS_METHOD_WFI_RESTORE 0x80000 | ||
| 64 | #define FECS_MAILBOX_0_ACK_RESTORE 0x4 | ||
| 65 | |||
| 66 | |||
| 67 | static u32 gk20a_fifo_engines_on_id(struct gk20a *g, u32 id, bool is_tsg); | ||
| 68 | |||
| 69 | static const char *const pbdma_intr_fault_type_desc[] = { | ||
| 70 | "MEMREQ timeout", "MEMACK_TIMEOUT", "MEMACK_EXTRA acks", | ||
| 71 | "MEMDAT_TIMEOUT", "MEMDAT_EXTRA acks", "MEMFLUSH noack", | ||
| 72 | "MEMOP noack", "LBCONNECT noack", "NONE - was LBREQ", | ||
| 73 | "LBACK_TIMEOUT", "LBACK_EXTRA acks", "LBDAT_TIMEOUT", | ||
| 74 | "LBDAT_EXTRA acks", "GPFIFO won't fit", "GPPTR invalid", | ||
| 75 | "GPENTRY invalid", "GPCRC mismatch", "PBPTR get>put", | ||
| 76 | "PBENTRY invld", "PBCRC mismatch", "NONE - was XBARC", | ||
| 77 | "METHOD invld", "METHODCRC mismat", "DEVICE sw method", | ||
| 78 | "[ENGINE]", "SEMAPHORE invlid", "ACQUIRE timeout", | ||
| 79 | "PRI forbidden", "ILLEGAL SYNCPT", "[NO_CTXSW_SEG]", | ||
| 80 | "PBSEG badsplit", "SIGNATURE bad" | ||
| 81 | }; | ||
| 82 | |||
| 83 | u32 gk20a_fifo_get_engine_ids(struct gk20a *g, | ||
| 84 | u32 engine_id[], u32 engine_id_sz, | ||
| 85 | u32 engine_enum) | ||
| 86 | { | ||
| 87 | struct fifo_gk20a *f = NULL; | ||
| 88 | u32 instance_cnt = 0; | ||
| 89 | u32 engine_id_idx; | ||
| 90 | u32 active_engine_id = 0; | ||
| 91 | struct fifo_engine_info_gk20a *info = NULL; | ||
| 92 | |||
| 93 | if (g && engine_id_sz && (engine_enum < ENGINE_INVAL_GK20A)) { | ||
| 94 | f = &g->fifo; | ||
| 95 | for (engine_id_idx = 0; engine_id_idx < f->num_engines; ++engine_id_idx) { | ||
| 96 | active_engine_id = f->active_engines_list[engine_id_idx]; | ||
| 97 | info = &f->engine_info[active_engine_id]; | ||
| 98 | |||
| 99 | if (info->engine_enum == engine_enum) { | ||
| 100 | if (instance_cnt < engine_id_sz) { | ||
| 101 | engine_id[instance_cnt] = active_engine_id; | ||
| 102 | ++instance_cnt; | ||
| 103 | } else { | ||
| 104 | nvgpu_log_info(g, "warning engine_id table sz is small %d", | ||
| 105 | engine_id_sz); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | } | ||
| 109 | } | ||
| 110 | return instance_cnt; | ||
| 111 | } | ||
| 112 | |||
| 113 | struct fifo_engine_info_gk20a *gk20a_fifo_get_engine_info(struct gk20a *g, u32 engine_id) | ||
| 114 | { | ||
| 115 | struct fifo_gk20a *f = NULL; | ||
| 116 | u32 engine_id_idx; | ||
| 117 | struct fifo_engine_info_gk20a *info = NULL; | ||
| 118 | |||
| 119 | if (!g) { | ||
| 120 | return info; | ||
| 121 | } | ||
| 122 | |||
| 123 | f = &g->fifo; | ||
| 124 | |||
| 125 | if (engine_id < f->max_engines) { | ||
| 126 | for (engine_id_idx = 0; engine_id_idx < f->num_engines; ++engine_id_idx) { | ||
| 127 | if (engine_id == f->active_engines_list[engine_id_idx]) { | ||
| 128 | info = &f->engine_info[engine_id]; | ||
| 129 | break; | ||
| 130 | } | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | if (!info) { | ||
| 135 | nvgpu_err(g, "engine_id is not in active list/invalid %d", engine_id); | ||
| 136 | } | ||
| 137 | |||
| 138 | return info; | ||
| 139 | } | ||
| 140 | |||
| 141 | bool gk20a_fifo_is_valid_engine_id(struct gk20a *g, u32 engine_id) | ||
| 142 | { | ||
| 143 | struct fifo_gk20a *f = NULL; | ||
| 144 | u32 engine_id_idx; | ||
| 145 | bool valid = false; | ||
| 146 | |||
| 147 | if (!g) { | ||
| 148 | return valid; | ||
| 149 | } | ||
| 150 | |||
| 151 | f = &g->fifo; | ||
| 152 | |||
| 153 | if (engine_id < f->max_engines) { | ||
| 154 | for (engine_id_idx = 0; engine_id_idx < f->num_engines; ++engine_id_idx) { | ||
| 155 | if (engine_id == f->active_engines_list[engine_id_idx]) { | ||
| 156 | valid = true; | ||
| 157 | break; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | if (!valid) { | ||
| 163 | nvgpu_err(g, "engine_id is not in active list/invalid %d", engine_id); | ||
| 164 | } | ||
| 165 | |||
| 166 | return valid; | ||
| 167 | } | ||
| 168 | |||
| 169 | u32 gk20a_fifo_get_gr_engine_id(struct gk20a *g) | ||
| 170 | { | ||
| 171 | u32 gr_engine_cnt = 0; | ||
| 172 | u32 gr_engine_id = FIFO_INVAL_ENGINE_ID; | ||
| 173 | |||
| 174 | /* Consider 1st available GR engine */ | ||
| 175 | gr_engine_cnt = gk20a_fifo_get_engine_ids(g, &gr_engine_id, | ||
| 176 | 1, ENGINE_GR_GK20A); | ||
| 177 | |||
| 178 | if (!gr_engine_cnt) { | ||
| 179 | nvgpu_err(g, "No GR engine available on this device!"); | ||
| 180 | } | ||
| 181 | |||
| 182 | return gr_engine_id; | ||
| 183 | } | ||
| 184 | |||
| 185 | u32 gk20a_fifo_get_all_ce_engine_reset_mask(struct gk20a *g) | ||
| 186 | { | ||
| 187 | u32 reset_mask = 0; | ||
| 188 | u32 engine_enum = ENGINE_INVAL_GK20A; | ||
| 189 | struct fifo_gk20a *f = NULL; | ||
| 190 | u32 engine_id_idx; | ||
| 191 | struct fifo_engine_info_gk20a *engine_info; | ||
| 192 | u32 active_engine_id = 0; | ||
| 193 | |||
| 194 | if (!g) { | ||
| 195 | return reset_mask; | ||
| 196 | } | ||
| 197 | |||
| 198 | f = &g->fifo; | ||
| 199 | |||
| 200 | for (engine_id_idx = 0; engine_id_idx < f->num_engines; ++engine_id_idx) { | ||
| 201 | active_engine_id = f->active_engines_list[engine_id_idx]; | ||
| 202 | engine_info = &f->engine_info[active_engine_id]; | ||
| 203 | engine_enum = engine_info->engine_enum; | ||
| 204 | |||
| 205 | if ((engine_enum == ENGINE_GRCE_GK20A) || | ||
| 206 | (engine_enum == ENGINE_ASYNC_CE_GK20A)) { | ||
| 207 | reset_mask |= engine_info->reset_mask; | ||
| 208 | } | ||
| 209 | } | ||
| 210 | |||
| 211 | return reset_mask; | ||
| 212 | } | ||
| 213 | |||
| 214 | u32 gk20a_fifo_get_fast_ce_runlist_id(struct gk20a *g) | ||
| 215 | { | ||
| 216 | u32 ce_runlist_id = gk20a_fifo_get_gr_runlist_id(g); | ||
