1 /* SPDX-License-Identifier: MIT 2 * 3 * Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. 4 */ 5 #include <subdev/gsp.h> 6 #ifndef __NVKM_RM_H__ 7 #define __NVKM_RM_H__ 8 #include "handles.h" 9 struct nvkm_ior; 10 struct nvkm_outp; 11 struct r535_gr; 12 13 struct nvkm_rm_impl { 14 const struct nvkm_rm_wpr *wpr; 15 const struct nvkm_rm_api *api; 16 }; 17 18 struct nvkm_rm { 19 struct nvkm_device *device; 20 const struct nvkm_rm_gpu *gpu; 21 const struct nvkm_rm_wpr *wpr; 22 const struct nvkm_rm_api *api; 23 }; 24 25 struct nvkm_rm_wpr { 26 u32 os_carveout_size; 27 u32 base_size; 28 u64 heap_size_min; 29 u32 heap_size_non_wpr; 30 u32 rsvd_size_pmu; 31 bool offset_set_by_acr; 32 }; 33 34 struct nvkm_rm_api { 35 const struct nvkm_rm_api_gsp { 36 void (*set_rmargs)(struct nvkm_gsp *, bool resume); 37 int (*set_system_info)(struct nvkm_gsp *); 38 int (*get_static_info)(struct nvkm_gsp *); 39 bool (*xlat_mc_engine_idx)(u32 mc_engine_idx, enum nvkm_subdev_type *, int *inst); 40 void (*drop_send_user_shared_data)(struct nvkm_gsp *); 41 void (*drop_post_nocat_record)(struct nvkm_gsp *); 42 u32 (*sr_data_size)(struct nvkm_gsp *); 43 } *gsp; 44 45 const struct nvkm_rm_api_rpc { 46 void *(*get)(struct nvkm_gsp *, u32 fn, u32 argc); 47 void *(*push)(struct nvkm_gsp *gsp, void *argv, 48 enum nvkm_gsp_rpc_reply_policy policy, u32 repc); 49 void (*done)(struct nvkm_gsp *gsp, void *repv); 50 } *rpc; 51 52 const struct nvkm_rm_api_ctrl { 53 void *(*get)(struct nvkm_gsp_object *, u32 cmd, u32 params_size); 54 int (*push)(struct nvkm_gsp_object *, void **params, u32 repc); 55 void (*done)(struct nvkm_gsp_object *, void *params); 56 } *ctrl; 57 58 const struct nvkm_rm_api_alloc { 59 void *(*get)(struct nvkm_gsp_object *, u32 oclass, u32 params_size); 60 void *(*push)(struct nvkm_gsp_object *, void *params); 61 void (*done)(struct nvkm_gsp_object *, void *params); 62 63 int (*free)(struct nvkm_gsp_object *); 64 } *alloc; 65 66 const struct nvkm_rm_api_client { 67 int (*ctor)(struct nvkm_gsp_client *, u32 handle); 68 } *client; 69 70 const struct nvkm_rm_api_device { 71 int (*ctor)(struct nvkm_gsp_client *, struct nvkm_gsp_device *); 72 void (*dtor)(struct nvkm_gsp_device *); 73 74 struct { 75 int (*ctor)(struct nvkm_gsp_device *, u32 handle, u32 id, 76 nvkm_gsp_event_func, struct nvkm_gsp_event *); 77 void (*dtor)(struct nvkm_gsp_event *); 78 } event; 79 } *device; 80 81 const struct nvkm_rm_api_fbsr { 82 int (*suspend)(struct nvkm_gsp *); 83 void (*resume)(struct nvkm_gsp *); 84 } *fbsr; 85 86 const struct nvkm_rm_api_disp { 87 int (*get_static_info)(struct nvkm_disp *); 88 int (*get_supported)(struct nvkm_disp *, unsigned long *display_mask); 89 int (*get_connect_state)(struct nvkm_disp *, unsigned display_id); 90 int (*get_active)(struct nvkm_disp *, unsigned head, u32 *display_id); 91 92 int (*bl_ctrl)(struct nvkm_disp *, unsigned display_id, bool set, int *val); 93 94 struct { 95 int (*get_caps)(struct nvkm_disp *, int *link_bw, bool *mst, bool *wm); 96 int (*set_indexed_link_rates)(struct nvkm_outp *); 97 int (*sst)(struct nvkm_ior *, int head, bool ef, 98 u32 watermark, u32 hblanksym, u32 vblanksym); 99 int (*vcpi)(struct nvkm_ior *, int head, 100 u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn); 101 } dp; 102 103 struct { 104 int (*set_pushbuf)(struct nvkm_disp *, s32 oclass, int inst, 105 struct nvkm_memory *); 106 int (*dmac_alloc)(struct nvkm_disp *, u32 oclass, int inst, u32 put_offset, 107 struct nvkm_gsp_object *); 108 } chan; 109 } *disp; 110 111 const struct nvkm_rm_api_fifo { 112 int (*xlat_rm_engine_type)(u32 rm_engine_type, 113 enum nvkm_subdev_type *, int *nv2080_type); 114 int (*ectx_size)(struct nvkm_fifo *); 115 unsigned rsvd_chids; 116 int (*rc_triggered)(void *priv, u32 fn, void *repv, u32 repc); 117 struct { 118 int (*alloc)(struct nvkm_gsp_device *, u32 handle, 119 u32 nv2080_engine_type, u8 runq, bool priv, int chid, 120 u64 inst_addr, u64 userd_addr, u64 mthdbuf_addr, 121 struct nvkm_vmm *, u64 gpfifo_offset, u32 gpfifo_length, 122 struct nvkm_gsp_object *); 123 } chan; 124 } *fifo; 125 126 const struct nvkm_rm_api_engine { 127 int (*alloc)(struct nvkm_gsp_object *chan, u32 handle, u32 class, int inst, 128 struct nvkm_gsp_object *); 129 } *ce, *nvdec, *nvenc, *nvjpg, *ofa; 130 131 const struct nvkm_rm_api_gr { 132 int (*get_ctxbufs_and_zcull_info)(struct r535_gr *); 133 struct { 134 int (*init)(struct r535_gr *); 135 void (*fini)(struct r535_gr *); 136 } scrubber; 137 } *gr; 138 }; 139 140 extern const struct nvkm_rm_impl r535_rm_tu102; 141 extern const struct nvkm_rm_impl r535_rm_ga102; 142 extern const struct nvkm_rm_api_gsp r535_gsp; 143 typedef struct DOD_METHOD_DATA DOD_METHOD_DATA; 144 typedef struct JT_METHOD_DATA JT_METHOD_DATA; 145 typedef struct CAPS_METHOD_DATA CAPS_METHOD_DATA; 146 void r535_gsp_acpi_dod(acpi_handle, DOD_METHOD_DATA *); 147 void r535_gsp_acpi_jt(acpi_handle, JT_METHOD_DATA *); 148 void r535_gsp_acpi_caps(acpi_handle, CAPS_METHOD_DATA *); 149 struct NV2080_CTRL_CMD_FB_GET_FB_REGION_INFO_PARAMS; 150 void r535_gsp_get_static_info_fb(struct nvkm_gsp *, 151 const struct NV2080_CTRL_CMD_FB_GET_FB_REGION_INFO_PARAMS *); 152 extern const struct nvkm_rm_api_rpc r535_rpc; 153 extern const struct nvkm_rm_api_ctrl r535_ctrl; 154 extern const struct nvkm_rm_api_alloc r535_alloc; 155 extern const struct nvkm_rm_api_client r535_client; 156 void r535_gsp_client_dtor(struct nvkm_gsp_client *); 157 extern const struct nvkm_rm_api_device r535_device; 158 int r535_mmu_vaspace_new(struct nvkm_vmm *, u32 handle, bool external); 159 void r535_mmu_vaspace_del(struct nvkm_vmm *); 160 extern const struct nvkm_rm_api_fbsr r535_fbsr; 161 void r535_fbsr_resume(struct nvkm_gsp *); 162 int r535_fbsr_memlist(struct nvkm_gsp_device *, u32 handle, enum nvkm_memory_target, 163 u64 phys, u64 size, struct sg_table *, struct nvkm_gsp_object *); 164 extern const struct nvkm_rm_api_disp r535_disp; 165 extern const struct nvkm_rm_api_fifo r535_fifo; 166 void r535_fifo_rc_chid(struct nvkm_fifo *, int chid); 167 extern const struct nvkm_rm_api_engine r535_ce; 168 extern const struct nvkm_rm_api_gr r535_gr; 169 void *r535_gr_dtor(struct nvkm_gr *); 170 int r535_gr_oneinit(struct nvkm_gr *); 171 u64 r535_gr_units(struct nvkm_gr *); 172 int r535_gr_chan_new(struct nvkm_gr *, struct nvkm_chan *, const struct nvkm_oclass *, 173 struct nvkm_object **); 174 int r535_gr_promote_ctx(struct r535_gr *, bool golden, struct nvkm_vmm *, 175 struct nvkm_memory **pctxbuf_mem, struct nvkm_vma **pctxbuf_vma, 176 struct nvkm_gsp_object *chan); 177 extern const struct nvkm_rm_api_engine r535_nvdec; 178 extern const struct nvkm_rm_api_engine r535_nvenc; 179 extern const struct nvkm_rm_api_engine r535_nvjpg; 180 extern const struct nvkm_rm_api_engine r535_ofa; 181 182 extern const struct nvkm_rm_impl r570_rm_tu102; 183 extern const struct nvkm_rm_impl r570_rm_ga102; 184 extern const struct nvkm_rm_impl r570_rm_gh100; 185 extern const struct nvkm_rm_impl r570_rm_gb10x; 186 extern const struct nvkm_rm_impl r570_rm_gb20x; 187 extern const struct nvkm_rm_api_gsp r570_gsp; 188 extern const struct nvkm_rm_api_client r570_client; 189 extern const struct nvkm_rm_api_fbsr r570_fbsr; 190 extern const struct nvkm_rm_api_disp r570_disp; 191 extern const struct nvkm_rm_api_fifo r570_fifo; 192 extern const struct nvkm_rm_api_gr r570_gr; 193 int r570_gr_gpc_mask(struct nvkm_gsp *, u32 *mask); 194 int r570_gr_tpc_mask(struct nvkm_gsp *, int gpc, u32 *mask); 195 extern const struct nvkm_rm_api_engine r570_ofa; 196 #endif 197