• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 
24 #ifndef __KGD_PP_INTERFACE_H__
25 #define __KGD_PP_INTERFACE_H__
26 
27 extern const struct amdgpu_ip_block_version pp_smu_ip_block;
28 
29 struct amd_vce_state {
30 	/* vce clocks */
31 	u32 evclk;
32 	u32 ecclk;
33 	/* gpu clocks */
34 	u32 sclk;
35 	u32 mclk;
36 	u8 clk_idx;
37 	u8 pstate;
38 };
39 
40 
41 enum amd_dpm_forced_level {
42 	AMD_DPM_FORCED_LEVEL_AUTO = 0x1,
43 	AMD_DPM_FORCED_LEVEL_MANUAL = 0x2,
44 	AMD_DPM_FORCED_LEVEL_LOW = 0x4,
45 	AMD_DPM_FORCED_LEVEL_HIGH = 0x8,
46 	AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD = 0x10,
47 	AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK = 0x20,
48 	AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK = 0x40,
49 	AMD_DPM_FORCED_LEVEL_PROFILE_PEAK = 0x80,
50 	AMD_DPM_FORCED_LEVEL_PROFILE_EXIT = 0x100,
51 	AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM = 0x200,
52 };
53 
54 enum amd_pm_state_type {
55 	/* not used for dpm */
56 	POWER_STATE_TYPE_DEFAULT,
57 	POWER_STATE_TYPE_POWERSAVE,
58 	/* user selectable states */
59 	POWER_STATE_TYPE_BATTERY,
60 	POWER_STATE_TYPE_BALANCED,
61 	POWER_STATE_TYPE_PERFORMANCE,
62 	/* internal states */
63 	POWER_STATE_TYPE_INTERNAL_UVD,
64 	POWER_STATE_TYPE_INTERNAL_UVD_SD,
65 	POWER_STATE_TYPE_INTERNAL_UVD_HD,
66 	POWER_STATE_TYPE_INTERNAL_UVD_HD2,
67 	POWER_STATE_TYPE_INTERNAL_UVD_MVC,
68 	POWER_STATE_TYPE_INTERNAL_BOOT,
69 	POWER_STATE_TYPE_INTERNAL_THERMAL,
70 	POWER_STATE_TYPE_INTERNAL_ACPI,
71 	POWER_STATE_TYPE_INTERNAL_ULV,
72 	POWER_STATE_TYPE_INTERNAL_3DPERF,
73 };
74 
75 #define AMD_MAX_VCE_LEVELS 6
76 
77 enum amd_vce_level {
78 	AMD_VCE_LEVEL_AC_ALL = 0,     /* AC, All cases */
79 	AMD_VCE_LEVEL_DC_EE = 1,      /* DC, entropy encoding */
80 	AMD_VCE_LEVEL_DC_LL_LOW = 2,  /* DC, low latency queue, res <= 720 */
81 	AMD_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
82 	AMD_VCE_LEVEL_DC_GP_LOW = 4,  /* DC, general purpose queue, res <= 720 */
83 	AMD_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
84 };
85 
86 enum amd_fan_ctrl_mode {
87 	AMD_FAN_CTRL_NONE = 0,
88 	AMD_FAN_CTRL_MANUAL = 1,
89 	AMD_FAN_CTRL_AUTO = 2,
90 };
91 
92 enum pp_clock_type {
93 	PP_SCLK,
94 	PP_MCLK,
95 	PP_PCIE,
96 	PP_SOCCLK,
97 	PP_FCLK,
98 	PP_DCEFCLK,
99 	PP_VCLK,
100 	PP_DCLK,
101 	OD_SCLK,
102 	OD_MCLK,
103 	OD_VDDC_CURVE,
104 	OD_RANGE,
105 	OD_VDDGFX_OFFSET,
106 	OD_CCLK,
107 };
108 
109 enum amd_pp_sensors {
110 	AMDGPU_PP_SENSOR_GFX_SCLK = 0,
111 	AMDGPU_PP_SENSOR_CPU_CLK,
112 	AMDGPU_PP_SENSOR_VDDNB,
113 	AMDGPU_PP_SENSOR_VDDGFX,
114 	AMDGPU_PP_SENSOR_UVD_VCLK,
115 	AMDGPU_PP_SENSOR_UVD_DCLK,
116 	AMDGPU_PP_SENSOR_VCE_ECCLK,
117 	AMDGPU_PP_SENSOR_GPU_LOAD,
118 	AMDGPU_PP_SENSOR_MEM_LOAD,
119 	AMDGPU_PP_SENSOR_GFX_MCLK,
120 	AMDGPU_PP_SENSOR_GPU_TEMP,
121 	AMDGPU_PP_SENSOR_EDGE_TEMP = AMDGPU_PP_SENSOR_GPU_TEMP,
122 	AMDGPU_PP_SENSOR_HOTSPOT_TEMP,
123 	AMDGPU_PP_SENSOR_MEM_TEMP,
124 	AMDGPU_PP_SENSOR_VCE_POWER,
125 	AMDGPU_PP_SENSOR_UVD_POWER,
126 	AMDGPU_PP_SENSOR_GPU_POWER,
127 	AMDGPU_PP_SENSOR_SS_APU_SHARE,
128 	AMDGPU_PP_SENSOR_SS_DGPU_SHARE,
129 	AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK,
130 	AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK,
131 	AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK,
132 	AMDGPU_PP_SENSOR_MIN_FAN_RPM,
133 	AMDGPU_PP_SENSOR_MAX_FAN_RPM,
134 	AMDGPU_PP_SENSOR_VCN_POWER_STATE,
135 };
136 
137 enum amd_pp_task {
138 	AMD_PP_TASK_DISPLAY_CONFIG_CHANGE,
139 	AMD_PP_TASK_ENABLE_USER_STATE,
140 	AMD_PP_TASK_READJUST_POWER_STATE,
141 	AMD_PP_TASK_COMPLETE_INIT,
142 	AMD_PP_TASK_MAX
143 };
144 
145 enum PP_SMC_POWER_PROFILE {
146 	PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT = 0x0,
147 	PP_SMC_POWER_PROFILE_FULLSCREEN3D = 0x1,
148 	PP_SMC_POWER_PROFILE_POWERSAVING  = 0x2,
149 	PP_SMC_POWER_PROFILE_VIDEO        = 0x3,
150 	PP_SMC_POWER_PROFILE_VR           = 0x4,
151 	PP_SMC_POWER_PROFILE_COMPUTE      = 0x5,
152 	PP_SMC_POWER_PROFILE_CUSTOM       = 0x6,
153 	PP_SMC_POWER_PROFILE_COUNT,
154 };
155 
156 enum {
157 	PP_GROUP_UNKNOWN = 0,
158 	PP_GROUP_GFX = 1,
159 	PP_GROUP_SYS,
160 	PP_GROUP_MAX
161 };
162 
163 enum PP_OD_DPM_TABLE_COMMAND {
164 	PP_OD_EDIT_SCLK_VDDC_TABLE,
165 	PP_OD_EDIT_MCLK_VDDC_TABLE,
166 	PP_OD_EDIT_CCLK_VDDC_TABLE,
167 	PP_OD_EDIT_VDDC_CURVE,
168 	PP_OD_RESTORE_DEFAULT_TABLE,
169 	PP_OD_COMMIT_DPM_TABLE,
170 	PP_OD_EDIT_VDDGFX_OFFSET
171 };
172 
173 struct pp_states_info {
174 	uint32_t nums;
175 	uint32_t states[16];
176 };
177 
178 enum PP_HWMON_TEMP {
179 	PP_TEMP_EDGE = 0,
180 	PP_TEMP_JUNCTION,
181 	PP_TEMP_MEM,
182 	PP_TEMP_MAX
183 };
184 
185 enum pp_mp1_state {
186 	PP_MP1_STATE_NONE,
187 	PP_MP1_STATE_SHUTDOWN,
188 	PP_MP1_STATE_UNLOAD,
189 	PP_MP1_STATE_RESET,
190 };
191 
192 enum pp_df_cstate {
193 	DF_CSTATE_DISALLOW = 0,
194 	DF_CSTATE_ALLOW,
195 };
196 
197 /**
198  * DOC: amdgpu_pp_power
199  *
200  * APU power is managed to system-level requirements through the PPT
201  * (package power tracking) feature. PPT is intended to limit power to the
202  * requirements of the power source and could be dynamically updated to
203  * maximize APU performance within the system power budget.
204  *
205  * Two types of power measurement can be requested, where supported, with
206  * :c:type:`enum pp_power_type <pp_power_type>`.
207  */
208 
209 /**
210  * enum pp_power_limit_level - Used to query the power limits
211  *
212  * @PP_PWR_LIMIT_MIN: Minimum Power Limit
213  * @PP_PWR_LIMIT_CURRENT: Current Power Limit
214  * @PP_PWR_LIMIT_DEFAULT: Default Power Limit
215  * @PP_PWR_LIMIT_MAX: Maximum Power Limit
216  */
217 enum pp_power_limit_level
218 {
219 	PP_PWR_LIMIT_MIN = -1,
220 	PP_PWR_LIMIT_CURRENT,
221 	PP_PWR_LIMIT_DEFAULT,
222 	PP_PWR_LIMIT_MAX,
223 };
224 
225 /**
226  * enum pp_power_type - Used to specify the type of the requested power
227  *
228  * @PP_PWR_TYPE_SUSTAINED: manages the configurable, thermally significant
229  * moving average of APU power (default ~5000 ms).
230  * @PP_PWR_TYPE_FAST: manages the ~10 ms moving average of APU power,
231  * where supported.
232  */
233 enum pp_power_type
234 {
235 	PP_PWR_TYPE_SUSTAINED,
236 	PP_PWR_TYPE_FAST,
237 };
238 
239 #define PP_GROUP_MASK        0xF0000000
240 #define PP_GROUP_SHIFT       28
241 
242 #define PP_BLOCK_MASK        0x0FFFFF00
243 #define PP_BLOCK_SHIFT       8
244 
245 #define PP_BLOCK_GFX_CG         0x01
246 #define PP_BLOCK_GFX_MG         0x02
247 #define PP_BLOCK_GFX_3D         0x04
248 #define PP_BLOCK_GFX_RLC        0x08
249 #define PP_BLOCK_GFX_CP         0x10
250 #define PP_BLOCK_SYS_BIF        0x01
251 #define PP_BLOCK_SYS_MC         0x02
252 #define PP_BLOCK_SYS_ROM        0x04
253 #define PP_BLOCK_SYS_DRM        0x08
254 #define PP_BLOCK_SYS_HDP        0x10
255 #define PP_BLOCK_SYS_SDMA       0x20
256 
257 #define PP_STATE_MASK           0x0000000F
258 #define PP_STATE_SHIFT          0
259 #define PP_STATE_SUPPORT_MASK   0x000000F0
260 #define PP_STATE_SUPPORT_SHIFT  0
261 
262 #define PP_STATE_CG             0x01
263 #define PP_STATE_LS             0x02
264 #define PP_STATE_DS             0x04
265 #define PP_STATE_SD             0x08
266 #define PP_STATE_SUPPORT_CG     0x10
267 #define PP_STATE_SUPPORT_LS     0x20
268 #define PP_STATE_SUPPORT_DS     0x40
269 #define PP_STATE_SUPPORT_SD     0x80
270 
271 #define PP_CG_MSG_ID(group, block, support, state) \
272 		((group) << PP_GROUP_SHIFT | (block) << PP_BLOCK_SHIFT | \
273 		(support) << PP_STATE_SUPPORT_SHIFT | (state) << PP_STATE_SHIFT)
274 
275 #define XGMI_MODE_PSTATE_D3 0
276 #define XGMI_MODE_PSTATE_D0 1
277 
278 #define NUM_HBM_INSTANCES 4
279 
280 struct seq_file;
281 enum amd_pp_clock_type;
282 struct amd_pp_simple_clock_info;
283 struct amd_pp_display_configuration;
284 struct amd_pp_clock_info;
285 struct pp_display_clock_request;
286 struct pp_clock_levels_with_voltage;
287 struct pp_clock_levels_with_latency;
288 struct amd_pp_clocks;
289 struct pp_smu_wm_range_sets;
290 struct pp_smu_nv_clock_table;
291 struct dpm_clocks;
292 
293 struct amd_pm_funcs {
294 /* export for dpm on ci and si */
295 	int (*pre_set_power_state)(void *handle);
296 	int (*set_power_state)(void *handle);
297 	void (*post_set_power_state)(void *handle);
298 	void (*display_configuration_changed)(void *handle);
299 	void (*print_power_state)(void *handle, void *ps);
300 	bool (*vblank_too_short)(void *handle);
301 	void (*enable_bapm)(void *handle, bool enable);
302 	int (*check_state_equal)(void *handle,
303 				void  *cps,
304 				void  *rps,
305 				bool  *equal);
306 /* export for sysfs */
307 	void (*set_fan_control_mode)(void *handle, u32 mode);
308 	u32 (*get_fan_control_mode)(void *handle);
309 	int (*set_fan_speed_pwm)(void *handle, u32 speed);
310 	int (*get_fan_speed_pwm)(void *handle, u32 *speed);
311 	int (*force_clock_level)(void *handle, enum pp_clock_type type, uint32_t mask);
312 	int (*print_clock_levels)(void *handle, enum pp_clock_type type, char *buf);
313 	int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level);
314 	int (*get_sclk_od)(void *handle);
315 	int (*set_sclk_od)(void *handle, uint32_t value);
316 	int (*get_mclk_od)(void *handle);
317 	int (*set_mclk_od)(void *handle, uint32_t value);
318 	int (*read_sensor)(void *handle, int idx, void *value, int *size);
319 	enum amd_dpm_forced_level (*get_performance_level)(void *handle);
320 	enum amd_pm_state_type (*get_current_power_state)(void *handle);
321 	int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm);
322 	int (*set_fan_speed_rpm)(void *handle, uint32_t rpm);
323 	int (*get_pp_num_states)(void *handle, struct pp_states_info *data);
324 	int (*get_pp_table)(void *handle, char **table);
325 	int (*set_pp_table)(void *handle, const char *buf, size_t size);
326 	void (*debugfs_print_current_performance_level)(void *handle, struct seq_file *m);
327 	int (*switch_power_profile)(void *handle, enum PP_SMC_POWER_PROFILE type, bool en);
328 /* export to amdgpu */
329 	struct amd_vce_state *(*get_vce_clock_state)(void *handle, u32 idx);
330 	int (*dispatch_tasks)(void *handle, enum amd_pp_task task_id,
331 			enum amd_pm_state_type *user_state);
332 	int (*load_firmware)(void *handle);
333 	int (*wait_for_fw_loading_complete)(void *handle);
334 	int (*set_powergating_by_smu)(void *handle,
335 				uint32_t block_type, bool gate);
336 	int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
337 	int (*set_power_limit)(void *handle, uint32_t n);
338 	int (*get_power_limit)(void *handle, uint32_t *limit,
339 			enum pp_power_limit_level pp_limit_level,
340 			enum pp_power_type power_type);
341 	int (*get_power_profile_mode)(void *handle, char *buf);
342 	int (*set_power_profile_mode)(void *handle, long *input, uint32_t size);
343 	int (*set_fine_grain_clk_vol)(void *handle, uint32_t type, long *input, uint32_t size);
344 	int (*odn_edit_dpm_table)(void *handle, enum PP_OD_DPM_TABLE_COMMAND type,
345 				  long *input, uint32_t size);
346 	int (*set_mp1_state)(void *handle, enum pp_mp1_state mp1_state);
347 	int (*smu_i2c_bus_access)(void *handle, bool acquire);
348 	int (*gfx_state_change_set)(void *handle, uint32_t state);
349 /* export to DC */
350 	u32 (*get_sclk)(void *handle, bool low);
351 	u32 (*get_mclk)(void *handle, bool low);
352 	int (*display_configuration_change)(void *handle,
353 		const struct amd_pp_display_configuration *input);
354 	int (*get_display_power_level)(void *handle,
355 		struct amd_pp_simple_clock_info *output);
356 	int (*get_current_clocks)(void *handle,
357 		struct amd_pp_clock_info *clocks);
358 	int (*get_clock_by_type)(void *handle,
359 		enum amd_pp_clock_type type,
360 		struct amd_pp_clocks *clocks);
361 	int (*get_clock_by_type_with_latency)(void *handle,
362 		enum amd_pp_clock_type type,
363 		struct pp_clock_levels_with_latency *clocks);
364 	int (*get_clock_by_type_with_voltage)(void *handle,
365 		enum amd_pp_clock_type type,
366 		struct pp_clock_levels_with_voltage *clocks);
367 	int (*set_watermarks_for_clocks_ranges)(void *handle,
368 						void *clock_ranges);
369 	int (*display_clock_voltage_request)(void *handle,
370 				struct pp_display_clock_request *clock);
371 	int (*get_display_mode_validation_clocks)(void *handle,
372 		struct amd_pp_simple_clock_info *clocks);
373 	int (*notify_smu_enable_pwe)(void *handle);
374 	int (*enable_mgpu_fan_boost)(void *handle);
375 	int (*set_active_display_count)(void *handle, uint32_t count);
376 	int (*set_hard_min_dcefclk_by_freq)(void *handle, uint32_t clock);
377 	int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
378 	int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
379 	int (*get_asic_baco_capability)(void *handle, bool *cap);
380 	int (*get_asic_baco_state)(void *handle, int *state);
381 	int (*set_asic_baco_state)(void *handle, int state);
382 	int (*get_ppfeature_status)(void *handle, char *buf);
383 	int (*set_ppfeature_status)(void *handle, uint64_t ppfeature_masks);
384 	int (*asic_reset_mode_2)(void *handle);
385 	int (*set_df_cstate)(void *handle, enum pp_df_cstate state);
386 	int (*set_xgmi_pstate)(void *handle, uint32_t pstate);
387 	ssize_t (*get_gpu_metrics)(void *handle, void **table);
388 	int (*set_watermarks_for_clock_ranges)(void *handle,
389 					       struct pp_smu_wm_range_sets *ranges);
390 	int (*display_disable_memory_clock_switch)(void *handle,
391 						   bool disable_memory_clock_switch);
392 	int (*get_max_sustainable_clocks_by_dc)(void *handle,
393 						struct pp_smu_nv_clock_table *max_clocks);
394 	int (*get_uclk_dpm_states)(void *handle,
395 				   unsigned int *clock_values_in_khz,
396 				   unsigned int *num_states);
397 	int (*get_dpm_clock_table)(void *handle,
398 				   struct dpm_clocks *clock_table);
399 	int (*get_smu_prv_buf_details)(void *handle, void **addr, size_t *size);
400 };
401 
402 struct metrics_table_header {
403 	uint16_t			structure_size;
404 	uint8_t				format_revision;
405 	uint8_t				content_revision;
406 };
407 
408 /*
409  * gpu_metrics_v1_0 is not recommended as it's not naturally aligned.
410  * Use gpu_metrics_v1_1 or later instead.
411  */
412 struct gpu_metrics_v1_0 {
413 	struct metrics_table_header	common_header;
414 
415 	/* Driver attached timestamp (in ns) */
416 	uint64_t			system_clock_counter;
417 
418 	/* Temperature */
419 	uint16_t			temperature_edge;
420 	uint16_t			temperature_hotspot;
421 	uint16_t			temperature_mem;
422 	uint16_t			temperature_vrgfx;
423 	uint16_t			temperature_vrsoc;
424 	uint16_t			temperature_vrmem;
425 
426 	/* Utilization */
427 	uint16_t			average_gfx_activity;
428 	uint16_t			average_umc_activity; // memory controller
429 	uint16_t			average_mm_activity; // UVD or VCN
430 
431 	/* Power/Energy */
432 	uint16_t			average_socket_power;
433 	uint32_t			energy_accumulator;
434 
435 	/* Average clocks */
436 	uint16_t			average_gfxclk_frequency;
437 	uint16_t			average_socclk_frequency;
438 	uint16_t			average_uclk_frequency;
439 	uint16_t			average_vclk0_frequency;
440 	uint16_t			average_dclk0_frequency;
441 	uint16_t			average_vclk1_frequency;
442 	uint16_t			average_dclk1_frequency;
443 
444 	/* Current clocks */
445 	uint16_t			current_gfxclk;
446 	uint16_t			current_socclk;
447 	uint16_t			current_uclk;
448 	uint16_t			current_vclk0;
449 	uint16_t			current_dclk0;
450 	uint16_t			current_vclk1;
451 	uint16_t			current_dclk1;
452 
453 	/* Throttle status */
454 	uint32_t			throttle_status;
455 
456 	/* Fans */
457 	uint16_t			current_fan_speed;
458 
459 	/* Link width/speed */
460 	uint8_t				pcie_link_width;
461 	uint8_t				pcie_link_speed; // in 0.1 GT/s
462 };
463 
464 struct gpu_metrics_v1_1 {
465 	struct metrics_table_header	common_header;
466 
467 	/* Temperature */
468 	uint16_t			temperature_edge;
469 	uint16_t			temperature_hotspot;
470 	uint16_t			temperature_mem;
471 	uint16_t			temperature_vrgfx;
472 	uint16_t			temperature_vrsoc;
473 	uint16_t			temperature_vrmem;
474 
475 	/* Utilization */
476 	uint16_t			average_gfx_activity;
477 	uint16_t			average_umc_activity; // memory controller
478 	uint16_t			average_mm_activity; // UVD or VCN
479 
480 	/* Power/Energy */
481 	uint16_t			average_socket_power;
482 	uint64_t			energy_accumulator;
483 
484 	/* Driver attached timestamp (in ns) */
485 	uint64_t			system_clock_counter;
486 
487 	/* Average clocks */
488 	uint16_t			average_gfxclk_frequency;
489 	uint16_t			average_socclk_frequency;
490 	uint16_t			average_uclk_frequency;
491 	uint16_t			average_vclk0_frequency;
492 	uint16_t			average_dclk0_frequency;
493 	uint16_t			average_vclk1_frequency;
494 	uint16_t			average_dclk1_frequency;
495 
496 	/* Current clocks */
497 	uint16_t			current_gfxclk;
498 	uint16_t			current_socclk;
499 	uint16_t			current_uclk;
500 	uint16_t			current_vclk0;
501 	uint16_t			current_dclk0;
502 	uint16_t			current_vclk1;
503 	uint16_t			current_dclk1;
504 
505 	/* Throttle status */
506 	uint32_t			throttle_status;
507 
508 	/* Fans */
509 	uint16_t			current_fan_speed;
510 
511 	/* Link width/speed */
512 	uint16_t			pcie_link_width;
513 	uint16_t			pcie_link_speed; // in 0.1 GT/s
514 
515 	uint16_t			padding;
516 
517 	uint32_t			gfx_activity_acc;
518 	uint32_t			mem_activity_acc;
519 
520 	uint16_t			temperature_hbm[NUM_HBM_INSTANCES];
521 };
522 
523 struct gpu_metrics_v1_2 {
524 	struct metrics_table_header	common_header;
525 
526 	/* Temperature */
527 	uint16_t			temperature_edge;
528 	uint16_t			temperature_hotspot;
529 	uint16_t			temperature_mem;
530 	uint16_t			temperature_vrgfx;
531 	uint16_t			temperature_vrsoc;
532 	uint16_t			temperature_vrmem;
533 
534 	/* Utilization */
535 	uint16_t			average_gfx_activity;
536 	uint16_t			average_umc_activity; // memory controller
537 	uint16_t			average_mm_activity; // UVD or VCN
538 
539 	/* Power/Energy */
540 	uint16_t			average_socket_power;
541 	uint64_t			energy_accumulator;
542 
543 	/* Driver attached timestamp (in ns) */
544 	uint64_t			system_clock_counter;
545 
546 	/* Average clocks */
547 	uint16_t			average_gfxclk_frequency;
548 	uint16_t			average_socclk_frequency;
549 	uint16_t			average_uclk_frequency;
550 	uint16_t			average_vclk0_frequency;
551 	uint16_t			average_dclk0_frequency;
552 	uint16_t			average_vclk1_frequency;
553 	uint16_t			average_dclk1_frequency;
554 
555 	/* Current clocks */
556 	uint16_t			current_gfxclk;
557 	uint16_t			current_socclk;
558 	uint16_t			current_uclk;
559 	uint16_t			current_vclk0;
560 	uint16_t			current_dclk0;
561 	uint16_t			current_vclk1;
562 	uint16_t			current_dclk1;
563 
564 	/* Throttle status (ASIC dependent) */
565 	uint32_t			throttle_status;
566 
567 	/* Fans */
568 	uint16_t			current_fan_speed;
569 
570 	/* Link width/speed */
571 	uint16_t			pcie_link_width;
572 	uint16_t			pcie_link_speed; // in 0.1 GT/s
573 
574 	uint16_t			padding;
575 
576 	uint32_t			gfx_activity_acc;
577 	uint32_t			mem_activity_acc;
578 
579 	uint16_t			temperature_hbm[NUM_HBM_INSTANCES];
580 
581 	/* PMFW attached timestamp (10ns resolution) */
582 	uint64_t			firmware_timestamp;
583 };
584 
585 struct gpu_metrics_v1_3 {
586 	struct metrics_table_header	common_header;
587 
588 	/* Temperature */
589 	uint16_t			temperature_edge;
590 	uint16_t			temperature_hotspot;
591 	uint16_t			temperature_mem;
592 	uint16_t			temperature_vrgfx;
593 	uint16_t			temperature_vrsoc;
594 	uint16_t			temperature_vrmem;
595 
596 	/* Utilization */
597 	uint16_t			average_gfx_activity;
598 	uint16_t			average_umc_activity; // memory controller
599 	uint16_t			average_mm_activity; // UVD or VCN
600 
601 	/* Power/Energy */
602 	uint16_t			average_socket_power;
603 	uint64_t			energy_accumulator;
604 
605 	/* Driver attached timestamp (in ns) */
606 	uint64_t			system_clock_counter;
607 
608 	/* Average clocks */
609 	uint16_t			average_gfxclk_frequency;
610 	uint16_t			average_socclk_frequency;
611 	uint16_t			average_uclk_frequency;
612 	uint16_t			average_vclk0_frequency;
613 	uint16_t			average_dclk0_frequency;
614 	uint16_t			average_vclk1_frequency;
615 	uint16_t			average_dclk1_frequency;
616 
617 	/* Current clocks */
618 	uint16_t			current_gfxclk;
619 	uint16_t			current_socclk;
620 	uint16_t			current_uclk;
621 	uint16_t			current_vclk0;
622 	uint16_t			current_dclk0;
623 	uint16_t			current_vclk1;
624 	uint16_t			current_dclk1;
625 
626 	/* Throttle status */
627 	uint32_t			throttle_status;
628 
629 	/* Fans */
630 	uint16_t			current_fan_speed;
631 
632 	/* Link width/speed */
633 	uint16_t			pcie_link_width;
634 	uint16_t			pcie_link_speed; // in 0.1 GT/s
635 
636 	uint16_t			padding;
637 
638 	uint32_t			gfx_activity_acc;
639 	uint32_t			mem_activity_acc;
640 
641 	uint16_t			temperature_hbm[NUM_HBM_INSTANCES];
642 
643 	/* PMFW attached timestamp (10ns resolution) */
644 	uint64_t			firmware_timestamp;
645 
646 	/* Voltage (mV) */
647 	uint16_t			voltage_soc;
648 	uint16_t			voltage_gfx;
649 	uint16_t			voltage_mem;
650 
651 	uint16_t			padding1;
652 
653 	/* Throttle status (ASIC independent) */
654 	uint64_t			indep_throttle_status;
655 };
656 
657 /*
658  * gpu_metrics_v2_0 is not recommended as it's not naturally aligned.
659  * Use gpu_metrics_v2_1 or later instead.
660  */
661 struct gpu_metrics_v2_0 {
662 	struct metrics_table_header	common_header;
663 
664 	/* Driver attached timestamp (in ns) */
665 	uint64_t			system_clock_counter;
666 
667 	/* Temperature */
668 	uint16_t			temperature_gfx; // gfx temperature on APUs
669 	uint16_t			temperature_soc; // soc temperature on APUs
670 	uint16_t			temperature_core[8]; // CPU core temperature on APUs
671 	uint16_t			temperature_l3[2];
672 
673 	/* Utilization */
674 	uint16_t			average_gfx_activity;
675 	uint16_t			average_mm_activity; // UVD or VCN
676 
677 	/* Power/Energy */
678 	uint16_t			average_socket_power; // dGPU + APU power on A + A platform
679 	uint16_t			average_cpu_power;
680 	uint16_t			average_soc_power;
681 	uint16_t			average_gfx_power;
682 	uint16_t			average_core_power[8]; // CPU core power on APUs
683 
684 	/* Average clocks */
685 	uint16_t			average_gfxclk_frequency;
686 	uint16_t			average_socclk_frequency;
687 	uint16_t			average_uclk_frequency;
688 	uint16_t			average_fclk_frequency;
689 	uint16_t			average_vclk_frequency;
690 	uint16_t			average_dclk_frequency;
691 
692 	/* Current clocks */
693 	uint16_t			current_gfxclk;
694 	uint16_t			current_socclk;
695 	uint16_t			current_uclk;
696 	uint16_t			current_fclk;
697 	uint16_t			current_vclk;
698 	uint16_t			current_dclk;
699 	uint16_t			current_coreclk[8]; // CPU core clocks
700 	uint16_t			current_l3clk[2];
701 
702 	/* Throttle status */
703 	uint32_t			throttle_status;
704 
705 	/* Fans */
706 	uint16_t			fan_pwm;
707 
708 	uint16_t			padding;
709 };
710 
711 struct gpu_metrics_v2_1 {
712 	struct metrics_table_header	common_header;
713 
714 	/* Temperature */
715 	uint16_t			temperature_gfx; // gfx temperature on APUs
716 	uint16_t			temperature_soc; // soc temperature on APUs
717 	uint16_t			temperature_core[8]; // CPU core temperature on APUs
718 	uint16_t			temperature_l3[2];
719 
720 	/* Utilization */
721 	uint16_t			average_gfx_activity;
722 	uint16_t			average_mm_activity; // UVD or VCN
723 
724 	/* Driver attached timestamp (in ns) */
725 	uint64_t			system_clock_counter;
726 
727 	/* Power/Energy */
728 	uint16_t			average_socket_power; // dGPU + APU power on A + A platform
729 	uint16_t			average_cpu_power;
730 	uint16_t			average_soc_power;
731 	uint16_t			average_gfx_power;
732 	uint16_t			average_core_power[8]; // CPU core power on APUs
733 
734 	/* Average clocks */
735 	uint16_t			average_gfxclk_frequency;
736 	uint16_t			average_socclk_frequency;
737 	uint16_t			average_uclk_frequency;
738 	uint16_t			average_fclk_frequency;
739 	uint16_t			average_vclk_frequency;
740 	uint16_t			average_dclk_frequency;
741 
742 	/* Current clocks */
743 	uint16_t			current_gfxclk;
744 	uint16_t			current_socclk;
745 	uint16_t			current_uclk;
746 	uint16_t			current_fclk;
747 	uint16_t			current_vclk;
748 	uint16_t			current_dclk;
749 	uint16_t			current_coreclk[8]; // CPU core clocks
750 	uint16_t			current_l3clk[2];
751 
752 	/* Throttle status */
753 	uint32_t			throttle_status;
754 
755 	/* Fans */
756 	uint16_t			fan_pwm;
757 
758 	uint16_t			padding[3];
759 };
760 
761 struct gpu_metrics_v2_2 {
762 	struct metrics_table_header	common_header;
763 
764 	/* Temperature */
765 	uint16_t			temperature_gfx; // gfx temperature on APUs
766 	uint16_t			temperature_soc; // soc temperature on APUs
767 	uint16_t			temperature_core[8]; // CPU core temperature on APUs
768 	uint16_t			temperature_l3[2];
769 
770 	/* Utilization */
771 	uint16_t			average_gfx_activity;
772 	uint16_t			average_mm_activity; // UVD or VCN
773 
774 	/* Driver attached timestamp (in ns) */
775 	uint64_t			system_clock_counter;
776 
777 	/* Power/Energy */
778 	uint16_t			average_socket_power; // dGPU + APU power on A + A platform
779 	uint16_t			average_cpu_power;
780 	uint16_t			average_soc_power;
781 	uint16_t			average_gfx_power;
782 	uint16_t			average_core_power[8]; // CPU core power on APUs
783 
784 	/* Average clocks */
785 	uint16_t			average_gfxclk_frequency;
786 	uint16_t			average_socclk_frequency;
787 	uint16_t			average_uclk_frequency;
788 	uint16_t			average_fclk_frequency;
789 	uint16_t			average_vclk_frequency;
790 	uint16_t			average_dclk_frequency;
791 
792 	/* Current clocks */
793 	uint16_t			current_gfxclk;
794 	uint16_t			current_socclk;
795 	uint16_t			current_uclk;
796 	uint16_t			current_fclk;
797 	uint16_t			current_vclk;
798 	uint16_t			current_dclk;
799 	uint16_t			current_coreclk[8]; // CPU core clocks
800 	uint16_t			current_l3clk[2];
801 
802 	/* Throttle status (ASIC dependent) */
803 	uint32_t			throttle_status;
804 
805 	/* Fans */
806 	uint16_t			fan_pwm;
807 
808 	uint16_t			padding[3];
809 
810 	/* Throttle status (ASIC independent) */
811 	uint64_t			indep_throttle_status;
812 };
813 
814 #endif
815