1 /* SPDX-License-Identifier: MIT */ 2 #ifndef __NVKM_FIFO_PRIV_H__ 3 #define __NVKM_FIFO_PRIV_H__ 4 #define nvkm_fifo(p) container_of((p), struct nvkm_fifo, engine) 5 #include <engine/fifo.h> 6 #include <core/enum.h> 7 struct nvkm_cgrp; 8 struct nvkm_engn; 9 struct nvkm_memory; 10 struct nvkm_runl; 11 struct nvkm_runq; 12 struct gk104_fifo; 13 14 struct nvkm_fifo_chan_oclass; 15 struct nvkm_fifo_func { 16 void *(*dtor)(struct nvkm_fifo *); 17 18 int (*oneinit)(struct nvkm_fifo *); 19 int (*chid_nr)(struct nvkm_fifo *); 20 int (*chid_ctor)(struct nvkm_fifo *, int nr); 21 int (*runq_nr)(struct nvkm_fifo *); 22 int (*runl_ctor)(struct nvkm_fifo *); 23 24 void (*init)(struct nvkm_fifo *); 25 void (*init_pbdmas)(struct nvkm_fifo *, u32 mask); 26 27 irqreturn_t (*intr)(struct nvkm_inth *); 28 void (*intr_mmu_fault_unit)(struct nvkm_fifo *, int unit); 29 void (*intr_ctxsw_timeout)(struct nvkm_fifo *, u32 engm); 30 31 const struct nvkm_fifo_func_mmu_fault { 32 void (*recover)(struct nvkm_fifo *, struct nvkm_fault_data *); 33 const struct nvkm_enum *access; 34 const struct nvkm_enum *engine; 35 const struct nvkm_enum *reason; 36 const struct nvkm_enum *hubclient; 37 const struct nvkm_enum *gpcclient; 38 } *mmu_fault; 39 40 int (*engine_id)(struct nvkm_fifo *, struct nvkm_engine *); 41 void (*pause)(struct nvkm_fifo *, unsigned long *); 42 void (*start)(struct nvkm_fifo *, unsigned long *); 43 44 const struct nvkm_event_func *nonstall; 45 46 const struct nvkm_runl_func *runl; 47 const struct nvkm_runq_func *runq; 48 const struct nvkm_engn_func *engn; 49 const struct nvkm_engn_func *engn_sw; 50 const struct nvkm_engn_func *engn_ce; 51 52 struct nvkm_fifo_func_cgrp { 53 struct nvkm_sclass user; 54 const struct nvkm_cgrp_func *func; 55 bool force; 56 } cgrp; 57 58 struct nvkm_fifo_func_chan { 59 struct nvkm_sclass user; 60 const struct nvkm_chan_func *func; 61 const struct nvkm_fifo_chan_oclass { 62 int (*ctor)(struct nvkm_fifo *, const struct nvkm_oclass *, 63 void *data, u32 size, struct nvkm_object **); 64 } *oclass; 65 int (*ctor)(struct gk104_fifo *, const struct nvkm_oclass *, void *, u32, 66 struct nvkm_object **); 67 } chan; 68 }; 69 70 int nvkm_fifo_ctor(const struct nvkm_fifo_func *, struct nvkm_device *, enum nvkm_subdev_type, int, 71 struct nvkm_fifo *); 72 73 int nv04_fifo_chid_ctor(struct nvkm_fifo *, int); 74 int nv04_fifo_runl_ctor(struct nvkm_fifo *); 75 void nv04_fifo_init(struct nvkm_fifo *); 76 irqreturn_t nv04_fifo_intr(struct nvkm_inth *); 77 int nv04_fifo_engine_id(struct nvkm_fifo *, struct nvkm_engine *); 78 void nv04_fifo_pause(struct nvkm_fifo *, unsigned long *); 79 void nv04_fifo_start(struct nvkm_fifo *, unsigned long *); 80 extern const struct nvkm_runl_func nv04_runl; 81 extern const struct nvkm_engn_func nv04_engn; 82 extern const struct nvkm_cgrp_func nv04_cgrp; 83 extern const struct nvkm_chan_func_inst nv04_chan_inst; 84 void nv04_chan_start(struct nvkm_chan *); 85 void nv04_chan_stop(struct nvkm_chan *); 86 87 int nv10_fifo_chid_nr(struct nvkm_fifo *); 88 89 int nv50_fifo_chid_nr(struct nvkm_fifo *); 90 int nv50_fifo_chid_ctor(struct nvkm_fifo *, int); 91 void nv50_fifo_init(struct nvkm_fifo *); 92 extern const struct nvkm_runl_func nv50_runl; 93 int nv50_runl_update(struct nvkm_runl *); 94 int nv50_runl_wait(struct nvkm_runl *); 95 extern const struct nvkm_engn_func nv50_engn_sw; 96 extern const struct nvkm_chan_func_inst nv50_chan_inst; 97 void nv50_chan_unbind(struct nvkm_chan *); 98 void nv50_chan_start(struct nvkm_chan *); 99 void nv50_chan_stop(struct nvkm_chan *); 100 void nv50_chan_preempt(struct nvkm_chan *); 101 102 extern const struct nvkm_event_func g84_fifo_nonstall; 103 extern const struct nvkm_engn_func g84_engn; 104 extern const struct nvkm_chan_func g84_chan; 105 106 int gf100_fifo_chid_ctor(struct nvkm_fifo *, int); 107 int gf100_fifo_runq_nr(struct nvkm_fifo *); 108 bool gf100_fifo_intr_pbdma(struct nvkm_fifo *); 109 void gf100_fifo_intr_mmu_fault(struct nvkm_fifo *); 110 void gf100_fifo_intr_mmu_fault_unit(struct nvkm_fifo *, int); 111 void gf100_fifo_intr_sched(struct nvkm_fifo *); 112 void gf100_fifo_intr_ctxsw_timeout(struct nvkm_fifo *, u32); 113 void gf100_fifo_mmu_fault_recover(struct nvkm_fifo *, struct nvkm_fault_data *); 114 extern const struct nvkm_enum gf100_fifo_mmu_fault_access[]; 115 extern const struct nvkm_event_func gf100_fifo_nonstall; 116 bool gf100_runl_preempt_pending(struct nvkm_runl *); 117 void gf100_runq_init(struct nvkm_runq *); 118 bool gf100_runq_intr(struct nvkm_runq *, struct nvkm_runl *); 119 void gf100_engn_mmu_fault_trigger(struct nvkm_engn *); 120 bool gf100_engn_mmu_fault_triggered(struct nvkm_engn *); 121 extern const struct nvkm_engn_func gf100_engn_sw; 122 extern const struct nvkm_chan_func_inst gf100_chan_inst; 123 void gf100_chan_preempt(struct nvkm_chan *); 124 125 int gk104_fifo_chid_nr(struct nvkm_fifo *); 126 int gk104_fifo_runl_ctor(struct nvkm_fifo *); 127 void gk104_fifo_init_pbdmas(struct nvkm_fifo *, u32); 128 irqreturn_t gk104_fifo_intr(struct nvkm_inth *); 129 void gk104_fifo_intr_runlist(struct nvkm_fifo *); 130 void gk104_fifo_intr_chsw(struct nvkm_fifo *); 131 void gk104_fifo_intr_bind(struct nvkm_fifo *); 132 extern const struct nvkm_fifo_func_mmu_fault gk104_fifo_mmu_fault; 133 extern const struct nvkm_enum gk104_fifo_mmu_fault_reason[]; 134 extern const struct nvkm_enum gk104_fifo_mmu_fault_hubclient[]; 135 extern const struct nvkm_enum gk104_fifo_mmu_fault_gpcclient[]; 136 int gk104_fifo_engine_id(struct nvkm_fifo *, struct nvkm_engine *); 137 void gk104_runl_insert_chan(struct nvkm_chan *, struct nvkm_memory *, u64); 138 void gk104_runl_commit(struct nvkm_runl *, struct nvkm_memory *, u32, int); 139 bool gk104_runl_pending(struct nvkm_runl *); 140 void gk104_runl_block(struct nvkm_runl *, u32); 141 void gk104_runl_allow(struct nvkm_runl *, u32); 142 void gk104_runl_fault_clear(struct nvkm_runl *); 143 extern const struct nvkm_runq_func gk104_runq; 144 void gk104_runq_init(struct nvkm_runq *); 145 bool gk104_runq_intr(struct nvkm_runq *, struct nvkm_runl *); 146 extern const struct nvkm_bitfield gk104_runq_intr_0_names[]; 147 bool gk104_runq_idle(struct nvkm_runq *); 148 extern const struct nvkm_engn_func gk104_engn; 149 bool gk104_engn_chsw(struct nvkm_engn *); 150 int gk104_engn_cxid(struct nvkm_engn *, bool *cgid); 151 extern const struct nvkm_engn_func gk104_engn_ce; 152 void gk104_chan_bind(struct nvkm_chan *); 153 void gk104_chan_bind_inst(struct nvkm_chan *); 154 void gk104_chan_unbind(struct nvkm_chan *); 155 void gk104_chan_start(struct nvkm_chan *); 156 void gk104_chan_stop(struct nvkm_chan *); 157 158 int gk110_fifo_chid_ctor(struct nvkm_fifo *, int); 159 extern const struct nvkm_runl_func gk110_runl; 160 extern const struct nvkm_cgrp_func gk110_cgrp; 161 void gk110_runl_insert_cgrp(struct nvkm_cgrp *, struct nvkm_memory *, u64); 162 extern const struct nvkm_chan_func gk110_chan; 163 void gk110_chan_preempt(struct nvkm_chan *); 164 165 extern const struct nvkm_runq_func gk208_runq; 166 void gk208_runq_init(struct nvkm_runq *); 167 168 void gm107_fifo_intr_mmu_fault_unit(struct nvkm_fifo *, int); 169 extern const struct nvkm_fifo_func_mmu_fault gm107_fifo_mmu_fault; 170 extern const struct nvkm_runl_func gm107_runl; 171 extern const struct nvkm_chan_func gm107_chan; 172 173 int gm200_fifo_chid_nr(struct nvkm_fifo *); 174 int gm200_fifo_runq_nr(struct nvkm_fifo *); 175 176 extern const struct nvkm_enum gv100_fifo_mmu_fault_access[]; 177 extern const struct nvkm_enum gv100_fifo_mmu_fault_reason[]; 178 extern const struct nvkm_enum gv100_fifo_mmu_fault_hubclient[]; 179 extern const struct nvkm_enum gv100_fifo_mmu_fault_gpcclient[]; 180 void gv100_runl_insert_cgrp(struct nvkm_cgrp *, struct nvkm_memory *, u64); 181 void gv100_runl_insert_chan(struct nvkm_chan *, struct nvkm_memory *, u64); 182 void gv100_runl_preempt(struct nvkm_runl *); 183 extern const struct nvkm_runq_func gv100_runq; 184 extern const struct nvkm_engn_func gv100_engn; 185 extern const struct nvkm_engn_func gv100_engn_ce; 186 187 void tu102_fifo_intr_ctxsw_timeout_info(struct nvkm_engn *, u32 info); 188 extern const struct nvkm_fifo_func_mmu_fault tu102_fifo_mmu_fault; 189 190 int nvkm_uchan_new(struct nvkm_fifo *, struct nvkm_cgrp *, const struct nvkm_oclass *, 191 void *argv, u32 argc, struct nvkm_object **); 192 #endif 193