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