1 #ifndef __NVKM_FIFO_H__
2 #define __NVKM_FIFO_H__
3 #include <core/namedb.h>
4 
5 struct nvkm_fifo_chan {
6 	struct nvkm_namedb namedb;
7 	struct nvkm_gpuobj *pushgpu;
8 	void __iomem *user;
9 	u64 addr;
10 	u32 size;
11 	u16 chid;
12 	u64 inst;
13 };
14 
15 static inline struct nvkm_fifo_chan *
16 nvkm_fifo_chan(void *obj)
17 {
18 	return (void *)nv_namedb(obj);
19 }
20 
21 #define nvkm_fifo_channel_create(p,e,c,b,a,s,n,m,d)                         \
22 	nvkm_fifo_channel_create_((p), (e), (c), (b), (a), (s), (n),        \
23 				     (m), sizeof(**d), (void **)d)
24 #define nvkm_fifo_channel_init(p)                                           \
25 	nvkm_namedb_init(&(p)->namedb)
26 #define nvkm_fifo_channel_fini(p,s)                                         \
27 	nvkm_namedb_fini(&(p)->namedb, (s))
28 
29 int  nvkm_fifo_channel_create_(struct nvkm_object *,
30 				  struct nvkm_object *,
31 				  struct nvkm_oclass *,
32 				  int bar, u32 addr, u32 size, u64 push,
33 				  u64 engmask, int len, void **);
34 void nvkm_fifo_channel_destroy(struct nvkm_fifo_chan *);
35 
36 #define _nvkm_fifo_channel_init _nvkm_namedb_init
37 #define _nvkm_fifo_channel_fini _nvkm_namedb_fini
38 
39 void _nvkm_fifo_channel_dtor(struct nvkm_object *);
40 int  _nvkm_fifo_channel_map(struct nvkm_object *, u64 *, u32 *);
41 u32  _nvkm_fifo_channel_rd32(struct nvkm_object *, u64);
42 void _nvkm_fifo_channel_wr32(struct nvkm_object *, u64, u32);
43 int  _nvkm_fifo_channel_ntfy(struct nvkm_object *, u32, struct nvkm_event **);
44 
45 #include <core/gpuobj.h>
46 
47 struct nvkm_fifo_base {
48 	struct nvkm_gpuobj gpuobj;
49 };
50 
51 #define nvkm_fifo_context_create(p,e,c,g,s,a,f,d)                           \
52 	nvkm_gpuobj_create((p), (e), (c), NV_ENGCTX_CLASS, (g), (s), (a), (f), (d))
53 #define nvkm_fifo_context_destroy(p)                                        \
54 	nvkm_gpuobj_destroy(&(p)->gpuobj)
55 #define nvkm_fifo_context_init(p)                                           \
56 	nvkm_gpuobj_init(&(p)->gpuobj)
57 #define nvkm_fifo_context_fini(p,s)                                         \
58 	nvkm_gpuobj_fini(&(p)->gpuobj, (s))
59 
60 #define _nvkm_fifo_context_dtor _nvkm_gpuobj_dtor
61 #define _nvkm_fifo_context_init _nvkm_gpuobj_init
62 #define _nvkm_fifo_context_fini _nvkm_gpuobj_fini
63 #define _nvkm_fifo_context_rd32 _nvkm_gpuobj_rd32
64 #define _nvkm_fifo_context_wr32 _nvkm_gpuobj_wr32
65 
66 #include <core/engine.h>
67 #include <core/event.h>
68 
69 struct nvkm_fifo {
70 	struct nvkm_engine engine;
71 
72 	struct nvkm_event cevent; /* channel creation event */
73 	struct nvkm_event uevent; /* async user trigger */
74 
75 	struct nvkm_object **channel;
76 	spinlock_t lock;
77 	u16 min;
78 	u16 max;
79 
80 	int  (*chid)(struct nvkm_fifo *, struct nvkm_object *);
81 	void (*pause)(struct nvkm_fifo *, unsigned long *);
82 	void (*start)(struct nvkm_fifo *, unsigned long *);
83 };
84 
85 void nvkm_fifo_chan_put(struct nvkm_fifo *, unsigned long flags,
86 			struct nvkm_fifo_chan **);
87 struct nvkm_fifo_chan *
88 nvkm_fifo_chan_inst(struct nvkm_fifo *, u64 inst, unsigned long *flags);
89 struct nvkm_fifo_chan *
90 nvkm_fifo_chan_chid(struct nvkm_fifo *, int chid, unsigned long *flags);
91 
92 static inline struct nvkm_fifo *
93 nvkm_fifo(void *obj)
94 {
95 	return (void *)nvkm_engine(obj, NVDEV_ENGINE_FIFO);
96 }
97 
98 #define nvkm_fifo_create(o,e,c,fc,lc,d)                                     \
99 	nvkm_fifo_create_((o), (e), (c), (fc), (lc), sizeof(**d), (void **)d)
100 #define nvkm_fifo_init(p)                                                   \
101 	nvkm_engine_init_old(&(p)->engine)
102 #define nvkm_fifo_fini(p,s)                                                 \
103 	nvkm_engine_fini_old(&(p)->engine, (s))
104 
105 int nvkm_fifo_create_(struct nvkm_object *, struct nvkm_object *,
106 			 struct nvkm_oclass *, int min, int max,
107 			 int size, void **);
108 void nvkm_fifo_destroy(struct nvkm_fifo *);
109 const char *
110 nvkm_client_name_for_fifo_chid(struct nvkm_fifo *fifo, u32 chid);
111 
112 #define _nvkm_fifo_init _nvkm_engine_init
113 #define _nvkm_fifo_fini _nvkm_engine_fini
114 
115 extern struct nvkm_oclass *nv04_fifo_oclass;
116 extern struct nvkm_oclass *nv10_fifo_oclass;
117 extern struct nvkm_oclass *nv17_fifo_oclass;
118 extern struct nvkm_oclass *nv40_fifo_oclass;
119 extern struct nvkm_oclass *nv50_fifo_oclass;
120 extern struct nvkm_oclass *g84_fifo_oclass;
121 extern struct nvkm_oclass *gf100_fifo_oclass;
122 extern struct nvkm_oclass *gk104_fifo_oclass;
123 extern struct nvkm_oclass *gk20a_fifo_oclass;
124 extern struct nvkm_oclass *gk208_fifo_oclass;
125 extern struct nvkm_oclass *gm204_fifo_oclass;
126 extern struct nvkm_oclass *gm20b_fifo_oclass;
127 
128 int  nvkm_fifo_uevent_ctor(struct nvkm_object *, void *, u32,
129 			   struct nvkm_notify *);
130 void nvkm_fifo_uevent(struct nvkm_fifo *);
131 
132 void nv04_fifo_intr(struct nvkm_subdev *);
133 int  nv04_fifo_context_attach(struct nvkm_object *, struct nvkm_object *);
134 #endif
135