Merge tag 'armsoc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[cascardo/linux.git] / drivers / gpu / drm / nouveau / nvkm / engine / fifo / gk104.h
1 #ifndef __GK104_FIFO_H__
2 #define __GK104_FIFO_H__
3 #define gk104_fifo(p) container_of((p), struct gk104_fifo, base)
4 #include "priv.h"
5
6 #include <subdev/mmu.h>
7
8 struct gk104_fifo_chan;
9 struct gk104_fifo_engn {
10         struct nvkm_memory *runlist[2];
11         int cur_runlist;
12         wait_queue_head_t wait;
13         struct list_head chan;
14 };
15
16 struct gk104_fifo {
17         struct nvkm_fifo base;
18
19         struct work_struct fault;
20         u64 mask;
21
22         struct gk104_fifo_engn engine[7];
23         struct {
24                 struct nvkm_memory *mem;
25                 struct nvkm_vma bar;
26         } user;
27         int spoon_nr;
28 };
29
30 int gk104_fifo_new_(const struct nvkm_fifo_func *, struct nvkm_device *,
31                     int index, int nr, struct nvkm_fifo **);
32 void *gk104_fifo_dtor(struct nvkm_fifo *);
33 int gk104_fifo_oneinit(struct nvkm_fifo *);
34 void gk104_fifo_init(struct nvkm_fifo *);
35 void gk104_fifo_fini(struct nvkm_fifo *);
36 void gk104_fifo_intr(struct nvkm_fifo *);
37 void gk104_fifo_uevent_init(struct nvkm_fifo *);
38 void gk104_fifo_uevent_fini(struct nvkm_fifo *);
39 void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *);
40 void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
41 void gk104_fifo_runlist_commit(struct gk104_fifo *, u32 engine);
42
43 static inline u64
44 gk104_fifo_engine_subdev(int engine)
45 {
46         switch (engine) {
47         case 0: return (1ULL << NVKM_ENGINE_GR) |
48                        (1ULL << NVKM_ENGINE_SW) |
49                        (1ULL << NVKM_ENGINE_CE2);
50         case 1: return (1ULL << NVKM_ENGINE_MSPDEC);
51         case 2: return (1ULL << NVKM_ENGINE_MSPPP);
52         case 3: return (1ULL << NVKM_ENGINE_MSVLD);
53         case 4: return (1ULL << NVKM_ENGINE_CE0);
54         case 5: return (1ULL << NVKM_ENGINE_CE1);
55         case 6: return (1ULL << NVKM_ENGINE_MSENC);
56         default:
57                 WARN_ON(1);
58                 return 0;
59         }
60 }
61
62 static inline int
63 gk104_fifo_subdev_engine(int subdev)
64 {
65         switch (subdev) {
66         case NVKM_ENGINE_GR:
67         case NVKM_ENGINE_SW:
68         case NVKM_ENGINE_CE2   : return 0;
69         case NVKM_ENGINE_MSPDEC: return 1;
70         case NVKM_ENGINE_MSPPP : return 2;
71         case NVKM_ENGINE_MSVLD : return 3;
72         case NVKM_ENGINE_CE0   : return 4;
73         case NVKM_ENGINE_CE1   : return 5;
74         case NVKM_ENGINE_MSENC : return 6;
75         default:
76                 WARN_ON(1);
77                 return 0;
78         }
79 }
80 #endif