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