• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010 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  * Authors: Ben Skeggs
23  */
24 #ifndef __GF100_GR_H__
25 #define __GF100_GR_H__
26 #define gf100_gr(p) container_of((p), struct gf100_gr, base)
27 #include "priv.h"
28 
29 #include <core/gpuobj.h>
30 #include <subdev/ltc.h>
31 #include <subdev/mmu.h>
32 #include <engine/falcon.h>
33 
34 struct nvkm_acr_lsfw;
35 
36 #define GPC_MAX 32
37 #define TPC_MAX_PER_GPC 8
38 #define TPC_MAX (GPC_MAX * TPC_MAX_PER_GPC)
39 
40 #define ROP_BCAST(r)      (0x408800 + (r))
41 #define ROP_UNIT(u, r)    (0x410000 + (u) * 0x400 + (r))
42 #define GPC_BCAST(r)      (0x418000 + (r))
43 #define GPC_UNIT(t, r)    (0x500000 + (t) * 0x8000 + (r))
44 #define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r))
45 #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
46 
47 struct gf100_gr_zbc_color {
48 	u32 format;
49 	u32 ds[4];
50 	u32 l2[4];
51 };
52 
53 struct gf100_gr_zbc_depth {
54 	u32 format;
55 	u32 ds;
56 	u32 l2;
57 };
58 
59 struct gf100_gr_zbc_stencil {
60 	u32 format;
61 	u32 ds;
62 	u32 l2;
63 };
64 
65 struct gf100_gr {
66 	const struct gf100_gr_func *func;
67 	struct nvkm_gr base;
68 
69 	struct {
70 		struct nvkm_falcon falcon;
71 		struct nvkm_blob inst;
72 		struct nvkm_blob data;
73 
74 		struct mutex mutex;
75 		u32 disable;
76 	} fecs;
77 
78 	struct {
79 		struct nvkm_falcon falcon;
80 		struct nvkm_blob inst;
81 		struct nvkm_blob data;
82 	} gpccs;
83 
84 	bool firmware;
85 
86 	/*
87 	 * Used if the register packs are loaded from NVIDIA fw instead of
88 	 * using hardcoded arrays. To be allocated with vzalloc().
89 	 */
90 	struct gf100_gr_pack *sw_nonctx;
91 	struct gf100_gr_pack *sw_nonctx1;
92 	struct gf100_gr_pack *sw_nonctx2;
93 	struct gf100_gr_pack *sw_nonctx3;
94 	struct gf100_gr_pack *sw_nonctx4;
95 	struct gf100_gr_pack *sw_ctx;
96 	struct gf100_gr_pack *bundle;
97 	struct gf100_gr_pack *bundle_veid;
98 	struct gf100_gr_pack *bundle64;
99 	struct gf100_gr_pack *method;
100 
101 	struct gf100_gr_zbc_color zbc_color[NVKM_LTC_MAX_ZBC_COLOR_CNT];
102 	struct gf100_gr_zbc_depth zbc_depth[NVKM_LTC_MAX_ZBC_DEPTH_CNT];
103 	struct gf100_gr_zbc_stencil zbc_stencil[NVKM_LTC_MAX_ZBC_DEPTH_CNT];
104 
105 	u8 rop_nr;
106 	u8 gpc_nr;
107 	u8 tpc_nr[GPC_MAX];
108 	u8 tpc_max;
109 	u8 tpc_total;
110 	u8 ppc_nr[GPC_MAX];
111 	u8 ppc_mask[GPC_MAX];
112 	u8 ppc_tpc_mask[GPC_MAX][4];
113 	u8 ppc_tpc_nr[GPC_MAX][4];
114 	u8 ppc_tpc_min;
115 	u8 ppc_tpc_max;
116 	u8 ppc_total;
117 
118 	struct nvkm_memory *pagepool;
119 	struct nvkm_memory *bundle_cb;
120 	struct nvkm_memory *attrib_cb;
121 	struct nvkm_memory *unknown;
122 
123 	u8 screen_tile_row_offset;
124 	u8 tile[TPC_MAX];
125 
126 	struct {
127 		u8 gpc;
128 		u8 tpc;
129 	} sm[TPC_MAX];
130 	u8 sm_nr;
131 
132 	u32  size;
133 	u32 *data;
134 	u32 size_zcull;
135 	u32 size_pm;
136 };
137 
138 int gf100_gr_fecs_bind_pointer(struct gf100_gr *, u32 inst);
139 int gf100_gr_fecs_wfi_golden_save(struct gf100_gr *, u32 inst);
140 
141 struct gf100_gr_func_zbc {
142 	void (*clear_color)(struct gf100_gr *, int zbc);
143 	void (*clear_depth)(struct gf100_gr *, int zbc);
144 	int (*stencil_get)(struct gf100_gr *, int format,
145 			   const u32 ds, const u32 l2);
146 	void (*clear_stencil)(struct gf100_gr *, int zbc);
147 };
148 
149 struct gf100_gr_func {
150 	int (*nonstall)(struct gf100_gr *);
151 	struct nvkm_intr *(*oneinit_intr)(struct gf100_gr *, enum nvkm_intr_type *);
152 	void (*oneinit_tiles)(struct gf100_gr *);
153 	int (*oneinit_sm_id)(struct gf100_gr *);
154 	int (*init)(struct gf100_gr *);
155 	void (*init_419bd8)(struct gf100_gr *);
156 	void (*init_gpc_mmu)(struct gf100_gr *);
157 	void (*init_r405a14)(struct gf100_gr *);
158 	void (*init_bios)(struct gf100_gr *);
159 	void (*init_vsc_stream_master)(struct gf100_gr *);
160 	void (*init_zcull)(struct gf100_gr *);
161 	void (*init_num_active_ltcs)(struct gf100_gr *);
162 	void (*init_rop_active_fbps)(struct gf100_gr *);
163 	void (*init_bios_2)(struct gf100_gr *);
164 	void (*init_swdx_pes_mask)(struct gf100_gr *);
165 	void (*init_fs)(struct gf100_gr *);
166 	void (*init_fecs_exceptions)(struct gf100_gr *);
167 	void (*init_40a790)(struct gf100_gr *);
168 	void (*init_ds_hww_esr_2)(struct gf100_gr *);
169 	void (*init_40601c)(struct gf100_gr *);
170 	void (*init_sked_hww_esr)(struct gf100_gr *);
171 	void (*init_419cc0)(struct gf100_gr *);
172 	void (*init_419eb4)(struct gf100_gr *);
173 	void (*init_419c9c)(struct gf100_gr *);
174 	void (*init_ppc_exceptions)(struct gf100_gr *);
175 	void (*init_tex_hww_esr)(struct gf100_gr *, int gpc, int tpc);
176 	void (*init_504430)(struct gf100_gr *, int gpc, int tpc);
177 	void (*init_shader_exceptions)(struct gf100_gr *, int gpc, int tpc);
178 	void (*init_rop_exceptions)(struct gf100_gr *);
179 	void (*init_exception2)(struct gf100_gr *);
180 	void (*init_400054)(struct gf100_gr *);
181 	void (*init_4188a4)(struct gf100_gr *);
182 	void (*trap_mp)(struct gf100_gr *, int gpc, int tpc);
183 	void (*set_hww_esr_report_mask)(struct gf100_gr *);
184 	const struct gf100_gr_pack *mmio;
185 	struct {
186 		struct gf100_gr_ucode *ucode;
187 		void (*reset)(struct gf100_gr *);
188 	} fecs;
189 	struct {
190 		struct gf100_gr_ucode *ucode;
191 		void (*reset)(struct gf100_gr *);
192 	} gpccs;
193 	int (*rops)(struct gf100_gr *);
194 	int gpc_nr;
195 	int tpc_nr;
196 	int ppc_nr;
197 	const struct gf100_grctx_func *grctx;
198 	const struct nvkm_therm_clkgate_pack *clkgate_pack;
199 	const struct gf100_gr_func_zbc *zbc;
200 	struct nvkm_sclass sclass[];
201 };
202 
203 int gf100_gr_rops(struct gf100_gr *);
204 void gf100_gr_oneinit_tiles(struct gf100_gr *);
205 int gf100_gr_oneinit_sm_id(struct gf100_gr *);
206 int gf100_gr_init(struct gf100_gr *);
207 void gf100_gr_init_vsc_stream_master(struct gf100_gr *);
208 void gf100_gr_init_zcull(struct gf100_gr *);
209 void gf100_gr_init_num_active_ltcs(struct gf100_gr *);
210 void gf100_gr_init_fecs_exceptions(struct gf100_gr *);
211 void gf100_gr_init_40601c(struct gf100_gr *);
212 void gf100_gr_init_419cc0(struct gf100_gr *);
213 void gf100_gr_init_419eb4(struct gf100_gr *);
214 void gf100_gr_init_tex_hww_esr(struct gf100_gr *, int, int);
215 void gf100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
216 void gf100_gr_init_rop_exceptions(struct gf100_gr *);
217 void gf100_gr_init_exception2(struct gf100_gr *);
218 void gf100_gr_init_400054(struct gf100_gr *);
219 void gf100_gr_init_num_tpc_per_gpc(struct gf100_gr *, bool, bool);
220 extern const struct gf100_gr_func_zbc gf100_gr_zbc;
221 void gf100_gr_fecs_reset(struct gf100_gr *);
222 
223 void gf117_gr_init_zcull(struct gf100_gr *);
224 
225 void gk104_gr_init_vsc_stream_master(struct gf100_gr *);
226 void gk104_gr_init_rop_active_fbps(struct gf100_gr *);
227 void gk104_gr_init_ppc_exceptions(struct gf100_gr *);
228 void gk104_gr_init_sked_hww_esr(struct gf100_gr *);
229 
230 void gk110_gr_init_419eb4(struct gf100_gr *);
231 
232 void gm107_gr_init_504430(struct gf100_gr *, int, int);
233 void gm107_gr_init_shader_exceptions(struct gf100_gr *, int, int);
234 void gm107_gr_init_400054(struct gf100_gr *);
235 
236 int gk20a_gr_init(struct gf100_gr *);
237 int gk20a_gr_av_to_init_(struct nvkm_blob *, u8 count, u32 pitch, struct gf100_gr_pack **);
238 int gk20a_gr_av_to_init(struct nvkm_blob *, struct gf100_gr_pack **);
239 int gk20a_gr_aiv_to_init(struct nvkm_blob *, struct gf100_gr_pack **);
240 int gk20a_gr_av_to_method(struct nvkm_blob *, struct gf100_gr_pack **);
241 
242 void gm200_gr_oneinit_tiles(struct gf100_gr *);
243 int gm200_gr_oneinit_sm_id(struct gf100_gr *);
244 int gm200_gr_rops(struct gf100_gr *);
245 void gm200_gr_init_num_active_ltcs(struct gf100_gr *);
246 void gm200_gr_init_ds_hww_esr_2(struct gf100_gr *);
247 
248 void gp100_gr_init_rop_active_fbps(struct gf100_gr *);
249 void gp100_gr_init_fecs_exceptions(struct gf100_gr *);
250 void gp100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
251 void gp100_gr_zbc_clear_color(struct gf100_gr *, int);
252 void gp100_gr_zbc_clear_depth(struct gf100_gr *, int);
253 extern const struct gf100_gr_func_zbc gp100_gr_zbc;
254 
255 void gp102_gr_init_swdx_pes_mask(struct gf100_gr *);
256 extern const struct gf100_gr_func_zbc gp102_gr_zbc;
257 int gp102_gr_zbc_stencil_get(struct gf100_gr *, int, const u32, const u32);
258 void gp102_gr_zbc_clear_stencil(struct gf100_gr *, int);
259 
260 extern const struct gf100_gr_func gp107_gr;
261 
262 int gv100_gr_oneinit_sm_id(struct gf100_gr *);
263 u32 gv100_gr_nonpes_aware_tpc(struct gf100_gr *gr, u32 gpc, u32 tpc);
264 void gv100_gr_init_419bd8(struct gf100_gr *);
265 void gv100_gr_init_504430(struct gf100_gr *, int, int);
266 void gv100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
267 void gv100_gr_init_4188a4(struct gf100_gr *);
268 void gv100_gr_trap_mp(struct gf100_gr *, int, int);
269 
270 int tu102_gr_av_to_init_veid(struct nvkm_blob *, struct gf100_gr_pack **);
271 void tu102_gr_init_zcull(struct gf100_gr *);
272 void tu102_gr_init_fs(struct gf100_gr *);
273 void tu102_gr_init_fecs_exceptions(struct gf100_gr *);
274 
275 #define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
276 #include <core/object.h>
277 
278 struct gf100_gr_chan {
279 	struct nvkm_object object;
280 	struct gf100_gr *gr;
281 	struct nvkm_vmm *vmm;
282 
283 	struct nvkm_vma *pagepool;
284 	struct nvkm_vma *bundle_cb;
285 	struct nvkm_vma *attrib_cb;
286 	struct nvkm_vma *unknown;
287 
288 	struct nvkm_memory *mmio;
289 	struct nvkm_vma *mmio_vma;
290 	int mmio_nr;
291 };
292 
293 void gf100_gr_ctxctl_debug(struct gf100_gr *);
294 
295 u64  gf100_gr_units(struct nvkm_gr *);
296 void gf100_gr_zbc_init(struct gf100_gr *);
297 
298 extern const struct nvkm_object_func gf100_fermi;
299 
300 struct gf100_gr_init {
301 	u32 addr;
302 	u8  count;
303 	u32 pitch;
304 	u64 data;
305 };
306 
307 struct gf100_gr_pack {
308 	const struct gf100_gr_init *init;
309 	u32 type;
310 };
311 
312 #define pack_for_each_init(init, pack, head)                                   \
313 	for (pack = head; pack && pack->init; pack++)                          \
314 		  for (init = pack->init; init && init->count; init++)
315 
316 struct gf100_gr_ucode {
317 	struct nvkm_blob code;
318 	struct nvkm_blob data;
319 };
320 
321 extern struct gf100_gr_ucode gf100_gr_fecs_ucode;
322 extern struct gf100_gr_ucode gf100_gr_gpccs_ucode;
323 
324 extern struct gf100_gr_ucode gk110_gr_fecs_ucode;
325 extern struct gf100_gr_ucode gk110_gr_gpccs_ucode;
326 
327 int  gf100_gr_wait_idle(struct gf100_gr *);
328 void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *);
329 void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *);
330 void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *);
331 int  gf100_gr_init_ctxctl(struct gf100_gr *);
332 
333 /* register init value lists */
334 
335 extern const struct gf100_gr_init gf100_gr_init_main_0[];
336 extern const struct gf100_gr_init gf100_gr_init_fe_0[];
337 extern const struct gf100_gr_init gf100_gr_init_pri_0[];
338 extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[];
339 extern const struct gf100_gr_init gf100_gr_init_pd_0[];
340 extern const struct gf100_gr_init gf100_gr_init_ds_0[];
341 extern const struct gf100_gr_init gf100_gr_init_scc_0[];
342 extern const struct gf100_gr_init gf100_gr_init_prop_0[];
343 extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[];
344 extern const struct gf100_gr_init gf100_gr_init_setup_0[];
345 extern const struct gf100_gr_init gf100_gr_init_crstr_0[];
346 extern const struct gf100_gr_init gf100_gr_init_setup_1[];
347 extern const struct gf100_gr_init gf100_gr_init_zcull_0[];
348 extern const struct gf100_gr_init gf100_gr_init_gpm_0[];
349 extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[];
350 extern const struct gf100_gr_init gf100_gr_init_gcc_0[];
351 extern const struct gf100_gr_init gf100_gr_init_tpccs_0[];
352 extern const struct gf100_gr_init gf100_gr_init_tex_0[];
353 extern const struct gf100_gr_init gf100_gr_init_pe_0[];
354 extern const struct gf100_gr_init gf100_gr_init_l1c_0[];
355 extern const struct gf100_gr_init gf100_gr_init_wwdx_0[];
356 extern const struct gf100_gr_init gf100_gr_init_tpccs_1[];
357 extern const struct gf100_gr_init gf100_gr_init_mpc_0[];
358 extern const struct gf100_gr_init gf100_gr_init_be_0[];
359 extern const struct gf100_gr_init gf100_gr_init_fe_1[];
360 extern const struct gf100_gr_init gf100_gr_init_pe_1[];
361 void gf100_gr_init_gpc_mmu(struct gf100_gr *);
362 void gf100_gr_trap_mp(struct gf100_gr *, int, int);
363 extern const struct nvkm_bitfield gf100_mp_global_error[];
364 extern const struct nvkm_enum gf100_mp_warp_error[];
365 
366 extern const struct gf100_gr_init gf104_gr_init_ds_0[];
367 extern const struct gf100_gr_init gf104_gr_init_tex_0[];
368 extern const struct gf100_gr_init gf104_gr_init_sm_0[];
369 
370 extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[];
371 extern const struct gf100_gr_init gf108_gr_init_setup_1[];
372 
373 extern const struct gf100_gr_init gf119_gr_init_pd_0[];
374 extern const struct gf100_gr_init gf119_gr_init_ds_0[];
375 extern const struct gf100_gr_init gf119_gr_init_prop_0[];
376 extern const struct gf100_gr_init gf119_gr_init_gpm_0[];
377 extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[];
378 extern const struct gf100_gr_init gf119_gr_init_tex_0[];
379 extern const struct gf100_gr_init gf119_gr_init_sm_0[];
380 extern const struct gf100_gr_init gf119_gr_init_fe_1[];
381 
382 extern const struct gf100_gr_init gf117_gr_init_pes_0[];
383 extern const struct gf100_gr_init gf117_gr_init_wwdx_0[];
384 extern const struct gf100_gr_init gf117_gr_init_cbm_0[];
385 
386 extern const struct gf100_gr_init gk104_gr_init_main_0[];
387 extern const struct gf100_gr_init gk104_gr_init_gpc_unk_2[];
388 extern const struct gf100_gr_init gk104_gr_init_tpccs_0[];
389 extern const struct gf100_gr_init gk104_gr_init_pe_0[];
390 extern const struct gf100_gr_init gk104_gr_init_be_0[];
391 extern const struct gf100_gr_pack gk104_gr_pack_mmio[];
392 
393 extern const struct gf100_gr_init gk110_gr_init_fe_0[];
394 extern const struct gf100_gr_init gk110_gr_init_ds_0[];
395 extern const struct gf100_gr_init gk110_gr_init_sked_0[];
396 extern const struct gf100_gr_init gk110_gr_init_cwd_0[];
397 extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[];
398 extern const struct gf100_gr_init gk110_gr_init_tex_0[];
399 extern const struct gf100_gr_init gk110_gr_init_sm_0[];
400 
401 extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[];
402 
403 extern const struct gf100_gr_init gm107_gr_init_scc_0[];
404 extern const struct gf100_gr_init gm107_gr_init_prop_0[];
405 extern const struct gf100_gr_init gm107_gr_init_setup_1[];
406 extern const struct gf100_gr_init gm107_gr_init_zcull_0[];
407 extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[];
408 extern const struct gf100_gr_init gm107_gr_init_tex_0[];
409 extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
410 extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
411 extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
412 void gm107_gr_init_bios(struct gf100_gr *);
413 
414 void gm200_gr_init_gpc_mmu(struct gf100_gr *);
415 
416 struct gf100_gr_fwif {
417 	int version;
418 	int (*load)(struct gf100_gr *, int ver, const struct gf100_gr_fwif *);
419 	const struct gf100_gr_func *func;
420 	const struct nvkm_acr_lsf_func *fecs;
421 	const struct nvkm_acr_lsf_func *gpccs;
422 };
423 
424 int gf100_gr_load(struct gf100_gr *, int, const struct gf100_gr_fwif *);
425 int gf100_gr_nofw(struct gf100_gr *, int, const struct gf100_gr_fwif *);
426 
427 int gk20a_gr_load_sw(struct gf100_gr *, const char *path, int ver);
428 int gk20a_gr_load_net(struct gf100_gr *, const char *, const char *, int,
429 		      int (*)(struct nvkm_blob *, struct gf100_gr_pack **),
430 		      struct gf100_gr_pack **);
431 
432 int gm200_gr_nofw(struct gf100_gr *, int, const struct gf100_gr_fwif *);
433 int gm200_gr_load(struct gf100_gr *, int, const struct gf100_gr_fwif *);
434 extern const struct nvkm_acr_lsf_func gm200_gr_gpccs_acr;
435 extern const struct nvkm_acr_lsf_func gm200_gr_fecs_acr;
436 
437 extern const struct nvkm_acr_lsf_func gm20b_gr_fecs_acr;
438 void gm20b_gr_acr_bld_write(struct nvkm_acr *, u32, struct nvkm_acr_lsfw *);
439 void gm20b_gr_acr_bld_patch(struct nvkm_acr *, u32, s64);
440 
441 extern const struct nvkm_acr_lsf_func gp108_gr_gpccs_acr;
442 extern const struct nvkm_acr_lsf_func gp108_gr_fecs_acr;
443 void gp108_gr_acr_bld_write(struct nvkm_acr *, u32, struct nvkm_acr_lsfw *);
444 void gp108_gr_acr_bld_patch(struct nvkm_acr *, u32, s64);
445 
446 int gf100_gr_new_(const struct gf100_gr_fwif *, struct nvkm_device *, enum nvkm_subdev_type, int,
447 		  struct nvkm_gr **);
448 #endif
449