xref: /linux/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h (revision ae22a94997b8a03dcb3c922857c203246711f9d4)
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_FIFO_PRIV_H__
3 #define __NVKM_FIFO_PRIV_H__
4 #define nvkm_fifo(p) container_of((p), struct nvkm_fifo, engine)
5 #include <engine/fifo.h>
6 #include <core/enum.h>
7 struct nvkm_cctx;
8 struct nvkm_cgrp;
9 struct nvkm_engn;
10 struct nvkm_memory;
11 struct nvkm_runl;
12 struct nvkm_runq;
13 struct nvkm_vctx;
14 
15 struct nvkm_fifo_func {
16 	void (*dtor)(struct nvkm_fifo *);
17 
18 	int (*chid_nr)(struct nvkm_fifo *);
19 	int (*chid_ctor)(struct nvkm_fifo *, int nr);
20 	int (*runq_nr)(struct nvkm_fifo *);
21 	int (*runl_ctor)(struct nvkm_fifo *);
22 
23 	void (*init)(struct nvkm_fifo *);
24 	void (*init_pbdmas)(struct nvkm_fifo *, u32 mask);
25 
26 	irqreturn_t (*intr)(struct nvkm_inth *);
27 	void (*intr_mmu_fault_unit)(struct nvkm_fifo *, int unit);
28 	void (*intr_ctxsw_timeout)(struct nvkm_fifo *, u32 engm);
29 
30 	const struct nvkm_fifo_func_mmu_fault {
31 		void (*recover)(struct nvkm_fifo *, struct nvkm_fault_data *);
32 		const struct nvkm_enum *access;
33 		const struct nvkm_enum *engine;
34 		const struct nvkm_enum *reason;
35 		const struct nvkm_enum *hubclient;
36 		const struct nvkm_enum *gpcclient;
37 	} *mmu_fault;
38 
39 	void (*pause)(struct nvkm_fifo *, unsigned long *);
40 	void (*start)(struct nvkm_fifo *, unsigned long *);
41 
42 	int (*nonstall_ctor)(struct nvkm_fifo *);
43 	const struct nvkm_event_func *nonstall;
44 
45 	const struct nvkm_runl_func *runl;
46 	const struct nvkm_runq_func *runq;
47 	const struct nvkm_engn_func *engn;
48 	const struct nvkm_engn_func *engn_sw;
49 	const struct nvkm_engn_func *engn_ce;
50 
51 	struct nvkm_fifo_func_cgrp {
52 		struct nvkm_sclass user;
53 		const struct nvkm_cgrp_func *func;
54 		bool force;
55 	} cgrp;
56 
57 	struct nvkm_fifo_func_chan {
58 		struct nvkm_sclass user;
59 		const struct nvkm_chan_func *func;
60 	} chan;
61 };
62 
63 int r535_fifo_new(const struct nvkm_fifo_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
64 		  struct nvkm_fifo **);
65 int nvkm_fifo_new_(const struct nvkm_fifo_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
66 		   struct nvkm_fifo **);
67 
68 int nv04_fifo_chid_ctor(struct nvkm_fifo *, int);
69 int nv04_fifo_runl_ctor(struct nvkm_fifo *);
70 void nv04_fifo_init(struct nvkm_fifo *);
71 irqreturn_t nv04_fifo_intr(struct nvkm_inth *);
72 void nv04_fifo_pause(struct nvkm_fifo *, unsigned long *);
73 void nv04_fifo_start(struct nvkm_fifo *, unsigned long *);
74 extern const struct nvkm_runl_func nv04_runl;
75 extern const struct nvkm_engn_func nv04_engn;
76 extern const struct nvkm_cgrp_func nv04_cgrp;
77 extern const struct nvkm_chan_func_inst nv04_chan_inst;
78 extern const struct nvkm_chan_func_userd nv04_chan_userd;
79 void nv04_chan_ramfc_clear(struct nvkm_chan *);
80 void nv04_chan_start(struct nvkm_chan *);
81 void nv04_chan_stop(struct nvkm_chan *);
82 void nv04_eobj_ramht_del(struct nvkm_chan *, int);
83 
84 int nv10_fifo_chid_nr(struct nvkm_fifo *);
85 
86 int nv50_fifo_chid_nr(struct nvkm_fifo *);
87 int nv50_fifo_chid_ctor(struct nvkm_fifo *, int);
88 void nv50_fifo_init(struct nvkm_fifo *);
89 extern const struct nvkm_runl_func nv50_runl;
90 int nv50_runl_update(struct nvkm_runl *);
91 int nv50_runl_wait(struct nvkm_runl *);
92 extern const struct nvkm_engn_func nv50_engn_sw;
93 extern const struct nvkm_chan_func_inst nv50_chan_inst;
94 extern const struct nvkm_chan_func_userd nv50_chan_userd;
95 void nv50_chan_unbind(struct nvkm_chan *);
96 void nv50_chan_start(struct nvkm_chan *);
97 void nv50_chan_stop(struct nvkm_chan *);
98 void nv50_chan_preempt(struct nvkm_chan *);
99 int nv50_eobj_ramht_add(struct nvkm_engn *, struct nvkm_object *, struct nvkm_chan *);
100 void nv50_eobj_ramht_del(struct nvkm_chan *, int);
101 
102 extern const struct nvkm_event_func g84_fifo_nonstall;
103 extern const struct nvkm_engn_func g84_engn;
104 extern const struct nvkm_chan_func g84_chan;
105 
106 int gf100_fifo_chid_ctor(struct nvkm_fifo *, int);
107 int gf100_fifo_runq_nr(struct nvkm_fifo *);
108 bool gf100_fifo_intr_pbdma(struct nvkm_fifo *);
109 void gf100_fifo_intr_mmu_fault(struct nvkm_fifo *);
110 void gf100_fifo_intr_mmu_fault_unit(struct nvkm_fifo *, int);
111 void gf100_fifo_intr_sched(struct nvkm_fifo *);
112 void gf100_fifo_intr_ctxsw_timeout(struct nvkm_fifo *, u32);
113 void gf100_fifo_mmu_fault_recover(struct nvkm_fifo *, struct nvkm_fault_data *);
114 extern const struct nvkm_enum gf100_fifo_mmu_fault_access[];
115 extern const struct nvkm_event_func gf100_fifo_nonstall;
116 bool gf100_runl_preempt_pending(struct nvkm_runl *);
117 void gf100_runq_init(struct nvkm_runq *);
118 bool gf100_runq_intr(struct nvkm_runq *, struct nvkm_runl *);
119 void gf100_engn_mmu_fault_trigger(struct nvkm_engn *);
120 bool gf100_engn_mmu_fault_triggered(struct nvkm_engn *);
121 extern const struct nvkm_engn_func gf100_engn_sw;
122 extern const struct nvkm_chan_func_inst gf100_chan_inst;
123 void gf100_chan_userd_clear(struct nvkm_chan *);
124 void gf100_chan_preempt(struct nvkm_chan *);
125 
126 int gk104_fifo_chid_nr(struct nvkm_fifo *);
127 int gk104_fifo_runl_ctor(struct nvkm_fifo *);
128 void gk104_fifo_init(struct nvkm_fifo *);
129 void gk104_fifo_init_pbdmas(struct nvkm_fifo *, u32);
130 irqreturn_t gk104_fifo_intr(struct nvkm_inth *);
131 void gk104_fifo_intr_runlist(struct nvkm_fifo *);
132 void gk104_fifo_intr_chsw(struct nvkm_fifo *);
133 void gk104_fifo_intr_bind(struct nvkm_fifo *);
134 extern const struct nvkm_fifo_func_mmu_fault gk104_fifo_mmu_fault;
135 extern const struct nvkm_enum gk104_fifo_mmu_fault_reason[];
136 extern const struct nvkm_enum gk104_fifo_mmu_fault_hubclient[];
137 extern const struct nvkm_enum gk104_fifo_mmu_fault_gpcclient[];
138 void gk104_runl_insert_chan(struct nvkm_chan *, struct nvkm_memory *, u64);
139 void gk104_runl_commit(struct nvkm_runl *, struct nvkm_memory *, u32, int);
140 bool gk104_runl_pending(struct nvkm_runl *);
141 void gk104_runl_block(struct nvkm_runl *, u32);
142 void gk104_runl_allow(struct nvkm_runl *, u32);
143 void gk104_runl_fault_clear(struct nvkm_runl *);
144 extern const struct nvkm_runq_func gk104_runq;
145 void gk104_runq_init(struct nvkm_runq *);
146 bool gk104_runq_intr(struct nvkm_runq *, struct nvkm_runl *);
147 extern const struct nvkm_bitfield gk104_runq_intr_0_names[];
148 bool gk104_runq_idle(struct nvkm_runq *);
149 extern const struct nvkm_engn_func gk104_engn;
150 bool gk104_engn_chsw(struct nvkm_engn *);
151 int gk104_engn_cxid(struct nvkm_engn *, bool *cgid);
152 int gk104_ectx_ctor(struct nvkm_engn *, struct nvkm_vctx *);
153 extern const struct nvkm_engn_func gk104_engn_ce;
154 extern const struct nvkm_chan_func_userd gk104_chan_userd;
155 extern const struct nvkm_chan_func_ramfc gk104_chan_ramfc;
156 void gk104_chan_bind(struct nvkm_chan *);
157 void gk104_chan_bind_inst(struct nvkm_chan *);
158 void gk104_chan_unbind(struct nvkm_chan *);
159 void gk104_chan_start(struct nvkm_chan *);
160 void gk104_chan_stop(struct nvkm_chan *);
161 
162 int gk110_fifo_chid_ctor(struct nvkm_fifo *, int);
163 extern const struct nvkm_runl_func gk110_runl;
164 extern const struct nvkm_cgrp_func gk110_cgrp;
165 void gk110_runl_insert_cgrp(struct nvkm_cgrp *, struct nvkm_memory *, u64);
166 extern const struct nvkm_chan_func gk110_chan;
167 void gk110_chan_preempt(struct nvkm_chan *);
168 
169 extern const struct nvkm_runq_func gk208_runq;
170 void gk208_runq_init(struct nvkm_runq *);
171 
172 void gm107_fifo_intr_mmu_fault_unit(struct nvkm_fifo *, int);
173 extern const struct nvkm_fifo_func_mmu_fault gm107_fifo_mmu_fault;
174 extern const struct nvkm_runl_func gm107_runl;
175 extern const struct nvkm_chan_func gm107_chan;
176 
177 int gm200_fifo_chid_nr(struct nvkm_fifo *);
178 int gm200_fifo_runq_nr(struct nvkm_fifo *);
179 
180 extern const struct nvkm_enum gv100_fifo_mmu_fault_access[];
181 extern const struct nvkm_enum gv100_fifo_mmu_fault_reason[];
182 extern const struct nvkm_enum gv100_fifo_mmu_fault_hubclient[];
183 extern const struct nvkm_enum gv100_fifo_mmu_fault_gpcclient[];
184 void gv100_runl_insert_cgrp(struct nvkm_cgrp *, struct nvkm_memory *, u64);
185 void gv100_runl_insert_chan(struct nvkm_chan *, struct nvkm_memory *, u64);
186 void gv100_runl_preempt(struct nvkm_runl *);
187 extern const struct nvkm_runq_func gv100_runq;
188 extern const struct nvkm_engn_func gv100_engn;
189 void gv100_ectx_bind(struct nvkm_engn *, struct nvkm_cctx *, struct nvkm_chan *);
190 extern const struct nvkm_engn_func gv100_engn_ce;
191 int gv100_ectx_ce_ctor(struct nvkm_engn *, struct nvkm_vctx *);
192 void gv100_ectx_ce_bind(struct nvkm_engn *, struct nvkm_cctx *, struct nvkm_chan *);
193 extern const struct nvkm_chan_func_userd gv100_chan_userd;
194 extern const struct nvkm_chan_func_ramfc gv100_chan_ramfc;
195 
196 void tu102_fifo_intr_ctxsw_timeout_info(struct nvkm_engn *, u32 info);
197 extern const struct nvkm_fifo_func_mmu_fault tu102_fifo_mmu_fault;
198 
199 int ga100_fifo_runl_ctor(struct nvkm_fifo *);
200 int ga100_fifo_nonstall_ctor(struct nvkm_fifo *);
201 extern const struct nvkm_event_func ga100_fifo_nonstall;
202 extern const struct nvkm_runl_func ga100_runl;
203 extern const struct nvkm_runq_func ga100_runq;
204 extern const struct nvkm_engn_func ga100_engn;
205 extern const struct nvkm_engn_func ga100_engn_ce;
206 extern const struct nvkm_cgrp_func ga100_cgrp;
207 extern const struct nvkm_chan_func ga100_chan;
208 
209 int nvkm_uchan_new(struct nvkm_fifo *, struct nvkm_cgrp *, const struct nvkm_oclass *,
210 		   void *argv, u32 argc, struct nvkm_object **);
211 int nvkm_ucgrp_new(struct nvkm_fifo *, const struct nvkm_oclass *, void *argv, u32 argc,
212 		   struct nvkm_object **);
213 #endif
214