diff options
Diffstat (limited to 'include/gk20a/gr_ctx_gk20a.c')
| -rw-r--r-- | include/gk20a/gr_ctx_gk20a.c | 486 |
1 files changed, 0 insertions, 486 deletions
diff --git a/include/gk20a/gr_ctx_gk20a.c b/include/gk20a/gr_ctx_gk20a.c deleted file mode 100644 index 8b9ac32..0000000 --- a/include/gk20a/gr_ctx_gk20a.c +++ /dev/null | |||
| @@ -1,486 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * GK20A Graphics Context | ||
| 3 | * | ||
| 4 | * Copyright (c) 2011-2018, 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/log.h> | ||
| 28 | #include <nvgpu/firmware.h> | ||
| 29 | #include <nvgpu/enabled.h> | ||
| 30 | #include <nvgpu/io.h> | ||
| 31 | |||
| 32 | #include "gk20a.h" | ||
| 33 | #include "gr_ctx_gk20a.h" | ||
| 34 | |||
| 35 | #include <nvgpu/hw/gk20a/hw_gr_gk20a.h> | ||
| 36 | |||
| 37 | static int gr_gk20a_alloc_load_netlist_u32(struct gk20a *g, u32 *src, u32 len, | ||
| 38 | struct u32_list_gk20a *u32_list) | ||
| 39 | { | ||
| 40 | u32_list->count = (len + sizeof(u32) - 1) / sizeof(u32); | ||
| 41 | if (!alloc_u32_list_gk20a(g, u32_list)) { | ||
| 42 | return -ENOMEM; | ||
| 43 | } | ||
| 44 | |||
| 45 | memcpy(u32_list->l, src, len); | ||
| 46 | |||
| 47 | return 0; | ||
| 48 | } | ||
| 49 | |||
| 50 | static int gr_gk20a_alloc_load_netlist_av(struct gk20a *g, u32 *src, u32 len, | ||
| 51 | struct av_list_gk20a *av_list) | ||
| 52 | { | ||
| 53 | av_list->count = len / sizeof(struct av_gk20a); | ||
| 54 | if (!alloc_av_list_gk20a(g, av_list)) { | ||
| 55 | return -ENOMEM; | ||
| 56 | } | ||
| 57 | |||
| 58 | memcpy(av_list->l, src, len); | ||
| 59 | |||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | static int gr_gk20a_alloc_load_netlist_av64(struct gk20a *g, u32 *src, u32 len, | ||
| 64 | struct av64_list_gk20a *av64_list) | ||
| 65 | { | ||
| 66 | av64_list->count = len / sizeof(struct av64_gk20a); | ||
| 67 | if (!alloc_av64_list_gk20a(g, av64_list)) { | ||
| 68 | return -ENOMEM; | ||
| 69 | } | ||
| 70 | |||
| 71 | memcpy(av64_list->l, src, len); | ||
| 72 | |||
| 73 | return 0; | ||
| 74 | } | ||
| 75 | |||
| 76 | static int gr_gk20a_alloc_load_netlist_aiv(struct gk20a *g, u32 *src, u32 len, | ||
| 77 | struct aiv_list_gk20a *aiv_list) | ||
| 78 | { | ||
| 79 | aiv_list->count = len / sizeof(struct aiv_gk20a); | ||
| 80 | if (!alloc_aiv_list_gk20a(g, aiv_list)) { | ||
| 81 | return -ENOMEM; | ||
| 82 | } | ||
| 83 | |||
| 84 | memcpy(aiv_list->l, src, len); | ||
| 85 | |||
| 86 | return 0; | ||
| 87 | } | ||
| 88 | |||
| 89 | static int gr_gk20a_init_ctx_vars_fw(struct gk20a *g, struct gr_gk20a *gr) | ||
| 90 | { | ||
| 91 | struct nvgpu_firmware *netlist_fw; | ||
| 92 | struct netlist_image *netlist = NULL; | ||
| 93 | char name[MAX_NETLIST_NAME]; | ||
| 94 | u32 i, major_v = ~0, major_v_hw, netlist_num; | ||
| 95 | int net, max, err = -ENOENT; | ||
| 96 | |||
| 97 | nvgpu_log_fn(g, " "); | ||
| 98 | |||
| 99 | if (g->ops.gr_ctx.is_fw_defined()) { | ||
| 100 | net = NETLIST_FINAL; | ||
| 101 | max = 0; | ||
| 102 | major_v_hw = ~0; | ||
| 103 | g->gr.ctx_vars.dynamic = false; | ||
| 104 | } else { | ||
| 105 | net = NETLIST_SLOT_A; | ||
| 106 | max = MAX_NETLIST; | ||
| 107 | major_v_hw = gk20a_readl(g, | ||
| 108 | gr_fecs_ctx_state_store_major_rev_id_r()); | ||
| 109 | g->gr.ctx_vars.dynamic = true; | ||
| 110 | } | ||
| 111 | |||
| 112 | for (; net < max; net++) { | ||
| 113 | if (g->ops.gr_ctx.get_netlist_name(g, net, name) != 0) { | ||
| 114 | nvgpu_warn(g, "invalid netlist index %d", net); | ||
| 115 | continue; | ||
| 116 | } | ||
| 117 | |||
| 118 | netlist_fw = nvgpu_request_firmware(g, name, 0); | ||
| 119 | if (!netlist_fw) { | ||
| 120 | nvgpu_warn(g, "failed to load netlist %s", name); | ||
| 121 | continue; | ||
| 122 | } | ||
| 123 | |||
| 124 | netlist = (struct netlist_image *)netlist_fw->data; | ||
| 125 | |||
| 126 | for (i = 0; i < netlist->header.regions; i++) { | ||
| 127 | u32 *src = (u32 *)((u8 *)netlist + netlist->regions[i].data_offset); | ||
| 128 | u32 size = netlist->regions[i].data_size; | ||
| 129 | |||
| 130 | switch (netlist->regions[i].region_id) { | ||
| 131 | case NETLIST_REGIONID_FECS_UCODE_DATA: | ||
| 132 | nvgpu_log_info(g, "NETLIST_REGIONID_FECS_UCODE_DATA"); | ||
| 133 | err = gr_gk20a_alloc_load_netlist_u32(g, | ||
| 134 | src, size, &g->gr.ctx_vars.ucode.fecs.data); | ||
| 135 | if (err) { | ||
| 136 | goto clean_up; | ||
| 137 | } | ||
| 138 | break; | ||
| 139 | case NETLIST_REGIONID_FECS_UCODE_INST: | ||
| 140 | nvgpu_log_info(g, "NETLIST_REGIONID_FECS_UCODE_INST"); | ||
| 141 | err = gr_gk20a_alloc_load_netlist_u32(g, | ||
| 142 | src, size, &g->gr.ctx_vars.ucode.fecs.inst); | ||
| 143 | if (err) { | ||
| 144 | goto clean_up; | ||
| 145 | } | ||
| 146 | break; | ||
| 147 | case NETLIST_REGIONID_GPCCS_UCODE_DATA: | ||
| 148 | nvgpu_log_info(g, "NETLIST_REGIONID_GPCCS_UCODE_DATA"); | ||
| 149 | err = gr_gk20a_alloc_load_netlist_u32(g, | ||
| 150 | src, size, &g->gr.ctx_vars.ucode.gpccs.data); | ||
| 151 | if (err) { | ||
| 152 | goto clean_up; | ||
| 153 | } | ||
| 154 | break; | ||
| 155 | case NETLIST_REGIONID_GPCCS_UCODE_INST: | ||
| 156 | nvgpu_log_info(g, "NETLIST_REGIONID_GPCCS_UCODE_INST"); | ||
| 157 | err = gr_gk20a_alloc_load_netlist_u32(g, | ||
| 158 | src, size, &g->gr.ctx_vars.ucode.gpccs.inst); | ||
| 159 | if (err) { | ||
| 160 | goto clean_up; | ||
| 161 | } | ||
| 162 | break; | ||
| 163 | case NETLIST_REGIONID_SW_BUNDLE_INIT: | ||
| 164 | nvgpu_log_info(g, "NETLIST_REGIONID_SW_BUNDLE_INIT"); | ||
| 165 | err = gr_gk20a_alloc_load_netlist_av(g, | ||
| 166 | src, size, &g->gr.ctx_vars.sw_bundle_init); | ||
| 167 | if (err) { | ||
| 168 | goto clean_up; | ||
| 169 | } | ||
| 170 | break; | ||
| 171 | case NETLIST_REGIONID_SW_METHOD_INIT: | ||
| 172 | nvgpu_log_info(g, "NETLIST_REGIONID_SW_METHOD_INIT"); | ||
| 173 | err = gr_gk20a_alloc_load_netlist_av(g, | ||
| 174 | src, size, &g->gr.ctx_vars.sw_method_init); | ||
| 175 | if (err) { | ||
| 176 | goto clean_up; | ||
| 177 | } | ||
| 178 | break; | ||
| 179 | case NETLIST_REGIONID_SW_CTX_LOAD: | ||
| 180 | nvgpu_log_info(g, "NETLIST_REGIONID_SW_CTX_LOAD"); | ||
| 181 | err = gr_gk20a_alloc_load_netlist_aiv(g, | ||
| 182 | src, size, &g->gr.ctx_vars.sw_ctx_load); | ||
| 183 | if (err) { | ||
| 184 | goto clean_up; | ||
| 185 | } | ||
| 186 | break; | ||
| 187 | case NETLIST_REGIONID_SW_NON_CTX_LOAD: | ||
| 188 | nvgpu_log_info(g, "NETLIST_REGIONID_SW_NON_CTX_LOAD"); | ||
| 189 | err = gr_gk20a_alloc_load_netlist_av(g, | ||
| 190 | src, size, &g->gr.ctx_vars.sw_non_ctx_load); | ||
| 191 | if (err) { | ||
| 192 | goto clean_up; | ||
| 193 | } | ||
| 194 | break; | ||
| 195 | case NETLIST_REGIONID_SWVEIDBUNDLEINIT: | ||
| 196 | nvgpu_log_info(g, | ||
| 197 | "NETLIST_REGIONID_SW_VEID_BUNDLE_INIT"); | ||
| 198 | err = gr_gk20a_alloc_load_netlist_av(g, | ||
| 199 | src, size, | ||
| 200 | &g->gr.ctx_vars.sw_veid_bundle_init); | ||
| 201 | if (err) { | ||
| 202 | goto clean_up; | ||
| 203 | } | ||
| 204 | break; | ||
| 205 | case NETLIST_REGIONID_CTXREG_SYS: | ||
| 206 | nvgpu_log_info(g, "NETLIST_REGIONID_CTXREG_SYS"); | ||
| 207 | err = gr_gk20a_alloc_load_netlist_aiv(g, | ||
| 208 | src, size, &g->gr.ctx_vars.ctxsw_regs.sys); | ||
| 209 | if (err) { | ||
| 210 | goto clean_up; | ||
| 211 | } | ||
| 212 | break; | ||
| 213 | case NETLIST_REGIONID_CTXREG_GPC: | ||
| 214 | nvgpu_log_info(g, "NETLIST_REGIONID_CTXREG_GPC"); | ||
| 215 | err = gr_gk20a_alloc_load_netlist_aiv(g, | ||
