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