xref: /openbmc/linux/drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h (revision f48dd2936138882d7755cbbc5d9984015c75980c)
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_cgrp;
8 struct nvkm_memory;
9 struct nvkm_runl;
10 struct nvkm_runq;
11 struct gk104_fifo;
12 struct gk104_fifo_chan;
13 
14 void nvkm_fifo_kevent(struct nvkm_fifo *, int chid);
15 void nvkm_fifo_recover_chan(struct nvkm_fifo *, int chid);
16 
17 struct nvkm_fifo_chan_oclass;
18 struct nvkm_fifo_func {
19 	void *(*dtor)(struct nvkm_fifo *);
20 
21 	int (*oneinit)(struct nvkm_fifo *);
22 	int (*chid_nr)(struct nvkm_fifo *);
23 	int (*chid_ctor)(struct nvkm_fifo *, int nr);
24 	int (*runq_nr)(struct nvkm_fifo *);
25 	int (*runl_ctor)(struct nvkm_fifo *);
26 
27 	void (*init)(struct nvkm_fifo *);
28 	void (*init_pbdmas)(struct nvkm_fifo *, u32 mask);
29 
30 	void (*fini)(struct nvkm_fifo *);
31 
32 	irqreturn_t (*intr)(struct nvkm_inth *);
33 	void (*intr_mmu_fault_unit)(struct nvkm_fifo *, int unit);
34 
35 	const struct nvkm_fifo_func_mmu_fault {
36 		void (*recover)(struct nvkm_fifo *, struct nvkm_fault_data *);
37 		const struct nvkm_enum *access;
38 		const struct nvkm_enum *engine;
39 		const struct nvkm_enum *reason;
40 		const struct nvkm_enum *hubclient;
41 		const struct nvkm_enum *gpcclient;
42 	} *mmu_fault;
43 
44 	int (*engine_id)(struct nvkm_fifo *, struct nvkm_engine *);
45 	void (*pause)(struct nvkm_fifo *, unsigned long *);
46 	void (*start)(struct nvkm_fifo *, unsigned long *);
47 	void (*recover_chan)(struct nvkm_fifo *, int chid);
48 
49 	const struct gk104_fifo_runlist_func {
50 		u8 size;
51 		void (*cgrp)(struct nvkm_fifo_cgrp *,
52 			     struct nvkm_memory *, u32 offset);
53 		void (*chan)(struct gk104_fifo_chan *,
54 			     struct nvkm_memory *, u32 offset);
55 		void (*commit)(struct gk104_fifo *, int runl,
56 			       struct nvkm_memory *, int entries);
57 	} *runlist;
58 
59 	const struct nvkm_event_func *nonstall;
60 
61 	const struct nvkm_runl_func *runl;
62 	const struct nvkm_runq_func *runq;
63 	const struct nvkm_engn_func *engn;
64 	const struct nvkm_engn_func *engn_sw;
65 	const struct nvkm_engn_func *engn_ce;
66 
67 	struct nvkm_fifo_func_cgrp {
68 		struct nvkm_sclass user;
69 		const struct nvkm_cgrp_func *func;
70 		bool force;
71 	} cgrp;
72 
73 	struct nvkm_fifo_func_chan {
74 		struct nvkm_sclass user;
75 		const struct nvkm_chan_func *func;
76 		const struct nvkm_fifo_chan_oclass {
77 			int (*ctor)(struct nvkm_fifo *, const struct nvkm_oclass *,
78 			void *data, u32 size, struct nvkm_object **);
79 		} *oclass;
80 		int (*ctor)(struct gk104_fifo *, const struct nvkm_oclass *, void *, u32,
81 			    struct nvkm_object **);
82 	} chan;
83 };
84 
85 int nvkm_fifo_ctor(const struct nvkm_fifo_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
86 		   struct nvkm_fifo *);
87 
88 int nv04_fifo_chid_ctor(struct nvkm_fifo *, int);
89 int nv04_fifo_runl_ctor(struct nvkm_fifo *);
90 void nv04_fifo_init(struct nvkm_fifo *);
91 irqreturn_t nv04_fifo_intr(struct nvkm_inth *);
92 int nv04_fifo_engine_id(struct nvkm_fifo *, struct nvkm_engine *);
93 void nv04_fifo_pause(struct nvkm_fifo *, unsigned long *);
94 void nv04_fifo_start(struct nvkm_fifo *, unsigned long *);
95 extern const struct nvkm_runl_func nv04_runl;
96 extern const struct nvkm_engn_func nv04_engn;
97 extern const struct nvkm_cgrp_func nv04_cgrp;
98 
99 int nv10_fifo_chid_nr(struct nvkm_fifo *);
100 
101 int nv50_fifo_chid_nr(struct nvkm_fifo *);
102 int nv50_fifo_chid_ctor(struct nvkm_fifo *, int);
103 extern const struct nvkm_runl_func nv50_runl;
104 extern const struct nvkm_engn_func nv50_engn_sw;
105 
106 extern const struct nvkm_event_func g84_fifo_nonstall;
107 extern const struct nvkm_engn_func g84_engn;
108 extern const struct nvkm_chan_func g84_chan;
109 
110 int gf100_fifo_chid_ctor(struct nvkm_fifo *, int);
111 int gf100_fifo_runq_nr(struct nvkm_fifo *);
112 bool gf100_fifo_intr_pbdma(struct nvkm_fifo *);
113 void gf100_fifo_intr_mmu_fault(struct nvkm_fifo *);
114 void gf100_fifo_intr_mmu_fault_unit(struct nvkm_fifo *, int);
115 void gf100_fifo_mmu_fault_recover(struct nvkm_fifo *, struct nvkm_fault_data *);
116 extern const struct nvkm_enum gf100_fifo_mmu_fault_access[];
117 extern const struct nvkm_event_func gf100_fifo_nonstall;
118 void gf100_runq_init(struct nvkm_runq *);
119 bool gf100_runq_intr(struct nvkm_runq *, struct nvkm_runl *);
120 extern const struct nvkm_engn_func gf100_engn_sw;
121 
122 int gk104_fifo_chid_nr(struct nvkm_fifo *);
123 int gk104_fifo_runl_ctor(struct nvkm_fifo *);
124 void gk104_fifo_init_pbdmas(struct nvkm_fifo *, u32);
125 irqreturn_t gk104_fifo_intr(struct nvkm_inth *);
126 void gk104_fifo_intr_chsw(struct nvkm_fifo *);
127 void gk104_fifo_intr_bind(struct nvkm_fifo *);
128 extern const struct nvkm_fifo_func_mmu_fault gk104_fifo_mmu_fault;
129 extern const struct nvkm_enum gk104_fifo_mmu_fault_reason[];
130 extern const struct nvkm_enum gk104_fifo_mmu_fault_hubclient[];
131 extern const struct nvkm_enum gk104_fifo_mmu_fault_gpcclient[];
132 void gk104_fifo_recover_chan(struct nvkm_fifo *, int);
133 int gk104_fifo_engine_id(struct nvkm_fifo *, struct nvkm_engine *);
134 extern const struct nvkm_runq_func gk104_runq;
135 void gk104_runq_init(struct nvkm_runq *);
136 bool gk104_runq_intr(struct nvkm_runq *, struct nvkm_runl *);
137 extern const struct nvkm_bitfield gk104_runq_intr_0_names[];
138 extern const struct nvkm_engn_func gk104_engn;
139 extern const struct nvkm_engn_func gk104_engn_ce;
140 
141 int gk110_fifo_chid_ctor(struct nvkm_fifo *, int);
142 extern const struct nvkm_runl_func gk110_runl;
143 extern const struct nvkm_cgrp_func gk110_cgrp;
144 extern const struct nvkm_chan_func gk110_chan;
145 
146 extern const struct nvkm_runq_func gk208_runq;
147 void gk208_runq_init(struct nvkm_runq *);
148 
149 void gm107_fifo_intr_mmu_fault_unit(struct nvkm_fifo *, int);
150 extern const struct nvkm_fifo_func_mmu_fault gm107_fifo_mmu_fault;
151 extern const struct nvkm_runl_func gm107_runl;
152 extern const struct nvkm_chan_func gm107_chan;
153 
154 int gm200_fifo_chid_nr(struct nvkm_fifo *);
155 int gm200_fifo_runq_nr(struct nvkm_fifo *);
156 
157 extern const struct nvkm_enum gv100_fifo_mmu_fault_access[];
158 extern const struct nvkm_enum gv100_fifo_mmu_fault_reason[];
159 extern const struct nvkm_enum gv100_fifo_mmu_fault_hubclient[];
160 extern const struct nvkm_enum gv100_fifo_mmu_fault_gpcclient[];
161 extern const struct nvkm_runq_func gv100_runq;
162 extern const struct nvkm_engn_func gv100_engn;
163 extern const struct nvkm_engn_func gv100_engn_ce;
164 
165 extern const struct nvkm_fifo_func_mmu_fault tu102_fifo_mmu_fault;
166 
167 int nvkm_uchan_new(struct nvkm_fifo *, struct nvkm_cgrp *, const struct nvkm_oclass *,
168 		   void *argv, u32 argc, struct nvkm_object **);
169 #endif
170