Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | /* * Copyright 2019 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #include "gf100.h" #include "ctxgf100.h" #include <core/firmware.h> #include <subdev/gsp.h> #include <subdev/acr.h> #include <subdev/timer.h> #include <subdev/vfn.h> #include <nvfw/flcn.h> #include <nvif/class.h> static void ga102_gr_zbc_clear_color(struct gf100_gr *gr, int zbc) { struct nvkm_device *device = gr->base.engine.subdev.device; u32 invalid[] = { 0, 0, 0, 0 }, *color; if (gr->zbc_color[zbc].format) color = gr->zbc_color[zbc].l2; else color = invalid; nvkm_mask(device, 0x41bcb4, 0x0000001f, zbc); nvkm_wr32(device, 0x41bcec, color[0]); nvkm_wr32(device, 0x41bcf0, color[1]); nvkm_wr32(device, 0x41bcf4, color[2]); nvkm_wr32(device, 0x41bcf8, color[3]); } static const struct gf100_gr_func_zbc ga102_gr_zbc = { .clear_color = ga102_gr_zbc_clear_color, .clear_depth = gp100_gr_zbc_clear_depth, .stencil_get = gp102_gr_zbc_stencil_get, .clear_stencil = gp102_gr_zbc_clear_stencil, }; static void ga102_gr_gpccs_reset(struct gf100_gr *gr) { struct nvkm_device *device = gr->base.engine.subdev.device; nvkm_wr32(device, 0x41a610, 0x00000000); nvkm_msec(device, 1, NVKM_DELAY); nvkm_wr32(device, 0x41a610, 0x00000001); } static const struct nvkm_acr_lsf_func ga102_gr_gpccs_acr = { .flags = NVKM_ACR_LSF_FORCE_PRIV_LOAD, .bl_entry = 0x3400, .bld_size = sizeof(struct flcn_bl_dmem_desc_v2), .bld_write = gp108_gr_acr_bld_write, .bld_patch = gp108_gr_acr_bld_patch, }; static void ga102_gr_fecs_reset(struct gf100_gr *gr) { struct nvkm_device *device = gr->base.engine.subdev.device; nvkm_wr32(device, 0x409614, 0x00000010); nvkm_wr32(device, 0x41a614, 0x00000020); nvkm_usec(device, 10, NVKM_DELAY); nvkm_wr32(device, 0x409614, 0x00000110); nvkm_wr32(device, 0x41a614, 0x00000a20); nvkm_usec(device, 10, NVKM_DELAY); nvkm_rd32(device, 0x409614); nvkm_rd32(device, 0x41a614); } static const struct nvkm_acr_lsf_func ga102_gr_fecs_acr = { .bl_entry = 0x7e00, .bld_size = sizeof(struct flcn_bl_dmem_desc_v2), .bld_write = gp108_gr_acr_bld_write, .bld_patch = gp108_gr_acr_bld_patch, }; static void ga102_gr_init_rop_exceptions(struct gf100_gr *gr) { struct nvkm_device *device = gr->base.engine.subdev.device; nvkm_wr32(device, 0x41bcbc, 0x40000000); nvkm_wr32(device, 0x41bc38, 0x40000000); nvkm_wr32(device, 0x41ac94, nvkm_rd32(device, 0x502c94)); } static void ga102_gr_init_40a790(struct gf100_gr *gr) { nvkm_wr32(gr->base.engine.subdev.device, 0x40a790, 0xc0000000); } static void ga102_gr_init_gpc_mmu(struct gf100_gr *gr) { struct nvkm_device *device = gr->base.engine.subdev.device; nvkm_wr32(device, 0x418880, nvkm_rd32(device, 0x100c80) & 0xf8001fff); nvkm_wr32(device, 0x418894, 0x00000000); nvkm_wr32(device, 0x4188b4, nvkm_rd32(device, 0x100cc8)); nvkm_wr32(device, 0x4188b8, nvkm_rd32(device, 0x100ccc)); nvkm_wr32(device, 0x4188b0, nvkm_rd32(device, 0x100cc4)); } static struct nvkm_intr * ga102_gr_oneinit_intr(struct gf100_gr *gr, enum nvkm_intr_type *pvector) { struct nvkm_device *device = gr->base.engine.subdev.device; *pvector = nvkm_rd32(device, 0x400154) & 0x00000fff; return &device->vfn->intr; } static int ga102_gr_nonstall(struct gf100_gr *gr) { return nvkm_rd32(gr->base.engine.subdev.device, 0x400160) & 0x00000fff; } static const struct gf100_gr_func ga102_gr = { .nonstall = ga102_gr_nonstall, .oneinit_intr = ga102_gr_oneinit_intr, .oneinit_tiles = gm200_gr_oneinit_tiles, .oneinit_sm_id = gv100_gr_oneinit_sm_id, .init = gf100_gr_init, .init_419bd8 = gv100_gr_init_419bd8, .init_gpc_mmu = ga102_gr_init_gpc_mmu, .init_vsc_stream_master = gk104_gr_init_vsc_stream_master, .init_zcull = tu102_gr_init_zcull, .init_num_active_ltcs = gf100_gr_init_num_active_ltcs, .init_swdx_pes_mask = gp102_gr_init_swdx_pes_mask, .init_fs = tu102_gr_init_fs, .init_fecs_exceptions = tu102_gr_init_fecs_exceptions, .init_40a790 = ga102_gr_init_40a790, .init_ds_hww_esr_2 = gm200_gr_init_ds_hww_esr_2, .init_sked_hww_esr = gk104_gr_init_sked_hww_esr, .init_ppc_exceptions = gk104_gr_init_ppc_exceptions, .init_504430 = gv100_gr_init_504430, .init_shader_exceptions = gv100_gr_init_shader_exceptions, .init_rop_exceptions = ga102_gr_init_rop_exceptions, .init_4188a4 = gv100_gr_init_4188a4, .trap_mp = gv100_gr_trap_mp, .fecs.reset = ga102_gr_fecs_reset, .gpccs.reset = ga102_gr_gpccs_reset, .rops = gm200_gr_rops, .gpc_nr = 7, .tpc_nr = 6, .ppc_nr = 3, .grctx = &ga102_grctx, .zbc = &ga102_gr_zbc, .sclass = { { -1, -1, FERMI_TWOD_A }, { -1, -1, KEPLER_INLINE_TO_MEMORY_B }, { -1, -1, AMPERE_B, &gf100_fermi }, { -1, -1, AMPERE_COMPUTE_B }, {} } }; MODULE_FIRMWARE("nvidia/ga102/gr/fecs_bl.bin"); MODULE_FIRMWARE("nvidia/ga102/gr/fecs_sig.bin"); MODULE_FIRMWARE("nvidia/ga102/gr/gpccs_bl.bin"); MODULE_FIRMWARE("nvidia/ga102/gr/gpccs_sig.bin"); MODULE_FIRMWARE("nvidia/ga102/gr/NET_img.bin"); MODULE_FIRMWARE("nvidia/ga103/gr/fecs_bl.bin"); MODULE_FIRMWARE("nvidia/ga103/gr/fecs_sig.bin"); MODULE_FIRMWARE("nvidia/ga103/gr/gpccs_bl.bin"); MODULE_FIRMWARE("nvidia/ga103/gr/gpccs_sig.bin"); MODULE_FIRMWARE("nvidia/ga103/gr/NET_img.bin"); MODULE_FIRMWARE("nvidia/ga104/gr/fecs_bl.bin"); MODULE_FIRMWARE("nvidia/ga104/gr/fecs_sig.bin"); MODULE_FIRMWARE("nvidia/ga104/gr/gpccs_bl.bin"); MODULE_FIRMWARE("nvidia/ga104/gr/gpccs_sig.bin"); MODULE_FIRMWARE("nvidia/ga104/gr/NET_img.bin"); MODULE_FIRMWARE("nvidia/ga106/gr/fecs_bl.bin"); MODULE_FIRMWARE("nvidia/ga106/gr/fecs_sig.bin"); MODULE_FIRMWARE("nvidia/ga106/gr/gpccs_bl.bin"); MODULE_FIRMWARE("nvidia/ga106/gr/gpccs_sig.bin"); MODULE_FIRMWARE("nvidia/ga106/gr/NET_img.bin"); MODULE_FIRMWARE("nvidia/ga107/gr/fecs_bl.bin"); MODULE_FIRMWARE("nvidia/ga107/gr/fecs_sig.bin"); MODULE_FIRMWARE("nvidia/ga107/gr/gpccs_bl.bin"); MODULE_FIRMWARE("nvidia/ga107/gr/gpccs_sig.bin"); MODULE_FIRMWARE("nvidia/ga107/gr/NET_img.bin"); struct netlist_region { u32 region_id; u32 data_size; u32 data_offset; }; struct netlist_image_header { u32 version; u32 regions; }; struct netlist_image { struct netlist_image_header header; struct netlist_region regions[]; }; struct netlist_av64 { u32 addr; u32 data_hi; u32 data_lo; }; static int ga102_gr_av64_to_init(struct nvkm_blob *blob, struct gf100_gr_pack **ppack) { struct gf100_gr_init *init; struct gf100_gr_pack *pack; int nent; int i; nent = (blob->size / sizeof(struct netlist_av64)); pack = vzalloc((sizeof(*pack) * 2) + (sizeof(*init) * (nent + 1))); if (!pack) return -ENOMEM; init = (void *)(pack + 2); pack[0].init = init; pack[0].type = 64; for (i = 0; i < nent; i++) { struct gf100_gr_init *ent = &init[i]; struct netlist_av64 *av = &((struct netlist_av64 *)blob->data)[i]; ent->addr = av->addr; ent->data = ((u64)av->data_hi << 32) | av->data_lo; ent->count = 1; ent->pitch = 1; } *ppack = pack; return 0; } static int ga102_gr_load(struct gf100_gr *gr, int ver, const struct gf100_gr_fwif *fwif) { struct nvkm_subdev *subdev = &gr->base.engine.subdev; const struct firmware *fw; const struct netlist_image *net; const struct netlist_region *fecs_inst = NULL; const struct netlist_region *fecs_data = NULL; const struct netlist_region *gpccs_inst = NULL; const struct netlist_region *gpccs_data = NULL; int ret, i; ret = nvkm_firmware_get(subdev, "gr/NET_img", 0, &fw); if (ret) return ret; net = (const void *)fw->data; nvkm_debug(subdev, "netlist version %d, %d regions\n", net->header.version, net->header.regions); for (i = 0; i < net->header.regions; i++) { const struct netlist_region *reg = &net->regions[i]; struct nvkm_blob blob = { .data = (void *)fw->data + reg->data_offset, .size = reg->data_size, }; nvkm_debug(subdev, "\t%2d: %08x %08x\n", reg->region_id, reg->data_offset, reg->data_size); switch (reg->region_id) { case 0: fecs_data = reg; break; case 1: fecs_inst = reg; break; case 2: gpccs_data = reg; break; case 3: gpccs_inst = reg; break; case 4: gk20a_gr_av_to_init(&blob, &gr->bundle); break; case 5: gk20a_gr_aiv_to_init(&blob, &gr->sw_ctx); break; case 7: gk20a_gr_av_to_method(&blob, &gr->method); break; case 28: tu102_gr_av_to_init_veid(&blob, &gr->bundle_veid); break; case 34: ga102_gr_av64_to_init(&blob, &gr->bundle64); break; case 48: gk20a_gr_av_to_init(&blob, &gr->sw_nonctx1); break; case 49: gk20a_gr_av_to_init(&blob, &gr->sw_nonctx2); break; case 50: gk20a_gr_av_to_init(&blob, &gr->sw_nonctx3); break; case 51: gk20a_gr_av_to_init(&blob, &gr->sw_nonctx4); break; default: break; } } ret = nvkm_acr_lsfw_load_bl_sig_net(subdev, &gr->fecs.falcon, NVKM_ACR_LSF_FECS, "gr/fecs_", ver, fwif->fecs, fw->data + fecs_inst->data_offset, fecs_inst->data_size, fw->data + fecs_data->data_offset, fecs_data->data_size); if (ret) return ret; ret = nvkm_acr_lsfw_load_bl_sig_net(subdev, &gr->gpccs.falcon, NVKM_ACR_LSF_GPCCS, "gr/gpccs_", ver, fwif->gpccs, fw->data + gpccs_inst->data_offset, gpccs_inst->data_size, fw->data + gpccs_data->data_offset, gpccs_data->data_size); if (ret) return ret; gr->firmware = true; nvkm_firmware_put(fw); return 0; } static const struct gf100_gr_fwif ga102_gr_fwif[] = { { 0, ga102_gr_load, &ga102_gr, &ga102_gr_fecs_acr, &ga102_gr_gpccs_acr }, { -1, gm200_gr_nofw }, {} }; int ga102_gr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_gr **pgr) { if (nvkm_gsp_rm(device->gsp)) return r535_gr_new(&ga102_gr, device, type, inst, pgr); return gf100_gr_new_(ga102_gr_fwif, device, type, inst, pgr); } |