1 /* $NetBSD: gk104.h,v 1.5 2021/12/19 10:51:57 riastradh Exp $ */ 2 3 /* SPDX-License-Identifier: MIT */ 4 #ifndef __GK104_FIFO_H__ 5 #define __GK104_FIFO_H__ 6 #define gk104_fifo(p) container_of((p), struct gk104_fifo, base) 7 #include "priv.h" 8 struct nvkm_fifo_cgrp; 9 10 #include <core/enum.h> 11 #include <subdev/mmu.h> 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 #ifdef __NetBSD__ 37 spinlock_t lock; 38 drm_waitqueue_t wait; 39 #else 40 wait_queue_head_t wait; 41 #endif 42 struct list_head cgrp; 43 struct list_head chan; 44 u32 engm; 45 } runlist[16]; 46 int runlist_nr; 47 48 struct { 49 struct nvkm_memory *mem; 50 struct nvkm_vma *bar; 51 } user; 52 }; 53 54 struct gk104_fifo_func { 55 struct { 56 void (*fault)(struct nvkm_fifo *, int unit); 57 } intr; 58 59 const struct gk104_fifo_pbdma_func { 60 int (*nr)(struct gk104_fifo *); 61 void (*init)(struct gk104_fifo *); 62 void (*init_timeout)(struct gk104_fifo *); 63 } *pbdma; 64 65 struct { 66 const struct nvkm_enum *access; 67 const struct nvkm_enum *engine; 68 const struct nvkm_enum *reason; 69 const struct nvkm_enum *hubclient; 70 const struct nvkm_enum *gpcclient; 71 } fault; 72 73 const struct gk104_fifo_runlist_func { 74 u8 size; 75 void (*cgrp)(struct nvkm_fifo_cgrp *, 76 struct nvkm_memory *, u32 offset); 77 void (*chan)(struct gk104_fifo_chan *, 78 struct nvkm_memory *, u32 offset); 79 void (*commit)(struct gk104_fifo *, int runl, 80 struct nvkm_memory *, int entries); 81 } *runlist; 82 83 struct gk104_fifo_user_user { 84 struct nvkm_sclass user; 85 int (*ctor)(const struct nvkm_oclass *, void *, u32, 86 struct nvkm_object **); 87 } user; 88 89 struct gk104_fifo_chan_user { 90 struct nvkm_sclass user; 91 int (*ctor)(struct gk104_fifo *, const struct nvkm_oclass *, 92 void *, u32, struct nvkm_object **); 93 } chan; 94 bool cgrp_force; 95 }; 96 97 int gk104_fifo_new_(const struct gk104_fifo_func *, struct nvkm_device *, 98 int index, int nr, struct nvkm_fifo **); 99 void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *); 100 void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *); 101 void gk104_fifo_runlist_update(struct gk104_fifo *, int runl); 102 103 extern const struct gk104_fifo_pbdma_func gk104_fifo_pbdma; 104 int gk104_fifo_pbdma_nr(struct gk104_fifo *); 105 void gk104_fifo_pbdma_init(struct gk104_fifo *); 106 extern const struct nvkm_enum gk104_fifo_fault_access[]; 107 extern const struct nvkm_enum gk104_fifo_fault_engine[]; 108 extern const struct nvkm_enum gk104_fifo_fault_reason[]; 109 extern const struct nvkm_enum gk104_fifo_fault_hubclient[]; 110 extern const struct nvkm_enum gk104_fifo_fault_gpcclient[]; 111 extern const struct gk104_fifo_runlist_func gk104_fifo_runlist; 112 void gk104_fifo_runlist_chan(struct gk104_fifo_chan *, 113 struct nvkm_memory *, u32); 114 void gk104_fifo_runlist_commit(struct gk104_fifo *, int runl, 115 struct nvkm_memory *, int); 116 117 extern const struct gk104_fifo_runlist_func gk110_fifo_runlist; 118 void gk110_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *, 119 struct nvkm_memory *, u32); 120 121 extern const struct gk104_fifo_pbdma_func gk208_fifo_pbdma; 122 void gk208_fifo_pbdma_init_timeout(struct gk104_fifo *); 123 124 void gm107_fifo_intr_fault(struct nvkm_fifo *, int); 125 extern const struct nvkm_enum gm107_fifo_fault_engine[]; 126 extern const struct gk104_fifo_runlist_func gm107_fifo_runlist; 127 128 extern const struct gk104_fifo_pbdma_func gm200_fifo_pbdma; 129 int gm200_fifo_pbdma_nr(struct gk104_fifo *); 130 131 void gp100_fifo_intr_fault(struct nvkm_fifo *, int); 132 extern const struct nvkm_enum gp100_fifo_fault_engine[]; 133 134 extern const struct nvkm_enum gv100_fifo_fault_access[]; 135 extern const struct nvkm_enum gv100_fifo_fault_reason[]; 136 extern const struct nvkm_enum gv100_fifo_fault_hubclient[]; 137 extern const struct nvkm_enum gv100_fifo_fault_gpcclient[]; 138 void gv100_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *, 139 struct nvkm_memory *, u32); 140 void gv100_fifo_runlist_chan(struct gk104_fifo_chan *, 141 struct nvkm_memory *, u32); 142 #endif 143