Merge tag 'drm-for-v4.15' of git://people.freedesktop.org/~airlied/linux
[sfrench/cifs-2.6.git] / drivers / gpu / drm / nouveau / nvkm / engine / fifo / gk104.h
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
7 #include <core/enum.h>
8 #include <subdev/mmu.h>
9
10 struct gk104_fifo_chan;
11 struct gk104_fifo {
12         const struct gk104_fifo_func *func;
13         struct nvkm_fifo base;
14
15         struct {
16                 struct work_struct work;
17                 u32 engm;
18                 u32 runm;
19         } recover;
20
21         int pbdma_nr;
22
23         struct {
24                 struct nvkm_engine *engine;
25                 int runl;
26                 int pbid;
27         } engine[16];
28         int engine_nr;
29
30         struct {
31                 struct nvkm_memory *mem[2];
32                 int next;
33                 wait_queue_head_t wait;
34                 struct list_head chan;
35                 u32 engm;
36         } runlist[16];
37         int runlist_nr;
38
39         struct {
40                 struct nvkm_memory *mem;
41                 struct nvkm_vma *bar;
42         } user;
43 };
44
45 struct gk104_fifo_func {
46         struct {
47                 const struct nvkm_enum *engine;
48                 const struct nvkm_enum *reason;
49                 const struct nvkm_enum *hubclient;
50                 const struct nvkm_enum *gpcclient;
51         } fault;
52
53         const struct nvkm_fifo_chan_oclass *chan[];
54 };
55
56 int gk104_fifo_new_(const struct gk104_fifo_func *, struct nvkm_device *,
57                     int index, int nr, struct nvkm_fifo **);
58 void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *);
59 void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
60 void gk104_fifo_runlist_commit(struct gk104_fifo *, int runl);
61
62 static inline u64
63 gk104_fifo_engine_subdev(int engine)
64 {
65         switch (engine) {
66         case 0: return (1ULL << NVKM_ENGINE_GR) |
67                        (1ULL << NVKM_ENGINE_SW) |
68                        (1ULL << NVKM_ENGINE_CE2);
69         case 1: return (1ULL << NVKM_ENGINE_MSPDEC);
70         case 2: return (1ULL << NVKM_ENGINE_MSPPP);
71         case 3: return (1ULL << NVKM_ENGINE_MSVLD);
72         case 4: return (1ULL << NVKM_ENGINE_CE0);
73         case 5: return (1ULL << NVKM_ENGINE_CE1);
74         case 6: return (1ULL << NVKM_ENGINE_MSENC);
75         default:
76                 WARN_ON(1);
77                 return 0;
78         }
79 }
80
81 extern const struct nvkm_enum gk104_fifo_fault_engine[];
82 extern const struct nvkm_enum gk104_fifo_fault_reason[];
83 extern const struct nvkm_enum gk104_fifo_fault_hubclient[];
84 extern const struct nvkm_enum gk104_fifo_fault_gpcclient[];
85
86 extern const struct nvkm_enum gm107_fifo_fault_engine[];
87 extern const struct nvkm_enum gp100_fifo_fault_engine[];
88 #endif