drm/nouveau/fifo: tidy up non-stall intr handling
[linux-block.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 #define gk104_fifo_func nvkm_fifo_func
12
13 struct gk104_fifo_chan;
14 struct gk104_fifo {
15         const struct gk104_fifo_func *func;
16         struct nvkm_fifo base;
17
18         struct {
19                 struct work_struct work;
20                 u32 engm;
21                 u32 runm;
22         } recover;
23
24         int pbdma_nr;
25
26         struct {
27                 struct nvkm_engine *engine;
28                 int runl;
29                 int pbid;
30         } engine[16];
31         int engine_nr;
32
33         struct {
34                 struct nvkm_memory *mem[2];
35                 int next;
36                 wait_queue_head_t wait;
37                 struct list_head cgrp;
38                 struct list_head chan;
39                 u32 engm;
40                 u32 engm_sw;
41         } runlist[16];
42         int runlist_nr;
43
44         struct {
45                 struct nvkm_memory *mem;
46                 struct nvkm_vma *bar;
47         } user;
48 };
49
50 struct gk104_fifo_engine_status {
51         bool busy;
52         bool faulted;
53         bool chsw;
54         bool save;
55         bool load;
56         struct {
57                 bool tsg;
58                 u32 id;
59         } prev, next, *chan;
60 };
61
62 int gk104_fifo_new_(const struct gk104_fifo_func *, struct nvkm_device *, enum nvkm_subdev_type,
63                     int index, int nr, struct nvkm_fifo **);
64 void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *);
65 void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
66 void gk104_fifo_runlist_update(struct gk104_fifo *, int runl);
67 void gk104_fifo_engine_status(struct gk104_fifo *fifo, int engn,
68                               struct gk104_fifo_engine_status *status);
69 void gk104_fifo_intr_pbdma_0(struct gk104_fifo *fifo, int unit);
70 void gk104_fifo_intr_pbdma_1(struct gk104_fifo *fifo, int unit);
71 void gk104_fifo_intr_runlist(struct gk104_fifo *fifo);
72 void *gk104_fifo_dtor(struct nvkm_fifo *base);
73 int gk104_fifo_oneinit(struct nvkm_fifo *);
74 void gk104_fifo_init(struct nvkm_fifo *base);
75 void gk104_fifo_fini(struct nvkm_fifo *base);
76
77 extern const struct gk104_fifo_pbdma_func gk104_fifo_pbdma;
78 void gk104_fifo_pbdma_init(struct gk104_fifo *);
79 extern const struct nvkm_enum gk104_fifo_fault_access[];
80 extern const struct nvkm_enum gk104_fifo_fault_engine[];
81 extern const struct nvkm_enum gk104_fifo_fault_reason[];
82 extern const struct nvkm_enum gk104_fifo_fault_hubclient[];
83 extern const struct nvkm_enum gk104_fifo_fault_gpcclient[];
84 extern const struct gk104_fifo_runlist_func gk104_fifo_runlist;
85 void gk104_fifo_runlist_chan(struct gk104_fifo_chan *,
86                              struct nvkm_memory *, u32);
87 void gk104_fifo_runlist_commit(struct gk104_fifo *, int runl,
88                                struct nvkm_memory *, int);
89
90 extern const struct gk104_fifo_runlist_func gk110_fifo_runlist;
91 void gk110_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *,
92                              struct nvkm_memory *, u32);
93
94 extern const struct gk104_fifo_pbdma_func gk208_fifo_pbdma;
95 void gk208_fifo_pbdma_init_timeout(struct gk104_fifo *);
96
97 extern const struct nvkm_enum gm107_fifo_fault_engine[];
98 extern const struct gk104_fifo_runlist_func gm107_fifo_runlist;
99
100 extern const struct gk104_fifo_pbdma_func gm200_fifo_pbdma;
101
102 extern const struct nvkm_enum gp100_fifo_fault_engine[];
103
104 extern const struct nvkm_enum gv100_fifo_fault_access[];
105 extern const struct nvkm_enum gv100_fifo_fault_reason[];
106 extern const struct nvkm_enum gv100_fifo_fault_hubclient[];
107 extern const struct nvkm_enum gv100_fifo_fault_gpcclient[];
108 void gv100_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *,
109                              struct nvkm_memory *, u32);
110 void gv100_fifo_runlist_chan(struct gk104_fifo_chan *,
111                              struct nvkm_memory *, u32);
112 #endif