1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_FIFO_H__
3 #define __NVKM_FIFO_H__
4 #include <core/engine.h>
5 #include <core/object.h>
6 #include <core/event.h>
7 struct nvkm_fault_data;
8 
9 #define NVKM_FIFO_CHID_NR 4096
10 
11 struct nvkm_fifo_engn {
12 	struct nvkm_object *object;
13 	int refcount;
14 	int usecount;
15 };
16 
17 struct nvkm_fifo_chan {
18 	const struct nvkm_fifo_chan_func *func;
19 	struct nvkm_fifo *fifo;
20 	u64 engines;
21 	struct nvkm_object object;
22 
23 	struct list_head head;
24 	u16 chid;
25 	struct nvkm_gpuobj *inst;
26 	struct nvkm_gpuobj *push;
27 	struct nvkm_vmm *vmm;
28 	void __iomem *user;
29 	u64 addr;
30 	u32 size;
31 
32 	struct nvkm_fifo_engn engn[NVKM_SUBDEV_NR];
33 };
34 
35 struct nvkm_fifo {
36 	const struct nvkm_fifo_func *func;
37 	struct nvkm_engine engine;
38 
39 	DECLARE_BITMAP(mask, NVKM_FIFO_CHID_NR);
40 	int nr;
41 	struct list_head chan;
42 	spinlock_t lock;
43 
44 	struct nvkm_event uevent; /* async user trigger */
45 	struct nvkm_event cevent; /* channel creation event */
46 	struct nvkm_event kevent; /* channel killed */
47 };
48 
49 void nvkm_fifo_fault(struct nvkm_fifo *, struct nvkm_fault_data *);
50 void nvkm_fifo_pause(struct nvkm_fifo *, unsigned long *);
51 void nvkm_fifo_start(struct nvkm_fifo *, unsigned long *);
52 
53 void nvkm_fifo_chan_put(struct nvkm_fifo *, unsigned long flags,
54 			struct nvkm_fifo_chan **);
55 struct nvkm_fifo_chan *
56 nvkm_fifo_chan_inst(struct nvkm_fifo *, u64 inst, unsigned long *flags);
57 struct nvkm_fifo_chan *
58 nvkm_fifo_chan_chid(struct nvkm_fifo *, int chid, unsigned long *flags);
59 
60 int nv04_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
61 int nv10_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
62 int nv17_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
63 int nv40_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
64 int nv50_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
65 int g84_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
66 int gf100_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
67 int gk104_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
68 int gk110_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
69 int gk208_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
70 int gk20a_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
71 int gm107_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
72 int gm200_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
73 int gm20b_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
74 int gp100_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
75 int gp10b_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
76 int gv100_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
77 int tu102_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
78 #endif
79