1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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#define GPC_MAX 32
35#define TPC_MAX_PER_GPC 8
36#define TPC_MAX (GPC_MAX * TPC_MAX_PER_GPC)
37
38#define ROP_BCAST(r) (0x408800 + (r))
39#define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r))
40#define GPC_BCAST(r) (0x418000 + (r))
41#define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r))
42#define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r))
43#define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
44
45struct gf100_gr_data {
46 u32 size;
47 u32 align;
48 bool priv;
49};
50
51struct gf100_gr_mmio {
52 u32 addr;
53 u32 data;
54 u32 shift;
55 int buffer;
56};
57
58struct gf100_gr_fuc {
59 u32 *data;
60 u32 size;
61};
62
63struct gf100_gr_zbc_color {
64 u32 format;
65 u32 ds[4];
66 u32 l2[4];
67};
68
69struct gf100_gr_zbc_depth {
70 u32 format;
71 u32 ds;
72 u32 l2;
73};
74
75struct gf100_gr_zbc_stencil {
76 u32 format;
77 u32 ds;
78 u32 l2;
79};
80
81struct gf100_gr {
82 const struct gf100_gr_func *func;
83 struct nvkm_gr base;
84
85 struct {
86 struct nvkm_falcon *falcon;
87 struct mutex mutex;
88 u32 disable;
89 } fecs;
90
91 struct {
92 struct nvkm_falcon *falcon;
93 } gpccs;
94
95 struct gf100_gr_fuc fuc409c;
96 struct gf100_gr_fuc fuc409d;
97 struct gf100_gr_fuc fuc41ac;
98 struct gf100_gr_fuc fuc41ad;
99 bool firmware;
100
101
102
103
104
105 struct gf100_gr_pack *fuc_sw_nonctx;
106 struct gf100_gr_pack *fuc_sw_ctx;
107 struct gf100_gr_pack *fuc_bundle;
108 struct gf100_gr_pack *fuc_method;
109
110 struct gf100_gr_zbc_color zbc_color[NVKM_LTC_MAX_ZBC_CNT];
111 struct gf100_gr_zbc_depth zbc_depth[NVKM_LTC_MAX_ZBC_CNT];
112 struct gf100_gr_zbc_stencil zbc_stencil[NVKM_LTC_MAX_ZBC_CNT];
113
114 u8 rop_nr;
115 u8 gpc_nr;
116 u8 tpc_nr[GPC_MAX];
117 u8 tpc_max;
118 u8 tpc_total;
119 u8 ppc_nr[GPC_MAX];
120 u8 ppc_mask[GPC_MAX];
121 u8 ppc_tpc_mask[GPC_MAX][4];
122 u8 ppc_tpc_nr[GPC_MAX][4];
123 u8 ppc_tpc_min;
124 u8 ppc_tpc_max;
125
126 u8 screen_tile_row_offset;
127 u8 tile[TPC_MAX];
128
129 struct {
130 u8 gpc;
131 u8 tpc;
132 } sm[TPC_MAX];
133 u8 sm_nr;
134
135 struct gf100_gr_data mmio_data[4];
136 struct gf100_gr_mmio mmio_list[4096/8];
137 u32 size;
138 u32 *data;
139 u32 size_zcull;
140 u32 size_pm;
141};
142
143int gf100_gr_ctor(const struct gf100_gr_func *, struct nvkm_device *,
144 int, struct gf100_gr *);
145int gf100_gr_new_(const struct gf100_gr_func *, struct nvkm_device *,
146 int, struct nvkm_gr **);
147void *gf100_gr_dtor(struct nvkm_gr *);
148
149int gf100_gr_fecs_bind_pointer(struct gf100_gr *, u32 inst);
150
151struct gf100_gr_func_zbc {
152 void (*clear_color)(struct gf100_gr *, int zbc);
153 void (*clear_depth)(struct gf100_gr *, int zbc);
154 int (*stencil_get)(struct gf100_gr *, int format,
155 const u32 ds, const u32 l2);
156 void (*clear_stencil)(struct gf100_gr *, int zbc);
157};
158
159struct gf100_gr_func {
160 void (*dtor)(struct gf100_gr *);
161 void (*oneinit_tiles)(struct gf100_gr *);
162 void (*oneinit_sm_id)(struct gf100_gr *);
163 int (*init)(struct gf100_gr *);
164 void (*init_419bd8)(struct gf100_gr *);
165 void (*init_gpc_mmu)(struct gf100_gr *);
166 void (*init_r405a14)(struct gf100_gr *);
167 void (*init_bios)(struct gf100_gr *);
168 void (*init_vsc_stream_master)(struct gf100_gr *);
169 void (*init_zcull)(struct gf100_gr *);
170 void (*init_num_active_ltcs)(struct gf100_gr *);
171 void (*init_rop_active_fbps)(struct gf100_gr *);
172 void (*init_bios_2)(struct gf100_gr *);
173 void (*init_swdx_pes_mask)(struct gf100_gr *);
174 void (*init_fecs_exceptions)(struct gf100_gr *);
175 void (*init_ds_hww_esr_2)(struct gf100_gr *);
176 void (*init_40601c)(struct gf100_gr *);
177 void (*init_sked_hww_esr)(struct gf100_gr *);
178 void (*init_419cc0)(struct gf100_gr *);
179 void (*init_419eb4)(struct gf100_gr *);
180 void (*init_419c9c)(struct gf100_gr *);
181 void (*init_ppc_exceptions)(struct gf100_gr *);
182 void (*init_tex_hww_esr)(struct gf100_gr *, int gpc, int tpc);
183 void (*init_504430)(struct gf100_gr *, int gpc, int tpc);
184 void (*init_shader_exceptions)(struct gf100_gr *, int gpc, int tpc);
185 void (*init_400054)(struct gf100_gr *);
186 void (*init_4188a4)(struct gf100_gr *);
187 void (*trap_mp)(struct gf100_gr *, int gpc, int tpc);
188 void (*set_hww_esr_report_mask)(struct gf100_gr *);
189 const struct gf100_gr_pack *mmio;
190 struct {
191 struct gf100_gr_ucode *ucode;
192 } fecs;
193 struct {
194 struct gf100_gr_ucode *ucode;
195 } gpccs;
196 int (*rops)(struct gf100_gr *);
197 int gpc_nr;
198 int tpc_nr;
199 int ppc_nr;
200 const struct gf100_grctx_func *grctx;
201 const struct nvkm_therm_clkgate_pack *clkgate_pack;
202 const struct gf100_gr_func_zbc *zbc;
203 struct nvkm_sclass sclass[];
204};
205
206int gf100_gr_rops(struct gf100_gr *);
207void gf100_gr_oneinit_tiles(struct gf100_gr *);
208void gf100_gr_oneinit_sm_id(struct gf100_gr *);
209int gf100_gr_init(struct gf100_gr *);
210void gf100_gr_init_vsc_stream_master(struct gf100_gr *);
211void gf100_gr_init_zcull(struct gf100_gr *);
212void gf100_gr_init_num_active_ltcs(struct gf100_gr *);
213void gf100_gr_init_fecs_exceptions(struct gf100_gr *);
214void gf100_gr_init_40601c(struct gf100_gr *);
215void gf100_gr_init_419cc0(struct gf100_gr *);
216void gf100_gr_init_419eb4(struct gf100_gr *);
217void gf100_gr_init_tex_hww_esr(struct gf100_gr *, int, int);
218void gf100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
219void gf100_gr_init_400054(struct gf100_gr *);
220extern const struct gf100_gr_func_zbc gf100_gr_zbc;
221
222void gf117_gr_init_zcull(struct gf100_gr *);
223
224void gk104_gr_init_vsc_stream_master(struct gf100_gr *);
225void gk104_gr_init_rop_active_fbps(struct gf100_gr *);
226void gk104_gr_init_ppc_exceptions(struct gf100_gr *);
227void gk104_gr_init_sked_hww_esr(struct gf100_gr *);
228
229void gk110_gr_init_419eb4(struct gf100_gr *);
230
231void gm107_gr_init_504430(struct gf100_gr *, int, int);
232void gm107_gr_init_shader_exceptions(struct gf100_gr *, int, int);
233void gm107_gr_init_400054(struct gf100_gr *);
234
235int gk20a_gr_init(struct gf100_gr *);
236
237void gm200_gr_oneinit_tiles(struct gf100_gr *);
238void gm200_gr_oneinit_sm_id(struct gf100_gr *);
239int gm200_gr_rops(struct gf100_gr *);
240void gm200_gr_init_num_active_ltcs(struct gf100_gr *);
241void gm200_gr_init_ds_hww_esr_2(struct gf100_gr *);
242
243void gp100_gr_init_rop_active_fbps(struct gf100_gr *);
244void gp100_gr_init_fecs_exceptions(struct gf100_gr *);
245void gp100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
246void gp100_gr_zbc_clear_color(struct gf100_gr *, int);
247void gp100_gr_zbc_clear_depth(struct gf100_gr *, int);
248
249void gp102_gr_init_swdx_pes_mask(struct gf100_gr *);
250extern const struct gf100_gr_func_zbc gp102_gr_zbc;
251
252#define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
253#include <core/object.h>
254
255struct gf100_gr_chan {
256 struct nvkm_object object;
257 struct gf100_gr *gr;
258 struct nvkm_vmm *vmm;
259
260 struct nvkm_memory *mmio;
261 struct nvkm_vma *mmio_vma;
262 int mmio_nr;
263
264 struct {
265 struct nvkm_memory *mem;
266 struct nvkm_vma *vma;
267 } data[4];
268};
269
270void gf100_gr_ctxctl_debug(struct gf100_gr *);
271
272void gf100_gr_dtor_fw(struct gf100_gr_fuc *);
273int gf100_gr_ctor_fw(struct gf100_gr *, const char *,
274 struct gf100_gr_fuc *);
275u64 gf100_gr_units(struct nvkm_gr *);
276void gf100_gr_zbc_init(struct gf100_gr *);
277
278extern const struct nvkm_object_func gf100_fermi;
279
280struct gf100_gr_init {
281 u32 addr;
282 u8 count;
283 u32 pitch;
284 u32 data;
285};
286
287struct gf100_gr_pack {
288 const struct gf100_gr_init *init;
289 u32 type;
290};
291
292#define pack_for_each_init(init, pack, head) \
293 for (pack = head; pack && pack->init; pack++) \
294 for (init = pack->init; init && init->count; init++)
295
296struct gf100_gr_ucode {
297 struct gf100_gr_fuc code;
298 struct gf100_gr_fuc data;
299};
300
301extern struct gf100_gr_ucode gf100_gr_fecs_ucode;
302extern struct gf100_gr_ucode gf100_gr_gpccs_ucode;
303
304extern struct gf100_gr_ucode gk110_gr_fecs_ucode;
305extern struct gf100_gr_ucode gk110_gr_gpccs_ucode;
306
307int gf100_gr_wait_idle(struct gf100_gr *);
308void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *);
309void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *);
310void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *);
311int gf100_gr_init_ctxctl(struct gf100_gr *);
312
313
314int gk20a_gr_av_to_init(struct gf100_gr *, const char *,
315 struct gf100_gr_pack **);
316int gk20a_gr_aiv_to_init(struct gf100_gr *, const char *,
317 struct gf100_gr_pack **);
318int gk20a_gr_av_to_method(struct gf100_gr *, const char *,
319 struct gf100_gr_pack **);
320
321int gm200_gr_new_(const struct gf100_gr_func *, struct nvkm_device *, int,
322 struct nvkm_gr **);
323
324
325
326extern const struct gf100_gr_init gf100_gr_init_main_0[];
327extern const struct gf100_gr_init gf100_gr_init_fe_0[];
328extern const struct gf100_gr_init gf100_gr_init_pri_0[];
329extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[];
330extern const struct gf100_gr_init gf100_gr_init_pd_0[];
331extern const struct gf100_gr_init gf100_gr_init_ds_0[];
332extern const struct gf100_gr_init gf100_gr_init_scc_0[];
333extern const struct gf100_gr_init gf100_gr_init_prop_0[];
334extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[];
335extern const struct gf100_gr_init gf100_gr_init_setup_0[];
336extern const struct gf100_gr_init gf100_gr_init_crstr_0[];
337extern const struct gf100_gr_init gf100_gr_init_setup_1[];
338extern const struct gf100_gr_init gf100_gr_init_zcull_0[];
339extern const struct gf100_gr_init gf100_gr_init_gpm_0[];
340extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[];
341extern const struct gf100_gr_init gf100_gr_init_gcc_0[];
342extern const struct gf100_gr_init gf100_gr_init_tpccs_0[];
343extern const struct gf100_gr_init gf100_gr_init_tex_0[];
344extern const struct gf100_gr_init gf100_gr_init_pe_0[];
345extern const struct gf100_gr_init gf100_gr_init_l1c_0[];
346extern const struct gf100_gr_init gf100_gr_init_wwdx_0[];
347extern const struct gf100_gr_init gf100_gr_init_tpccs_1[];
348extern const struct gf100_gr_init gf100_gr_init_mpc_0[];
349extern const struct gf100_gr_init gf100_gr_init_be_0[];
350extern const struct gf100_gr_init gf100_gr_init_fe_1[];
351extern const struct gf100_gr_init gf100_gr_init_pe_1[];
352void gf100_gr_init_gpc_mmu(struct gf100_gr *);
353void gf100_gr_trap_mp(struct gf100_gr *, int, int);
354extern const struct nvkm_bitfield gf100_mp_global_error[];
355extern const struct nvkm_enum gf100_mp_warp_error[];
356
357extern const struct gf100_gr_init gf104_gr_init_ds_0[];
358extern const struct gf100_gr_init gf104_gr_init_tex_0[];
359extern const struct gf100_gr_init gf104_gr_init_sm_0[];
360
361extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[];
362extern const struct gf100_gr_init gf108_gr_init_setup_1[];
363
364extern const struct gf100_gr_init gf119_gr_init_pd_0[];
365extern const struct gf100_gr_init gf119_gr_init_ds_0[];
366extern const struct gf100_gr_init gf119_gr_init_prop_0[];
367extern const struct gf100_gr_init gf119_gr_init_gpm_0[];
368extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[];
369extern const struct gf100_gr_init gf119_gr_init_tex_0[];
370extern const struct gf100_gr_init gf119_gr_init_sm_0[];
371extern const struct gf100_gr_init gf119_gr_init_fe_1[];
372
373extern const struct gf100_gr_init gf117_gr_init_pes_0[];
374extern const struct gf100_gr_init gf117_gr_init_wwdx_0[];
375extern const struct gf100_gr_init gf117_gr_init_cbm_0[];
376
377extern const struct gf100_gr_init gk104_gr_init_main_0[];
378extern const struct gf100_gr_init gk104_gr_init_gpc_unk_2[];
379extern const struct gf100_gr_init gk104_gr_init_tpccs_0[];
380extern const struct gf100_gr_init gk104_gr_init_pe_0[];
381extern const struct gf100_gr_init gk104_gr_init_be_0[];
382extern const struct gf100_gr_pack gk104_gr_pack_mmio[];
383
384extern const struct gf100_gr_init gk110_gr_init_fe_0[];
385extern const struct gf100_gr_init gk110_gr_init_ds_0[];
386extern const struct gf100_gr_init gk110_gr_init_sked_0[];
387extern const struct gf100_gr_init gk110_gr_init_cwd_0[];
388extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[];
389extern const struct gf100_gr_init gk110_gr_init_tex_0[];
390extern const struct gf100_gr_init gk110_gr_init_sm_0[];
391
392extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[];
393
394extern const struct gf100_gr_init gm107_gr_init_scc_0[];
395extern const struct gf100_gr_init gm107_gr_init_prop_0[];
396extern const struct gf100_gr_init gm107_gr_init_setup_1[];
397extern const struct gf100_gr_init gm107_gr_init_zcull_0[];
398extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[];
399extern const struct gf100_gr_init gm107_gr_init_tex_0[];
400extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
401extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
402extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
403void gm107_gr_init_bios(struct gf100_gr *);
404
405void gm200_gr_init_gpc_mmu(struct gf100_gr *);
406#endif
407