Linux-libre 5.7.6-gnu
[librecmc/linux-libre.git] / drivers / gpu / drm / nouveau / nvkm / engine / fifo / gk104.h
1 /* SPDX-License-Identifier: MIT */
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         struct {
49                 void (*fault)(struct nvkm_fifo *, int unit);
50         } intr;
51
52         const struct gk104_fifo_pbdma_func {
53                 int (*nr)(struct gk104_fifo *);
54                 void (*init)(struct gk104_fifo *);
55                 void (*init_timeout)(struct gk104_fifo *);
56         } *pbdma;
57
58         struct {
59                 const struct nvkm_enum *access;
60                 const struct nvkm_enum *engine;
61                 const struct nvkm_enum *reason;
62                 const struct nvkm_enum *hubclient;
63                 const struct nvkm_enum *gpcclient;
64         } fault;
65
66         const struct gk104_fifo_runlist_func {
67                 u8 size;
68                 void (*cgrp)(struct nvkm_fifo_cgrp *,
69                              struct nvkm_memory *, u32 offset);
70                 void (*chan)(struct gk104_fifo_chan *,
71                              struct nvkm_memory *, u32 offset);
72                 void (*commit)(struct gk104_fifo *, int runl,
73                                struct nvkm_memory *, int entries);
74         } *runlist;
75
76         struct gk104_fifo_user_user {
77                 struct nvkm_sclass user;
78                 int (*ctor)(const struct nvkm_oclass *, void *, u32,
79                             struct nvkm_object **);
80         } user;
81
82         struct gk104_fifo_chan_user {
83                 struct nvkm_sclass user;
84                 int (*ctor)(struct gk104_fifo *, const struct nvkm_oclass *,
85                             void *, u32, struct nvkm_object **);
86         } chan;
87         bool cgrp_force;
88 };
89
90 int gk104_fifo_new_(const struct gk104_fifo_func *, struct nvkm_device *,
91                     int index, int nr, struct nvkm_fifo **);
92 void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *);
93 void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
94 void gk104_fifo_runlist_update(struct gk104_fifo *, int runl);
95
96 extern const struct gk104_fifo_pbdma_func gk104_fifo_pbdma;
97 int gk104_fifo_pbdma_nr(struct gk104_fifo *);
98 void gk104_fifo_pbdma_init(struct gk104_fifo *);
99 extern const struct nvkm_enum gk104_fifo_fault_access[];
100 extern const struct nvkm_enum gk104_fifo_fault_engine[];
101 extern const struct nvkm_enum gk104_fifo_fault_reason[];
102 extern const struct nvkm_enum gk104_fifo_fault_hubclient[];
103 extern const struct nvkm_enum gk104_fifo_fault_gpcclient[];
104 extern const struct gk104_fifo_runlist_func gk104_fifo_runlist;
105 void gk104_fifo_runlist_chan(struct gk104_fifo_chan *,
106                              struct nvkm_memory *, u32);
107 void gk104_fifo_runlist_commit(struct gk104_fifo *, int runl,
108                                struct nvkm_memory *, int);
109
110 extern const struct gk104_fifo_runlist_func gk110_fifo_runlist;
111 void gk110_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *,
112                              struct nvkm_memory *, u32);
113
114 extern const struct gk104_fifo_pbdma_func gk208_fifo_pbdma;
115 void gk208_fifo_pbdma_init_timeout(struct gk104_fifo *);
116
117 void gm107_fifo_intr_fault(struct nvkm_fifo *, int);
118 extern const struct nvkm_enum gm107_fifo_fault_engine[];
119 extern const struct gk104_fifo_runlist_func gm107_fifo_runlist;
120
121 extern const struct gk104_fifo_pbdma_func gm200_fifo_pbdma;
122 int gm200_fifo_pbdma_nr(struct gk104_fifo *);
123
124 void gp100_fifo_intr_fault(struct nvkm_fifo *, int);
125 extern const struct nvkm_enum gp100_fifo_fault_engine[];
126
127 extern const struct nvkm_enum gv100_fifo_fault_access[];
128 extern const struct nvkm_enum gv100_fifo_fault_reason[];
129 extern const struct nvkm_enum gv100_fifo_fault_hubclient[];
130 extern const struct nvkm_enum gv100_fifo_fault_gpcclient[];
131 void gv100_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *,
132                              struct nvkm_memory *, u32);
133 void gv100_fifo_runlist_chan(struct gk104_fifo_chan *,
134                              struct nvkm_memory *, u32);
135 #endif