1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __GK104_FIFO_H__
3 #define __GK104_FIFO_H__
4 #define gk104_fifo(p) container_of((p), struct gk104_fifo, base)
5 #include "priv.h"
6 struct nvkm_fifo_cgrp;
7 
8 #include <core/enum.h>
9 #include <subdev/mmu.h>
10 
11 struct gk104_fifo_chan;
12 struct gk104_fifo {
13 	const struct gk104_fifo_func *func;
14 	struct nvkm_fifo base;
15 
16 	struct {
17 		struct work_struct work;
18 		u32 engm;
19 		u32 runm;
20 	} recover;
21 
22 	int pbdma_nr;
23 
24 	struct {
25 		struct nvkm_engine *engine;
26 		int runl;
27 		int pbid;
28 	} engine[16];
29 	int engine_nr;
30 
31 	struct {
32 		struct nvkm_memory *mem[2];
33 		int next;
34 		wait_queue_head_t wait;
35 		struct list_head cgrp;
36 		struct list_head chan;
37 		u32 engm;
38 	} runlist[16];
39 	int runlist_nr;
40 
41 	struct {
42 		struct nvkm_memory *mem;
43 		struct nvkm_vma *bar;
44 	} user;
45 };
46 
47 struct gk104_fifo_func {
48 	void (*init_pbdma_timeout)(struct gk104_fifo *);
49 
50 	struct {
51 		const struct nvkm_enum *access;
52 		const struct nvkm_enum *engine;
53 		const struct nvkm_enum *reason;
54 		const struct nvkm_enum *hubclient;
55 		const struct nvkm_enum *gpcclient;
56 	} fault;
57 
58 	const struct gk104_fifo_runlist_func {
59 		u8 size;
60 		void (*cgrp)(struct nvkm_fifo_cgrp *,
61 			     struct nvkm_memory *, u32 offset);
62 		void (*chan)(struct gk104_fifo_chan *,
63 			     struct nvkm_memory *, u32 offset);
64 	} *runlist;
65 
66 	struct gk104_fifo_user_user {
67 		struct nvkm_sclass user;
68 		int (*ctor)(const struct nvkm_oclass *, void *, u32,
69 			    struct nvkm_object **);
70 	} user;
71 
72 	struct gk104_fifo_chan_user {
73 		struct nvkm_sclass user;
74 		int (*ctor)(struct gk104_fifo *, const struct nvkm_oclass *,
75 			    void *, u32, struct nvkm_object **);
76 	} chan;
77 	bool cgrp_force;
78 };
79 
80 int gk104_fifo_new_(const struct gk104_fifo_func *, struct nvkm_device *,
81 		    int index, int nr, struct nvkm_fifo **);
82 void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *);
83 void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
84 void gk104_fifo_runlist_commit(struct gk104_fifo *, int runl);
85 
86 extern const struct nvkm_enum gk104_fifo_fault_access[];
87 extern const struct nvkm_enum gk104_fifo_fault_engine[];
88 extern const struct nvkm_enum gk104_fifo_fault_reason[];
89 extern const struct nvkm_enum gk104_fifo_fault_hubclient[];
90 extern const struct nvkm_enum gk104_fifo_fault_gpcclient[];
91 extern const struct gk104_fifo_runlist_func gk104_fifo_runlist;
92 void gk104_fifo_runlist_chan(struct gk104_fifo_chan *,
93 			     struct nvkm_memory *, u32);
94 
95 extern const struct gk104_fifo_runlist_func gk110_fifo_runlist;
96 void gk110_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *,
97 			     struct nvkm_memory *, u32);
98 
99 void gk208_fifo_init_pbdma_timeout(struct gk104_fifo *);
100 
101 extern const struct nvkm_enum gm107_fifo_fault_engine[];
102 extern const struct gk104_fifo_runlist_func gm107_fifo_runlist;
103 
104 extern const struct nvkm_enum gp100_fifo_fault_engine[];
105 #endif
106