1 /* SPDX-License-Identifier: MIT */ 2 #ifndef __NVKM_GRCTX_NVC0_H__ 3 #define __NVKM_GRCTX_NVC0_H__ 4 #include "gf100.h" 5 6 struct gf100_grctx { 7 struct gf100_gr *gr; 8 struct gf100_gr_data *data; 9 struct gf100_gr_mmio *mmio; 10 int buffer_nr; 11 u64 buffer[4]; 12 u64 addr; 13 }; 14 15 int gf100_grctx_mmio_data(struct gf100_grctx *, u32 size, u32 align, bool priv); 16 void gf100_grctx_mmio_item(struct gf100_grctx *, u32 addr, u32 data, int s, int); 17 18 #define mmio_vram(a,b,c,d) gf100_grctx_mmio_data((a), (b), (c), (d)) 19 #define mmio_refn(a,b,c,d,e) gf100_grctx_mmio_item((a), (b), (c), (d), (e)) 20 #define mmio_skip(a,b,c) mmio_refn((a), (b), (c), -1, -1) 21 #define mmio_wr32(a,b,c) mmio_refn((a), (b), (c), 0, -1) 22 23 struct gf100_grctx_func { 24 void (*unkn88c)(struct gf100_gr *, bool on); 25 /* main context generation function */ 26 void (*main)(struct gf100_gr *, struct gf100_grctx *); 27 /* context-specific modify-on-first-load list generation function */ 28 void (*unkn)(struct gf100_gr *); 29 /* mmio context data */ 30 const struct gf100_gr_pack *hub; 31 const struct gf100_gr_pack *gpc_0; 32 const struct gf100_gr_pack *gpc_1; 33 const struct gf100_gr_pack *zcull; 34 const struct gf100_gr_pack *tpc; 35 const struct gf100_gr_pack *ppc; 36 /* indirect context data, generated with icmds/mthds */ 37 const struct gf100_gr_pack *icmd; 38 const struct gf100_gr_pack *mthd; 39 const struct gf100_gr_pack *sw_veid_bundle_init; 40 /* bundle circular buffer */ 41 void (*bundle)(struct gf100_grctx *); 42 u32 bundle_size; 43 u32 bundle_min_gpm_fifo_depth; 44 u32 bundle_token_limit; 45 /* pagepool */ 46 void (*pagepool)(struct gf100_grctx *); 47 u32 pagepool_size; 48 /* attribute(/alpha) circular buffer */ 49 void (*attrib)(struct gf100_grctx *); 50 u32 attrib_nr_max; 51 u32 attrib_nr; 52 u32 alpha_nr_max; 53 u32 alpha_nr; 54 u32 gfxp_nr; 55 /* other patch buffer stuff */ 56 void (*patch_ltc)(struct gf100_grctx *); 57 /* floorsweeping */ 58 void (*sm_id)(struct gf100_gr *, int gpc, int tpc, int sm); 59 void (*tpc_nr)(struct gf100_gr *, int gpc); 60 bool skip_pd_num_tpc_per_gpc; 61 void (*r4060a8)(struct gf100_gr *); 62 void (*rop_mapping)(struct gf100_gr *); 63 void (*alpha_beta_tables)(struct gf100_gr *); 64 void (*max_ways_evict)(struct gf100_gr *); 65 void (*dist_skip_table)(struct gf100_gr *); 66 void (*r406500)(struct gf100_gr *); 67 void (*gpc_tpc_nr)(struct gf100_gr *); 68 void (*r419f78)(struct gf100_gr *); 69 void (*tpc_mask)(struct gf100_gr *); 70 void (*smid_config)(struct gf100_gr *); 71 /* misc other things */ 72 void (*r400088)(struct gf100_gr *, bool); 73 void (*r419cb8)(struct gf100_gr *); 74 void (*r418800)(struct gf100_gr *); 75 void (*r419eb0)(struct gf100_gr *); 76 void (*r419e00)(struct gf100_gr *); 77 void (*r418e94)(struct gf100_gr *); 78 void (*r419a3c)(struct gf100_gr *); 79 void (*r408840)(struct gf100_gr *); 80 void (*r419c0c)(struct gf100_gr *); 81 }; 82 83 extern const struct gf100_grctx_func gf100_grctx; 84 int gf100_grctx_generate(struct gf100_gr *); 85 void gf100_grctx_generate_main(struct gf100_gr *, struct gf100_grctx *); 86 void gf100_grctx_generate_bundle(struct gf100_grctx *); 87 void gf100_grctx_generate_pagepool(struct gf100_grctx *); 88 void gf100_grctx_generate_attrib(struct gf100_grctx *); 89 void gf100_grctx_generate_unkn(struct gf100_gr *); 90 void gf100_grctx_generate_floorsweep(struct gf100_gr *); 91 void gf100_grctx_generate_sm_id(struct gf100_gr *, int, int, int); 92 void gf100_grctx_generate_tpc_nr(struct gf100_gr *, int); 93 void gf100_grctx_generate_r4060a8(struct gf100_gr *); 94 void gf100_grctx_generate_rop_mapping(struct gf100_gr *); 95 void gf100_grctx_generate_alpha_beta_tables(struct gf100_gr *); 96 void gf100_grctx_generate_max_ways_evict(struct gf100_gr *); 97 void gf100_grctx_generate_r419cb8(struct gf100_gr *); 98 99 extern const struct gf100_grctx_func gf108_grctx; 100 void gf108_grctx_generate_attrib(struct gf100_grctx *); 101 void gf108_grctx_generate_unkn(struct gf100_gr *); 102 103 extern const struct gf100_grctx_func gf104_grctx; 104 extern const struct gf100_grctx_func gf110_grctx; 105 106 extern const struct gf100_grctx_func gf117_grctx; 107 void gf117_grctx_generate_attrib(struct gf100_grctx *); 108 void gf117_grctx_generate_rop_mapping(struct gf100_gr *); 109 void gf117_grctx_generate_dist_skip_table(struct gf100_gr *); 110 111 extern const struct gf100_grctx_func gf119_grctx; 112 113 extern const struct gf100_grctx_func gk104_grctx; 114 void gk104_grctx_generate_alpha_beta_tables(struct gf100_gr *); 115 void gk104_grctx_generate_gpc_tpc_nr(struct gf100_gr *); 116 117 extern const struct gf100_grctx_func gk20a_grctx; 118 void gk104_grctx_generate_bundle(struct gf100_grctx *); 119 void gk104_grctx_generate_pagepool(struct gf100_grctx *); 120 void gk104_grctx_generate_patch_ltc(struct gf100_grctx *); 121 void gk104_grctx_generate_unkn(struct gf100_gr *); 122 void gk104_grctx_generate_r418800(struct gf100_gr *); 123 124 extern const struct gf100_grctx_func gk110_grctx; 125 void gk110_grctx_generate_r419eb0(struct gf100_gr *); 126 void gk110_grctx_generate_r419f78(struct gf100_gr *); 127 128 extern const struct gf100_grctx_func gk110b_grctx; 129 extern const struct gf100_grctx_func gk208_grctx; 130 131 extern const struct gf100_grctx_func gm107_grctx; 132 void gm107_grctx_generate_bundle(struct gf100_grctx *); 133 void gm107_grctx_generate_pagepool(struct gf100_grctx *); 134 void gm107_grctx_generate_attrib(struct gf100_grctx *); 135 void gm107_grctx_generate_sm_id(struct gf100_gr *, int, int, int); 136 137 extern const struct gf100_grctx_func gm200_grctx; 138 void gm200_grctx_generate_dist_skip_table(struct gf100_gr *); 139 void gm200_grctx_generate_r406500(struct gf100_gr *); 140 void gm200_grctx_generate_tpc_mask(struct gf100_gr *); 141 void gm200_grctx_generate_smid_config(struct gf100_gr *); 142 void gm200_grctx_generate_r419a3c(struct gf100_gr *); 143 144 extern const struct gf100_grctx_func gm20b_grctx; 145 146 extern const struct gf100_grctx_func gp100_grctx; 147 void gp100_grctx_generate_pagepool(struct gf100_grctx *); 148 void gp100_grctx_generate_smid_config(struct gf100_gr *); 149 150 extern const struct gf100_grctx_func gp102_grctx; 151 void gp102_grctx_generate_attrib(struct gf100_grctx *); 152 153 extern const struct gf100_grctx_func gp104_grctx; 154 155 extern const struct gf100_grctx_func gp107_grctx; 156 157 extern const struct gf100_grctx_func gv100_grctx; 158 159 extern const struct gf100_grctx_func tu102_grctx; 160 void gv100_grctx_unkn88c(struct gf100_gr *, bool); 161 void gv100_grctx_generate_unkn(struct gf100_gr *); 162 extern const struct gf100_gr_init gv100_grctx_init_sw_veid_bundle_init_0[]; 163 void gv100_grctx_generate_attrib(struct gf100_grctx *); 164 void gv100_grctx_generate_rop_mapping(struct gf100_gr *); 165 void gv100_grctx_generate_r400088(struct gf100_gr *, bool); 166 167 /* context init value lists */ 168 169 extern const struct gf100_gr_pack gf100_grctx_pack_icmd[]; 170 171 extern const struct gf100_gr_pack gf100_grctx_pack_mthd[]; 172 extern const struct gf100_gr_init gf100_grctx_init_902d_0[]; 173 extern const struct gf100_gr_init gf100_grctx_init_9039_0[]; 174 extern const struct gf100_gr_init gf100_grctx_init_90c0_0[]; 175 176 extern const struct gf100_gr_pack gf100_grctx_pack_hub[]; 177 extern const struct gf100_gr_init gf100_grctx_init_main_0[]; 178 extern const struct gf100_gr_init gf100_grctx_init_fe_0[]; 179 extern const struct gf100_gr_init gf100_grctx_init_pri_0[]; 180 extern const struct gf100_gr_init gf100_grctx_init_memfmt_0[]; 181 extern const struct gf100_gr_init gf100_grctx_init_rstr2d_0[]; 182 extern const struct gf100_gr_init gf100_grctx_init_scc_0[]; 183 184 extern const struct gf100_gr_pack gf100_grctx_pack_gpc_0[]; 185 extern const struct gf100_gr_pack gf100_grctx_pack_gpc_1[]; 186 extern const struct gf100_gr_init gf100_grctx_init_gpc_unk_0[]; 187 extern const struct gf100_gr_init gf100_grctx_init_prop_0[]; 188 extern const struct gf100_gr_init gf100_grctx_init_gpc_unk_1[]; 189 extern const struct gf100_gr_init gf100_grctx_init_zcull_0[]; 190 extern const struct gf100_gr_init gf100_grctx_init_crstr_0[]; 191 extern const struct gf100_gr_init gf100_grctx_init_gpm_0[]; 192 extern const struct gf100_gr_init gf100_grctx_init_gcc_0[]; 193 194 extern const struct gf100_gr_pack gf100_grctx_pack_zcull[]; 195 196 extern const struct gf100_gr_pack gf100_grctx_pack_tpc[]; 197 extern const struct gf100_gr_init gf100_grctx_init_pe_0[]; 198 extern const struct gf100_gr_init gf100_grctx_init_wwdx_0[]; 199 extern const struct gf100_gr_init gf100_grctx_init_mpc_0[]; 200 extern const struct gf100_gr_init gf100_grctx_init_tpccs_0[]; 201 202 extern const struct gf100_gr_init gf104_grctx_init_tex_0[]; 203 extern const struct gf100_gr_init gf104_grctx_init_l1c_0[]; 204 extern const struct gf100_gr_init gf104_grctx_init_sm_0[]; 205 206 extern const struct gf100_gr_init gf108_grctx_init_9097_0[]; 207 208 extern const struct gf100_gr_init gf108_grctx_init_gpm_0[]; 209 210 extern const struct gf100_gr_init gf108_grctx_init_pe_0[]; 211 extern const struct gf100_gr_init gf108_grctx_init_wwdx_0[]; 212 extern const struct gf100_gr_init gf108_grctx_init_tpccs_0[]; 213 214 extern const struct gf100_gr_init gf110_grctx_init_9197_0[]; 215 extern const struct gf100_gr_init gf110_grctx_init_9297_0[]; 216 217 extern const struct gf100_gr_pack gf119_grctx_pack_icmd[]; 218 219 extern const struct gf100_gr_pack gf119_grctx_pack_mthd[]; 220 221 extern const struct gf100_gr_init gf119_grctx_init_fe_0[]; 222 extern const struct gf100_gr_init gf119_grctx_init_be_0[]; 223 224 extern const struct gf100_gr_init gf119_grctx_init_prop_0[]; 225 extern const struct gf100_gr_init gf119_grctx_init_gpc_unk_1[]; 226 extern const struct gf100_gr_init gf119_grctx_init_crstr_0[]; 227 228 extern const struct gf100_gr_init gf119_grctx_init_sm_0[]; 229 230 extern const struct gf100_gr_init gf117_grctx_init_pe_0[]; 231 232 extern const struct gf100_gr_init gf117_grctx_init_wwdx_0[]; 233 234 extern const struct gf100_gr_pack gf117_grctx_pack_gpc_1[]; 235 236 extern const struct gf100_gr_init gk104_grctx_init_memfmt_0[]; 237 extern const struct gf100_gr_init gk104_grctx_init_ds_0[]; 238 extern const struct gf100_gr_init gk104_grctx_init_scc_0[]; 239 240 extern const struct gf100_gr_init gk104_grctx_init_gpm_0[]; 241 242 extern const struct gf100_gr_init gk104_grctx_init_pes_0[]; 243 244 extern const struct gf100_gr_pack gk104_grctx_pack_hub[]; 245 extern const struct gf100_gr_pack gk104_grctx_pack_tpc[]; 246 extern const struct gf100_gr_pack gk104_grctx_pack_ppc[]; 247 extern const struct gf100_gr_pack gk104_grctx_pack_icmd[]; 248 extern const struct gf100_gr_init gk104_grctx_init_a097_0[]; 249 250 extern const struct gf100_gr_pack gk110_grctx_pack_icmd[]; 251 252 extern const struct gf100_gr_pack gk110_grctx_pack_mthd[]; 253 254 extern const struct gf100_gr_pack gk110_grctx_pack_hub[]; 255 extern const struct gf100_gr_init gk110_grctx_init_pri_0[]; 256 extern const struct gf100_gr_init gk110_grctx_init_cwd_0[]; 257 258 extern const struct gf100_gr_pack gk110_grctx_pack_gpc_0[]; 259 extern const struct gf100_gr_pack gk110_grctx_pack_gpc_1[]; 260 extern const struct gf100_gr_init gk110_grctx_init_gpc_unk_2[]; 261 262 extern const struct gf100_gr_init gk110_grctx_init_tex_0[]; 263 extern const struct gf100_gr_init gk110_grctx_init_mpc_0[]; 264 extern const struct gf100_gr_init gk110_grctx_init_l1c_0[]; 265 266 extern const struct gf100_gr_pack gk110_grctx_pack_ppc[]; 267 268 extern const struct gf100_gr_init gk208_grctx_init_rstr2d_0[]; 269 270 extern const struct gf100_gr_init gk208_grctx_init_prop_0[]; 271 extern const struct gf100_gr_init gk208_grctx_init_crstr_0[]; 272 273 extern const struct gf100_gr_init gm107_grctx_init_gpc_unk_0[]; 274 extern const struct gf100_gr_init gm107_grctx_init_wwdx_0[]; 275 #endif 276