1 /* 2 * Copyright 2019 Red Hat Inc. 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 #include "gf100.h" 23 #include "ctxgf100.h" 24 25 #include <nvif/class.h> 26 27 static void 28 tu102_gr_init_fecs_exceptions(struct gf100_gr *gr) 29 { 30 nvkm_wr32(gr->base.engine.subdev.device, 0x409c24, 0x006f0002); 31 } 32 33 static void 34 tu102_gr_init_fs(struct gf100_gr *gr) 35 { 36 struct nvkm_device *device = gr->base.engine.subdev.device; 37 int sm; 38 39 gp100_grctx_generate_smid_config(gr); 40 gk104_grctx_generate_gpc_tpc_nr(gr); 41 42 for (sm = 0; sm < gr->sm_nr; sm++) { 43 nvkm_wr32(device, GPC_UNIT(gr->sm[sm].gpc, 0x0c10 + 44 gr->sm[sm].tpc * 4), sm); 45 } 46 47 gm200_grctx_generate_dist_skip_table(gr); 48 gf100_gr_init_num_tpc_per_gpc(gr, true, true); 49 } 50 51 static void 52 tu102_gr_init_zcull(struct gf100_gr *gr) 53 { 54 struct nvkm_device *device = gr->base.engine.subdev.device; 55 const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total); 56 const u8 tile_nr = gr->func->gpc_nr * gr->func->tpc_nr; 57 u8 bank[GPC_MAX] = {}, gpc, i, j; 58 u32 data; 59 60 for (i = 0; i < tile_nr; i += 8) { 61 for (data = 0, j = 0; j < 8 && i + j < gr->tpc_total; j++) { 62 data |= bank[gr->tile[i + j]] << (j * 4); 63 bank[gr->tile[i + j]]++; 64 } 65 nvkm_wr32(device, GPC_BCAST(0x0980 + ((i / 8) * 4)), data); 66 } 67 68 for (gpc = 0; gpc < gr->gpc_nr; gpc++) { 69 nvkm_wr32(device, GPC_UNIT(gpc, 0x0914), 70 gr->screen_tile_row_offset << 8 | gr->tpc_nr[gpc]); 71 nvkm_wr32(device, GPC_UNIT(gpc, 0x0910), 0x00040000 | 72 gr->tpc_total); 73 nvkm_wr32(device, GPC_UNIT(gpc, 0x0918), magicgpc918); 74 } 75 76 nvkm_wr32(device, GPC_BCAST(0x3fd4), magicgpc918); 77 } 78 79 static void 80 tu102_gr_init_gpc_mmu(struct gf100_gr *gr) 81 { 82 struct nvkm_device *device = gr->base.engine.subdev.device; 83 84 nvkm_wr32(device, 0x418880, nvkm_rd32(device, 0x100c80) & 0xf8001fff); 85 nvkm_wr32(device, 0x418890, 0x00000000); 86 nvkm_wr32(device, 0x418894, 0x00000000); 87 88 nvkm_wr32(device, 0x4188b4, nvkm_rd32(device, 0x100cc8)); 89 nvkm_wr32(device, 0x4188b8, nvkm_rd32(device, 0x100ccc)); 90 nvkm_wr32(device, 0x4188b0, nvkm_rd32(device, 0x100cc4)); 91 } 92 93 static const struct gf100_gr_func 94 tu102_gr = { 95 .oneinit_tiles = gm200_gr_oneinit_tiles, 96 .oneinit_sm_id = gm200_gr_oneinit_sm_id, 97 .init = gf100_gr_init, 98 .init_419bd8 = gv100_gr_init_419bd8, 99 .init_gpc_mmu = tu102_gr_init_gpc_mmu, 100 .init_vsc_stream_master = gk104_gr_init_vsc_stream_master, 101 .init_zcull = tu102_gr_init_zcull, 102 .init_num_active_ltcs = gf100_gr_init_num_active_ltcs, 103 .init_rop_active_fbps = gp100_gr_init_rop_active_fbps, 104 .init_swdx_pes_mask = gp102_gr_init_swdx_pes_mask, 105 .init_fs = tu102_gr_init_fs, 106 .init_fecs_exceptions = tu102_gr_init_fecs_exceptions, 107 .init_ds_hww_esr_2 = gm200_gr_init_ds_hww_esr_2, 108 .init_sked_hww_esr = gk104_gr_init_sked_hww_esr, 109 .init_ppc_exceptions = gk104_gr_init_ppc_exceptions, 110 .init_504430 = gv100_gr_init_504430, 111 .init_shader_exceptions = gv100_gr_init_shader_exceptions, 112 .init_rop_exceptions = gf100_gr_init_rop_exceptions, 113 .init_exception2 = gf100_gr_init_exception2, 114 .trap_mp = gv100_gr_trap_mp, 115 .fecs.reset = gf100_gr_fecs_reset, 116 .rops = gm200_gr_rops, 117 .gpc_nr = 6, 118 .tpc_nr = 6, 119 .ppc_nr = 3, 120 .grctx = &tu102_grctx, 121 .zbc = &gp102_gr_zbc, 122 .sclass = { 123 { -1, -1, FERMI_TWOD_A }, 124 { -1, -1, KEPLER_INLINE_TO_MEMORY_B }, 125 { -1, -1, TURING_A, &gf100_fermi }, 126 { -1, -1, TURING_COMPUTE_A }, 127 {} 128 } 129 }; 130 131 MODULE_FIRMWARE("nvidia/tu102/gr/fecs_bl.bin"); 132 MODULE_FIRMWARE("nvidia/tu102/gr/fecs_inst.bin"); 133 MODULE_FIRMWARE("nvidia/tu102/gr/fecs_data.bin"); 134 MODULE_FIRMWARE("nvidia/tu102/gr/fecs_sig.bin"); 135 MODULE_FIRMWARE("nvidia/tu102/gr/gpccs_bl.bin"); 136 MODULE_FIRMWARE("nvidia/tu102/gr/gpccs_inst.bin"); 137 MODULE_FIRMWARE("nvidia/tu102/gr/gpccs_data.bin"); 138 MODULE_FIRMWARE("nvidia/tu102/gr/gpccs_sig.bin"); 139 MODULE_FIRMWARE("nvidia/tu102/gr/sw_ctx.bin"); 140 MODULE_FIRMWARE("nvidia/tu102/gr/sw_nonctx.bin"); 141 MODULE_FIRMWARE("nvidia/tu102/gr/sw_bundle_init.bin"); 142 MODULE_FIRMWARE("nvidia/tu102/gr/sw_method_init.bin"); 143 144 MODULE_FIRMWARE("nvidia/tu104/gr/fecs_bl.bin"); 145 MODULE_FIRMWARE("nvidia/tu104/gr/fecs_inst.bin"); 146 MODULE_FIRMWARE("nvidia/tu104/gr/fecs_data.bin"); 147 MODULE_FIRMWARE("nvidia/tu104/gr/fecs_sig.bin"); 148 MODULE_FIRMWARE("nvidia/tu104/gr/gpccs_bl.bin"); 149 MODULE_FIRMWARE("nvidia/tu104/gr/gpccs_inst.bin"); 150 MODULE_FIRMWARE("nvidia/tu104/gr/gpccs_data.bin"); 151 MODULE_FIRMWARE("nvidia/tu104/gr/gpccs_sig.bin"); 152 MODULE_FIRMWARE("nvidia/tu104/gr/sw_ctx.bin"); 153 MODULE_FIRMWARE("nvidia/tu104/gr/sw_nonctx.bin"); 154 MODULE_FIRMWARE("nvidia/tu104/gr/sw_bundle_init.bin"); 155 MODULE_FIRMWARE("nvidia/tu104/gr/sw_method_init.bin"); 156 157 MODULE_FIRMWARE("nvidia/tu106/gr/fecs_bl.bin"); 158 MODULE_FIRMWARE("nvidia/tu106/gr/fecs_inst.bin"); 159 MODULE_FIRMWARE("nvidia/tu106/gr/fecs_data.bin"); 160 MODULE_FIRMWARE("nvidia/tu106/gr/fecs_sig.bin"); 161 MODULE_FIRMWARE("nvidia/tu106/gr/gpccs_bl.bin"); 162 MODULE_FIRMWARE("nvidia/tu106/gr/gpccs_inst.bin"); 163 MODULE_FIRMWARE("nvidia/tu106/gr/gpccs_data.bin"); 164 MODULE_FIRMWARE("nvidia/tu106/gr/gpccs_sig.bin"); 165 MODULE_FIRMWARE("nvidia/tu106/gr/sw_ctx.bin"); 166 MODULE_FIRMWARE("nvidia/tu106/gr/sw_nonctx.bin"); 167 MODULE_FIRMWARE("nvidia/tu106/gr/sw_bundle_init.bin"); 168 MODULE_FIRMWARE("nvidia/tu106/gr/sw_method_init.bin"); 169 170 MODULE_FIRMWARE("nvidia/tu117/gr/fecs_bl.bin"); 171 MODULE_FIRMWARE("nvidia/tu117/gr/fecs_inst.bin"); 172 MODULE_FIRMWARE("nvidia/tu117/gr/fecs_data.bin"); 173 MODULE_FIRMWARE("nvidia/tu117/gr/fecs_sig.bin"); 174 MODULE_FIRMWARE("nvidia/tu117/gr/gpccs_bl.bin"); 175 MODULE_FIRMWARE("nvidia/tu117/gr/gpccs_inst.bin"); 176 MODULE_FIRMWARE("nvidia/tu117/gr/gpccs_data.bin"); 177 MODULE_FIRMWARE("nvidia/tu117/gr/gpccs_sig.bin"); 178 MODULE_FIRMWARE("nvidia/tu117/gr/sw_ctx.bin"); 179 MODULE_FIRMWARE("nvidia/tu117/gr/sw_nonctx.bin"); 180 MODULE_FIRMWARE("nvidia/tu117/gr/sw_bundle_init.bin"); 181 MODULE_FIRMWARE("nvidia/tu117/gr/sw_method_init.bin"); 182 183 MODULE_FIRMWARE("nvidia/tu116/gr/fecs_bl.bin"); 184 MODULE_FIRMWARE("nvidia/tu116/gr/fecs_inst.bin"); 185 MODULE_FIRMWARE("nvidia/tu116/gr/fecs_data.bin"); 186 MODULE_FIRMWARE("nvidia/tu116/gr/fecs_sig.bin"); 187 MODULE_FIRMWARE("nvidia/tu116/gr/gpccs_bl.bin"); 188 MODULE_FIRMWARE("nvidia/tu116/gr/gpccs_inst.bin"); 189 MODULE_FIRMWARE("nvidia/tu116/gr/gpccs_data.bin"); 190 MODULE_FIRMWARE("nvidia/tu116/gr/gpccs_sig.bin"); 191 MODULE_FIRMWARE("nvidia/tu116/gr/sw_ctx.bin"); 192 MODULE_FIRMWARE("nvidia/tu116/gr/sw_nonctx.bin"); 193 MODULE_FIRMWARE("nvidia/tu116/gr/sw_bundle_init.bin"); 194 MODULE_FIRMWARE("nvidia/tu116/gr/sw_method_init.bin"); 195 196 static const struct gf100_gr_fwif 197 tu102_gr_fwif[] = { 198 { 0, gm200_gr_load, &tu102_gr, &gp108_gr_fecs_acr, &gp108_gr_gpccs_acr }, 199 { -1, gm200_gr_nofw }, 200 {} 201 }; 202 203 int 204 tu102_gr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_gr **pgr) 205 { 206 return gf100_gr_new_(tu102_gr_fwif, device, type, inst, pgr); 207 } 208