Linux Audio

Check our new training course

Loading...
  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
 34struct 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
 47struct gf100_gr_zbc_color {
 48	u32 format;
 49	u32 ds[4];
 50	u32 l2[4];
 51};
 52
 53struct gf100_gr_zbc_depth {
 54	u32 format;
 55	u32 ds;
 56	u32 l2;
 57};
 58
 59struct gf100_gr_zbc_stencil {
 60	u32 format;
 61	u32 ds;
 62	u32 l2;
 63};
 64
 65struct 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
138int gf100_gr_fecs_bind_pointer(struct gf100_gr *, u32 inst);
139int gf100_gr_fecs_wfi_golden_save(struct gf100_gr *, u32 inst);
140
141struct 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
149struct 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
203int gf100_gr_rops(struct gf100_gr *);
204void gf100_gr_oneinit_tiles(struct gf100_gr *);
205int gf100_gr_oneinit_sm_id(struct gf100_gr *);
206int gf100_gr_init(struct gf100_gr *);
207void gf100_gr_init_vsc_stream_master(struct gf100_gr *);
208void gf100_gr_init_zcull(struct gf100_gr *);
209void gf100_gr_init_num_active_ltcs(struct gf100_gr *);
210void gf100_gr_init_fecs_exceptions(struct gf100_gr *);
211void gf100_gr_init_40601c(struct gf100_gr *);
212void gf100_gr_init_419cc0(struct gf100_gr *);
213void gf100_gr_init_419eb4(struct gf100_gr *);
214void gf100_gr_init_tex_hww_esr(struct gf100_gr *, int, int);
215void gf100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
216void gf100_gr_init_rop_exceptions(struct gf100_gr *);
217void gf100_gr_init_exception2(struct gf100_gr *);
218void gf100_gr_init_400054(struct gf100_gr *);
219void gf100_gr_init_num_tpc_per_gpc(struct gf100_gr *, bool, bool);
220extern const struct gf100_gr_func_zbc gf100_gr_zbc;
221void gf100_gr_fecs_reset(struct gf100_gr *);
222
223void gf117_gr_init_zcull(struct gf100_gr *);
224
225void gk104_gr_init_vsc_stream_master(struct gf100_gr *);
226void gk104_gr_init_rop_active_fbps(struct gf100_gr *);
227void gk104_gr_init_ppc_exceptions(struct gf100_gr *);
228void gk104_gr_init_sked_hww_esr(struct gf100_gr *);
229
230void gk110_gr_init_419eb4(struct gf100_gr *);
231
232void gm107_gr_init_504430(struct gf100_gr *, int, int);
233void gm107_gr_init_shader_exceptions(struct gf100_gr *, int, int);
234void gm107_gr_init_400054(struct gf100_gr *);
235
236int gk20a_gr_init(struct gf100_gr *);
237int gk20a_gr_av_to_init_(struct nvkm_blob *, u8 count, u32 pitch, struct gf100_gr_pack **);
238int gk20a_gr_av_to_init(struct nvkm_blob *, struct gf100_gr_pack **);
239int gk20a_gr_aiv_to_init(struct nvkm_blob *, struct gf100_gr_pack **);
240int gk20a_gr_av_to_method(struct nvkm_blob *, struct gf100_gr_pack **);
241
242void gm200_gr_oneinit_tiles(struct gf100_gr *);
243int gm200_gr_oneinit_sm_id(struct gf100_gr *);
244int gm200_gr_rops(struct gf100_gr *);
245void gm200_gr_init_num_active_ltcs(struct gf100_gr *);
246void gm200_gr_init_ds_hww_esr_2(struct gf100_gr *);
247
248void gp100_gr_init_rop_active_fbps(struct gf100_gr *);
249void gp100_gr_init_fecs_exceptions(struct gf100_gr *);
250void gp100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
251void gp100_gr_zbc_clear_color(struct gf100_gr *, int);
252void gp100_gr_zbc_clear_depth(struct gf100_gr *, int);
253extern const struct gf100_gr_func_zbc gp100_gr_zbc;
254
255void gp102_gr_init_swdx_pes_mask(struct gf100_gr *);
256extern const struct gf100_gr_func_zbc gp102_gr_zbc;
257int gp102_gr_zbc_stencil_get(struct gf100_gr *, int, const u32, const u32);
258void gp102_gr_zbc_clear_stencil(struct gf100_gr *, int);
259
260extern const struct gf100_gr_func gp107_gr;
261
262int gv100_gr_oneinit_sm_id(struct gf100_gr *);
263u32 gv100_gr_nonpes_aware_tpc(struct gf100_gr *gr, u32 gpc, u32 tpc);
264void gv100_gr_init_419bd8(struct gf100_gr *);
265void gv100_gr_init_504430(struct gf100_gr *, int, int);
266void gv100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
267void gv100_gr_init_4188a4(struct gf100_gr *);
268void gv100_gr_trap_mp(struct gf100_gr *, int, int);
269
270int tu102_gr_av_to_init_veid(struct nvkm_blob *, struct gf100_gr_pack **);
271void tu102_gr_init_zcull(struct gf100_gr *);
272void tu102_gr_init_fs(struct gf100_gr *);
273void 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
278struct 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
293void gf100_gr_ctxctl_debug(struct gf100_gr *);
294
295u64  gf100_gr_units(struct nvkm_gr *);
296void gf100_gr_zbc_init(struct gf100_gr *);
297
298extern const struct nvkm_object_func gf100_fermi;
299
300struct gf100_gr_init {
301	u32 addr;
302	u8  count;
303	u32 pitch;
304	u64 data;
305};
306
307struct 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
316struct gf100_gr_ucode {
317	struct nvkm_blob code;
318	struct nvkm_blob data;
319};
320
321extern struct gf100_gr_ucode gf100_gr_fecs_ucode;
322extern struct gf100_gr_ucode gf100_gr_gpccs_ucode;
323
324extern struct gf100_gr_ucode gk110_gr_fecs_ucode;
325extern struct gf100_gr_ucode gk110_gr_gpccs_ucode;
326
327int  gf100_gr_wait_idle(struct gf100_gr *);
328void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *);
329void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *);
330void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *);
331int  gf100_gr_init_ctxctl(struct gf100_gr *);
332
333/* register init value lists */
334
335extern const struct gf100_gr_init gf100_gr_init_main_0[];
336extern const struct gf100_gr_init gf100_gr_init_fe_0[];
337extern const struct gf100_gr_init gf100_gr_init_pri_0[];
338extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[];
339extern const struct gf100_gr_init gf100_gr_init_pd_0[];
340extern const struct gf100_gr_init gf100_gr_init_ds_0[];
341extern const struct gf100_gr_init gf100_gr_init_scc_0[];
342extern const struct gf100_gr_init gf100_gr_init_prop_0[];
343extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[];
344extern const struct gf100_gr_init gf100_gr_init_setup_0[];
345extern const struct gf100_gr_init gf100_gr_init_crstr_0[];
346extern const struct gf100_gr_init gf100_gr_init_setup_1[];
347extern const struct gf100_gr_init gf100_gr_init_zcull_0[];
348extern const struct gf100_gr_init gf100_gr_init_gpm_0[];
349extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[];
350extern const struct gf100_gr_init gf100_gr_init_gcc_0[];
351extern const struct gf100_gr_init gf100_gr_init_tpccs_0[];
352extern const struct gf100_gr_init gf100_gr_init_tex_0[];
353extern const struct gf100_gr_init gf100_gr_init_pe_0[];
354extern const struct gf100_gr_init gf100_gr_init_l1c_0[];
355extern const struct gf100_gr_init gf100_gr_init_wwdx_0[];
356extern const struct gf100_gr_init gf100_gr_init_tpccs_1[];
357extern const struct gf100_gr_init gf100_gr_init_mpc_0[];
358extern const struct gf100_gr_init gf100_gr_init_be_0[];
359extern const struct gf100_gr_init gf100_gr_init_fe_1[];
360extern const struct gf100_gr_init gf100_gr_init_pe_1[];
361void gf100_gr_init_gpc_mmu(struct gf100_gr *);
362void gf100_gr_trap_mp(struct gf100_gr *, int, int);
363extern const struct nvkm_bitfield gf100_mp_global_error[];
364extern const struct nvkm_enum gf100_mp_warp_error[];
365
366extern const struct gf100_gr_init gf104_gr_init_ds_0[];
367extern const struct gf100_gr_init gf104_gr_init_tex_0[];
368extern const struct gf100_gr_init gf104_gr_init_sm_0[];
369
370extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[];
371extern const struct gf100_gr_init gf108_gr_init_setup_1[];
372
373extern const struct gf100_gr_init gf119_gr_init_pd_0[];
374extern const struct gf100_gr_init gf119_gr_init_ds_0[];
375extern const struct gf100_gr_init gf119_gr_init_prop_0[];
376extern const struct gf100_gr_init gf119_gr_init_gpm_0[];
377extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[];
378extern const struct gf100_gr_init gf119_gr_init_tex_0[];
379extern const struct gf100_gr_init gf119_gr_init_sm_0[];
380extern const struct gf100_gr_init gf119_gr_init_fe_1[];
381
382extern const struct gf100_gr_init gf117_gr_init_pes_0[];
383extern const struct gf100_gr_init gf117_gr_init_wwdx_0[];
384extern const struct gf100_gr_init gf117_gr_init_cbm_0[];
385
386extern const struct gf100_gr_init gk104_gr_init_main_0[];
387extern const struct gf100_gr_init gk104_gr_init_gpc_unk_2[];
388extern const struct gf100_gr_init gk104_gr_init_tpccs_0[];
389extern const struct gf100_gr_init gk104_gr_init_pe_0[];
390extern const struct gf100_gr_init gk104_gr_init_be_0[];
391extern const struct gf100_gr_pack gk104_gr_pack_mmio[];
392
393extern const struct gf100_gr_init gk110_gr_init_fe_0[];
394extern const struct gf100_gr_init gk110_gr_init_ds_0[];
395extern const struct gf100_gr_init gk110_gr_init_sked_0[];
396extern const struct gf100_gr_init gk110_gr_init_cwd_0[];
397extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[];
398extern const struct gf100_gr_init gk110_gr_init_tex_0[];
399extern const struct gf100_gr_init gk110_gr_init_sm_0[];
400
401extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[];
402
403extern const struct gf100_gr_init gm107_gr_init_scc_0[];
404extern const struct gf100_gr_init gm107_gr_init_prop_0[];
405extern const struct gf100_gr_init gm107_gr_init_setup_1[];
406extern const struct gf100_gr_init gm107_gr_init_zcull_0[];
407extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[];
408extern const struct gf100_gr_init gm107_gr_init_tex_0[];
409extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
410extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
411extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
412void gm107_gr_init_bios(struct gf100_gr *);
413
414void gm200_gr_init_gpc_mmu(struct gf100_gr *);
415
416struct 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
424int gf100_gr_load(struct gf100_gr *, int, const struct gf100_gr_fwif *);
425int gf100_gr_nofw(struct gf100_gr *, int, const struct gf100_gr_fwif *);
426
427int gk20a_gr_load_sw(struct gf100_gr *, const char *path, int ver);
428int 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
432int gm200_gr_nofw(struct gf100_gr *, int, const struct gf100_gr_fwif *);
433int gm200_gr_load(struct gf100_gr *, int, const struct gf100_gr_fwif *);
434extern const struct nvkm_acr_lsf_func gm200_gr_gpccs_acr;
435extern const struct nvkm_acr_lsf_func gm200_gr_fecs_acr;
436
437extern const struct nvkm_acr_lsf_func gm20b_gr_fecs_acr;
438void gm20b_gr_acr_bld_write(struct nvkm_acr *, u32, struct nvkm_acr_lsfw *);
439void gm20b_gr_acr_bld_patch(struct nvkm_acr *, u32, s64);
440
441extern const struct nvkm_acr_lsf_func gp108_gr_gpccs_acr;
442extern const struct nvkm_acr_lsf_func gp108_gr_fecs_acr;
443void gp108_gr_acr_bld_write(struct nvkm_acr *, u32, struct nvkm_acr_lsfw *);
444void gp108_gr_acr_bld_patch(struct nvkm_acr *, u32, s64);
445
446int gf100_gr_new_(const struct gf100_gr_fwif *, struct nvkm_device *, enum nvkm_subdev_type, int,
447		  struct nvkm_gr **);
448int r535_gr_new(const struct gf100_gr_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
449		struct nvkm_gr **);
450#endif