xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h (revision 6812ce4e4379ffc99c52401ec28f0d7ffbc36206)
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 		int (*gcx_ready)(struct nvkm_gsp *gsp);
44 	} *gsp;
45 
46 	const struct nvkm_rm_api_rpc {
47 		void *(*get)(struct nvkm_gsp *, u32 fn, u32 argc);
48 		void *(*push)(struct nvkm_gsp *gsp, void *argv,
49 			      enum nvkm_gsp_rpc_reply_policy policy, u32 repc);
50 		void (*done)(struct nvkm_gsp *gsp, void *repv);
51 	} *rpc;
52 
53 	const struct nvkm_rm_api_ctrl {
54 		void *(*get)(struct nvkm_gsp_object *, u32 cmd, u32 params_size);
55 		int (*push)(struct nvkm_gsp_object *, void **params, u32 repc);
56 		void (*done)(struct nvkm_gsp_object *, void *params);
57 	} *ctrl;
58 
59 	const struct nvkm_rm_api_alloc {
60 		void *(*get)(struct nvkm_gsp_object *, u32 oclass, u32 params_size);
61 		void *(*push)(struct nvkm_gsp_object *, void *params);
62 		void (*done)(struct nvkm_gsp_object *, void *params);
63 
64 		int (*free)(struct nvkm_gsp_object *);
65 	} *alloc;
66 
67 	const struct nvkm_rm_api_client {
68 		int (*ctor)(struct nvkm_gsp_client *, u32 handle);
69 	} *client;
70 
71 	const struct nvkm_rm_api_device {
72 		int (*ctor)(struct nvkm_gsp_client *, struct nvkm_gsp_device *);
73 		void (*dtor)(struct nvkm_gsp_device *);
74 
75 		struct {
76 			int (*ctor)(struct nvkm_gsp_device *, u32 handle, u32 id,
77 				    nvkm_gsp_event_func, struct nvkm_gsp_event *);
78 			void (*dtor)(struct nvkm_gsp_event *);
79 		} event;
80 	} *device;
81 
82 	const struct nvkm_rm_api_fbsr {
83 		int (*suspend)(struct nvkm_gsp *);
84 		void (*resume)(struct nvkm_gsp *);
85 	} *fbsr;
86 
87 	const struct nvkm_rm_api_disp {
88 		int (*get_static_info)(struct nvkm_disp *);
89 		int (*get_supported)(struct nvkm_disp *, unsigned long *display_mask);
90 		int (*get_connect_state)(struct nvkm_disp *, unsigned display_id);
91 		int (*get_active)(struct nvkm_disp *, unsigned head, u32 *display_id);
92 
93 		int (*bl_ctrl)(struct nvkm_disp *, unsigned display_id, bool set, int *val);
94 
95 		struct {
96 			int (*get_caps)(struct nvkm_disp *, int *link_bw, bool *mst, bool *wm);
97 			int (*set_indexed_link_rates)(struct nvkm_outp *);
98 			int (*sst)(struct nvkm_ior *, int head, bool ef,
99 				   u32 watermark, u32 hblanksym, u32 vblanksym);
100 			int (*vcpi)(struct nvkm_ior *, int head,
101 				    u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn);
102 		} dp;
103 
104 		struct {
105 			int (*set_pushbuf)(struct nvkm_disp *, s32 oclass, int inst,
106 					   struct nvkm_memory *);
107 			int (*dmac_alloc)(struct nvkm_disp *, u32 oclass, int inst, u32 put_offset,
108 					  struct nvkm_gsp_object *);
109 		} chan;
110 	} *disp;
111 
112 	const struct nvkm_rm_api_fifo {
113 		int (*xlat_rm_engine_type)(u32 rm_engine_type,
114 					   enum nvkm_subdev_type *, int *nv2080_type);
115 		int (*ectx_size)(struct nvkm_fifo *);
116 		unsigned rsvd_chids;
117 		int (*rc_triggered)(void *priv, u32 fn, void *repv, u32 repc);
118 		struct {
119 			int (*alloc)(struct nvkm_gsp_device *, u32 handle,
120 				     u32 nv2080_engine_type, u8 runq, bool priv, int chid,
121 				     u64 inst_addr, u64 userd_addr, u64 mthdbuf_addr,
122 				     struct nvkm_vmm *, u64 gpfifo_offset, u32 gpfifo_length,
123 				     struct nvkm_gsp_object *);
124 		} chan;
125 	} *fifo;
126 
127 	const struct nvkm_rm_api_engine {
128 		int (*alloc)(struct nvkm_gsp_object *chan, u32 handle, u32 class, int inst,
129 			     struct nvkm_gsp_object *);
130 	} *ce, *nvdec, *nvenc, *nvjpg, *ofa;
131 
132 	const struct nvkm_rm_api_gr {
133 		int (*get_ctxbufs_and_zcull_info)(struct r535_gr *);
134 		struct {
135 			int (*init)(struct r535_gr *);
136 			void (*fini)(struct r535_gr *);
137 		} scrubber;
138 	} *gr;
139 };
140 
141 extern const struct nvkm_rm_impl r535_rm_tu102;
142 extern const struct nvkm_rm_impl r535_rm_ga102;
143 extern const struct nvkm_rm_api_gsp r535_gsp;
144 typedef struct DOD_METHOD_DATA DOD_METHOD_DATA;
145 typedef struct JT_METHOD_DATA JT_METHOD_DATA;
146 typedef struct CAPS_METHOD_DATA CAPS_METHOD_DATA;
147 void r535_gsp_acpi_dod(acpi_handle, DOD_METHOD_DATA *);
148 void r535_gsp_acpi_jt(acpi_handle, JT_METHOD_DATA *);
149 void r535_gsp_acpi_caps(acpi_handle, CAPS_METHOD_DATA *);
150 struct NV2080_CTRL_CMD_FB_GET_FB_REGION_INFO_PARAMS;
151 void r535_gsp_get_static_info_fb(struct nvkm_gsp *,
152 				 const struct NV2080_CTRL_CMD_FB_GET_FB_REGION_INFO_PARAMS *);
153 extern const struct nvkm_rm_api_rpc r535_rpc;
154 extern const struct nvkm_rm_api_ctrl r535_ctrl;
155 extern const struct nvkm_rm_api_alloc r535_alloc;
156 extern const struct nvkm_rm_api_client r535_client;
157 void r535_gsp_client_dtor(struct nvkm_gsp_client *);
158 extern const struct nvkm_rm_api_device r535_device;
159 int r535_mmu_vaspace_new(struct nvkm_vmm *, u32 handle, bool external);
160 void r535_mmu_vaspace_del(struct nvkm_vmm *);
161 extern const struct nvkm_rm_api_fbsr r535_fbsr;
162 void r535_fbsr_resume(struct nvkm_gsp *);
163 int r535_fbsr_memlist(struct nvkm_gsp_device *, u32 handle, enum nvkm_memory_target,
164 		      u64 phys, u64 size, struct sg_table *, struct nvkm_gsp_object *);
165 extern const struct nvkm_rm_api_disp r535_disp;
166 extern const struct nvkm_rm_api_fifo r535_fifo;
167 void r535_fifo_rc_chid(struct nvkm_fifo *, int chid);
168 extern const struct nvkm_rm_api_engine r535_ce;
169 extern const struct nvkm_rm_api_gr r535_gr;
170 void *r535_gr_dtor(struct nvkm_gr *);
171 int r535_gr_oneinit(struct nvkm_gr *);
172 u64 r535_gr_units(struct nvkm_gr *);
173 int r535_gr_chan_new(struct nvkm_gr *, struct nvkm_chan *, const struct nvkm_oclass *,
174 		     struct nvkm_object **);
175 int r535_gr_promote_ctx(struct r535_gr *, bool golden, struct nvkm_vmm *,
176 			struct nvkm_memory **pctxbuf_mem, struct nvkm_vma **pctxbuf_vma,
177 			struct nvkm_gsp_object *chan);
178 int r570_gsp_gcx_ready(struct nvkm_gsp *gsp);
179 int r535_gsp_get_static_memsys_info(struct nvkm_gsp *gsp);
180 extern const struct nvkm_rm_api_engine r535_nvdec;
181 extern const struct nvkm_rm_api_engine r535_nvenc;
182 extern const struct nvkm_rm_api_engine r535_nvjpg;
183 extern const struct nvkm_rm_api_engine r535_ofa;
184 
185 extern const struct nvkm_rm_impl r570_rm_tu102;
186 extern const struct nvkm_rm_impl r570_rm_ga102;
187 extern const struct nvkm_rm_impl r570_rm_gh100;
188 extern const struct nvkm_rm_impl r570_rm_gb10x;
189 extern const struct nvkm_rm_impl r570_rm_gb20x;
190 extern const struct nvkm_rm_api_gsp r570_gsp;
191 extern const struct nvkm_rm_api_client r570_client;
192 extern const struct nvkm_rm_api_fbsr r570_fbsr;
193 extern const struct nvkm_rm_api_disp r570_disp;
194 extern const struct nvkm_rm_api_fifo r570_fifo;
195 extern const struct nvkm_rm_api_gr r570_gr;
196 int r570_gr_gpc_mask(struct nvkm_gsp *, u32 *mask);
197 int r570_gr_tpc_mask(struct nvkm_gsp *, int gpc, u32 *mask);
198 extern const struct nvkm_rm_api_engine r570_ofa;
199 #endif
200