1 /* 2 * Copyright 2014 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 __AMDGPU_GFX_H__ 25 #define __AMDGPU_GFX_H__ 26 27 /* 28 * GFX stuff 29 */ 30 #include "clearstate_defs.h" 31 #include "amdgpu_ring.h" 32 #include "amdgpu_rlc.h" 33 #include "amdgpu_imu.h" 34 #include "soc15.h" 35 #include "amdgpu_ras.h" 36 #include "amdgpu_ring_mux.h" 37 #include "amdgpu_xcp.h" 38 39 struct amdgpu_usermode_queue; 40 41 /* GFX current status */ 42 #define AMDGPU_GFX_NORMAL_MODE 0x00000000L 43 #define AMDGPU_GFX_SAFE_MODE 0x00000001L 44 #define AMDGPU_GFX_PG_DISABLED_MODE 0x00000002L 45 #define AMDGPU_GFX_CG_DISABLED_MODE 0x00000004L 46 #define AMDGPU_GFX_LBPW_DISABLED_MODE 0x00000008L 47 48 #define AMDGPU_MAX_GC_INSTANCES 8 49 #define AMDGPU_MAX_QUEUES 128 50 51 #define AMDGPU_MAX_GFX_QUEUES AMDGPU_MAX_QUEUES 52 #define AMDGPU_MAX_COMPUTE_QUEUES AMDGPU_MAX_QUEUES 53 54 enum amdgpu_gfx_pipe_priority { 55 AMDGPU_GFX_PIPE_PRIO_NORMAL = AMDGPU_RING_PRIO_1, 56 AMDGPU_GFX_PIPE_PRIO_HIGH = AMDGPU_RING_PRIO_2 57 }; 58 59 #define AMDGPU_GFX_QUEUE_PRIORITY_MINIMUM 0 60 #define AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM 15 61 62 /* 1 second timeout */ 63 #define GFX_PROFILE_IDLE_TIMEOUT msecs_to_jiffies(1000) 64 65 enum amdgpu_gfx_partition { 66 AMDGPU_SPX_PARTITION_MODE = 0, 67 AMDGPU_DPX_PARTITION_MODE = 1, 68 AMDGPU_TPX_PARTITION_MODE = 2, 69 AMDGPU_QPX_PARTITION_MODE = 3, 70 AMDGPU_CPX_PARTITION_MODE = 4, 71 AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE = -1, 72 /* Automatically choose the right mode */ 73 AMDGPU_AUTO_COMPUTE_PARTITION_MODE = -2, 74 }; 75 76 enum amdgpu_gfx_partition_mem_alloc_mode { 77 AMDGPU_PARTITION_MEM_CAPPING_EVEN = 0, 78 AMDGPU_PARTITION_MEM_ALLOC_ALL = 1, 79 }; 80 81 #define NUM_XCC(x) hweight16(x) 82 83 enum amdgpu_gfx_ras_mem_id_type { 84 AMDGPU_GFX_CP_MEM = 0, 85 AMDGPU_GFX_GCEA_MEM, 86 AMDGPU_GFX_GC_CANE_MEM, 87 AMDGPU_GFX_GCUTCL2_MEM, 88 AMDGPU_GFX_GDS_MEM, 89 AMDGPU_GFX_LDS_MEM, 90 AMDGPU_GFX_RLC_MEM, 91 AMDGPU_GFX_SP_MEM, 92 AMDGPU_GFX_SPI_MEM, 93 AMDGPU_GFX_SQC_MEM, 94 AMDGPU_GFX_SQ_MEM, 95 AMDGPU_GFX_TA_MEM, 96 AMDGPU_GFX_TCC_MEM, 97 AMDGPU_GFX_TCA_MEM, 98 AMDGPU_GFX_TCI_MEM, 99 AMDGPU_GFX_TCP_MEM, 100 AMDGPU_GFX_TD_MEM, 101 AMDGPU_GFX_TCX_MEM, 102 AMDGPU_GFX_ATC_L2_MEM, 103 AMDGPU_GFX_UTCL2_MEM, 104 AMDGPU_GFX_VML2_MEM, 105 AMDGPU_GFX_VML2_WALKER_MEM, 106 AMDGPU_GFX_MEM_TYPE_NUM 107 }; 108 109 struct amdgpu_mec { 110 struct amdgpu_bo *hpd_eop_obj; 111 u64 hpd_eop_gpu_addr; 112 struct amdgpu_bo *mec_fw_obj; 113 u64 mec_fw_gpu_addr; 114 struct amdgpu_bo *mec_fw_data_obj; 115 u64 mec_fw_data_gpu_addr; 116 117 u32 num_mec; 118 u32 num_pipe_per_mec; 119 u32 num_queue_per_pipe; 120 void *mqd_backup[AMDGPU_MAX_COMPUTE_RINGS * AMDGPU_MAX_GC_INSTANCES]; 121 bool use_mmio_for_reset; 122 u32 *mes_hung_db_array; 123 struct mutex reset_mutex; 124 }; 125 126 struct amdgpu_mec_bitmap { 127 /* These are the resources for which amdgpu takes ownership */ 128 DECLARE_BITMAP(queue_bitmap, AMDGPU_MAX_COMPUTE_QUEUES); 129 }; 130 131 enum amdgpu_unmap_queues_action { 132 PREEMPT_QUEUES = 0, 133 RESET_QUEUES, 134 DISABLE_PROCESS_QUEUES, 135 PREEMPT_QUEUES_NO_UNMAP, 136 }; 137 138 struct kiq_pm4_funcs { 139 /* Support ASIC-specific kiq pm4 packets*/ 140 void (*kiq_set_resources)(struct amdgpu_ring *kiq_ring, 141 uint64_t queue_mask); 142 void (*kiq_map_queues)(struct amdgpu_ring *kiq_ring, 143 struct amdgpu_ring *ring); 144 void (*kiq_unmap_queues)(struct amdgpu_ring *kiq_ring, 145 struct amdgpu_ring *ring, 146 enum amdgpu_unmap_queues_action action, 147 u64 gpu_addr, u64 seq); 148 void (*kiq_query_status)(struct amdgpu_ring *kiq_ring, 149 struct amdgpu_ring *ring, 150 u64 addr, 151 u64 seq); 152 void (*kiq_invalidate_tlbs)(struct amdgpu_ring *kiq_ring, 153 uint16_t pasid, uint32_t flush_type, 154 bool all_hub); 155 void (*kiq_reset_hw_queue)(struct amdgpu_ring *kiq_ring, 156 uint32_t queue_type, uint32_t me_id, 157 uint32_t pipe_id, uint32_t queue_id, 158 uint32_t xcc_id, uint32_t vmid); 159 /* Packet sizes */ 160 int set_resources_size; 161 int map_queues_size; 162 int unmap_queues_size; 163 int query_status_size; 164 int invalidate_tlbs_size; 165 }; 166 167 struct amdgpu_kiq { 168 u64 eop_gpu_addr; 169 struct amdgpu_bo *eop_obj; 170 spinlock_t ring_lock; 171 struct amdgpu_ring ring; 172 struct amdgpu_irq_src irq; 173 const struct kiq_pm4_funcs *pmf; 174 void *mqd_backup; 175 }; 176 177 /* 178 * GFX configurations 179 */ 180 #define AMDGPU_GFX_MAX_SE 4 181 #define AMDGPU_GFX_MAX_SH_PER_SE 2 182 183 /** 184 * amdgpu_rb_config - Configure a single Render Backend (RB) 185 * 186 * Bad RBs are fused off and there is a harvest register the driver reads to 187 * determine which RB(s) are fused off so that the driver can configure the 188 * hardware state so that nothing gets sent to them. There are also user 189 * harvest registers that the driver can program to disable additional RBs, 190 * etc., for testing purposes. 191 */ 192 struct amdgpu_rb_config { 193 /** 194 * @rb_backend_disable: 195 * 196 * The value captured from register RB_BACKEND_DISABLE indicates if the 197 * RB backend is disabled or not. 198 */ 199 uint32_t rb_backend_disable; 200 201 /** 202 * @user_rb_backend_disable: 203 * 204 * The value captured from register USER_RB_BACKEND_DISABLE indicates 205 * if the User RB backend is disabled or not. 206 */ 207 uint32_t user_rb_backend_disable; 208 209 /** 210 * @raster_config: 211 * 212 * To set up all of the states, it is necessary to have two registers 213 * to keep all of the states. This field holds the first register. 214 */ 215 uint32_t raster_config; 216 217 /** 218 * @raster_config_1: 219 * 220 * To set up all of the states, it is necessary to have two registers 221 * to keep all of the states. This field holds the second register. 222 */ 223 uint32_t raster_config_1; 224 }; 225 226 struct gb_addr_config { 227 uint16_t pipe_interleave_size; 228 uint8_t num_pipes; 229 uint8_t max_compress_frags; 230 uint8_t num_banks; 231 uint8_t num_se; 232 uint8_t num_rb_per_se; 233 uint8_t num_pkrs; 234 }; 235 236 struct amdgpu_gfx_config { 237 unsigned max_shader_engines; 238 unsigned max_tile_pipes; 239 unsigned max_cu_per_sh; 240 unsigned max_sh_per_se; 241 unsigned max_backends_per_se; 242 unsigned max_texture_channel_caches; 243 unsigned max_gprs; 244 unsigned max_gs_threads; 245 unsigned max_hw_contexts; 246 unsigned sc_prim_fifo_size_frontend; 247 unsigned sc_prim_fifo_size_backend; 248 unsigned sc_hiz_tile_fifo_size; 249 unsigned sc_earlyz_tile_fifo_size; 250 251 unsigned num_tile_pipes; 252 unsigned backend_enable_mask; 253 unsigned mem_max_burst_length_bytes; 254 unsigned mem_row_size_in_kb; 255 unsigned shader_engine_tile_size; 256 unsigned num_gpus; 257 unsigned multi_gpu_tile_size; 258 unsigned mc_arb_ramcfg; 259 unsigned num_banks; 260 unsigned num_ranks; 261 unsigned gb_addr_config; 262 unsigned num_rbs; 263 unsigned gs_vgt_table_depth; 264 unsigned gs_prim_buffer_depth; 265 266 uint32_t tile_mode_array[32]; 267 uint32_t macrotile_mode_array[16]; 268 269 struct gb_addr_config gb_addr_config_fields; 270 271 /** 272 * @rb_config: 273 * 274 * Matrix that keeps all the Render Backend (color and depth buffer 275 * handling) configuration on the 3D engine. 276 */ 277 struct amdgpu_rb_config rb_config[AMDGPU_GFX_MAX_SE][AMDGPU_GFX_MAX_SH_PER_SE]; 278 279 /* gfx configure feature */ 280 uint32_t double_offchip_lds_buf; 281 /* cached value of DB_DEBUG2 */ 282 uint32_t db_debug2; 283 /* gfx10 specific config */ 284 uint32_t num_sc_per_sh; 285 uint32_t num_packer_per_sc; 286 uint32_t pa_sc_tile_steering_override; 287 /* Whether texture coordinate truncation is conformant. */ 288 bool ta_cntl2_truncate_coord_mode; 289 uint64_t tcc_disabled_mask; 290 uint32_t gc_num_tcp_per_sa; 291 uint32_t gc_num_sdp_interface; 292 uint32_t gc_num_tcps; 293 uint32_t gc_num_tcp_per_wpg; 294 uint32_t gc_tcp_l1_size; 295 uint32_t gc_num_sqc_per_wgp; 296 uint32_t gc_l1_instruction_cache_size_per_sqc; 297 uint32_t gc_l1_data_cache_size_per_sqc; 298 uint32_t gc_gl1c_per_sa; 299 uint32_t gc_gl1c_size_per_instance; 300 uint32_t gc_gl2c_per_gpu; 301 uint32_t gc_tcp_size_per_cu; 302 uint32_t gc_num_cu_per_sqc; 303 uint32_t gc_tcc_size; 304 uint32_t gc_tcp_cache_line_size; 305 uint32_t gc_instruction_cache_size_per_sqc; 306 uint32_t gc_instruction_cache_line_size; 307 uint32_t gc_scalar_data_cache_size_per_sqc; 308 uint32_t gc_scalar_data_cache_line_size; 309 uint32_t gc_tcc_cache_line_size; 310 uint32_t gc_max_num_residency_ways; 311 uint32_t gc_cache_ways_size_in_bytes; 312 uint32_t gc_reserved; 313 }; 314 315 struct amdgpu_cu_info { 316 uint32_t simd_per_cu; 317 uint32_t max_waves_per_simd; 318 uint32_t wave_front_size; 319 uint32_t max_scratch_slots_per_cu; 320 uint32_t lds_size; 321 322 /* total active CU number */ 323 uint32_t number; 324 uint32_t ao_cu_mask; 325 uint32_t ao_cu_bitmap[4][4]; 326 uint32_t bitmap[AMDGPU_MAX_GC_INSTANCES][4][4]; 327 }; 328 329 struct amdgpu_gfx_ras { 330 struct amdgpu_ras_block_object ras_block; 331 void (*enable_watchdog_timer)(struct amdgpu_device *adev); 332 int (*rlc_gc_fed_irq)(struct amdgpu_device *adev, 333 struct amdgpu_irq_src *source, 334 struct amdgpu_iv_entry *entry); 335 int (*poison_consumption_handler)(struct amdgpu_device *adev, 336 struct amdgpu_iv_entry *entry); 337 }; 338 339 struct amdgpu_gfx_shadow_info { 340 u32 shadow_size; 341 u32 shadow_alignment; 342 u32 csa_size; 343 u32 csa_alignment; 344 u32 eop_size; 345 u32 eop_alignment; 346 }; 347 348 struct amdgpu_gfx_funcs { 349 /* get the gpu clock counter */ 350 uint64_t (*get_gpu_clock_counter)(struct amdgpu_device *adev); 351 void (*select_se_sh)(struct amdgpu_device *adev, u32 se_num, 352 u32 sh_num, u32 instance, int xcc_id); 353 void (*read_wave_data)(struct amdgpu_device *adev, uint32_t xcc_id, uint32_t simd, 354 uint32_t wave, uint32_t *dst, int *no_fields); 355 void (*read_wave_vgprs)(struct amdgpu_device *adev, uint32_t xcc_id, uint32_t simd, 356 uint32_t wave, uint32_t thread, uint32_t start, 357 uint32_t size, uint32_t *dst); 358 void (*read_wave_sgprs)(struct amdgpu_device *adev, uint32_t xcc_id, uint32_t simd, 359 uint32_t wave, uint32_t start, uint32_t size, 360 uint32_t *dst); 361 void (*select_me_pipe_q)(struct amdgpu_device *adev, u32 me, u32 pipe, 362 u32 queue, u32 vmid, u32 xcc_id); 363 void (*init_spm_golden)(struct amdgpu_device *adev); 364 void (*update_perfmon_mgcg)(struct amdgpu_device *adev, bool enable); 365 int (*get_gfx_shadow_info)(struct amdgpu_device *adev, 366 struct amdgpu_gfx_shadow_info *shadow_info, 367 bool skip_check); 368 enum amdgpu_gfx_partition 369 (*query_partition_mode)(struct amdgpu_device *adev); 370 int (*switch_partition_mode)(struct amdgpu_device *adev, 371 int num_xccs_per_xcp); 372 int (*ih_node_to_logical_xcc)(struct amdgpu_device *adev, int ih_node); 373 int (*get_xccs_per_xcp)(struct amdgpu_device *adev); 374 void (*get_hdp_flush_mask)(struct amdgpu_ring *ring, 375 uint32_t *ref_and_mask, uint32_t *reg_mem_engine); 376 }; 377 378 struct sq_work { 379 struct work_struct work; 380 unsigned ih_data; 381 }; 382 383 struct amdgpu_pfp { 384 struct amdgpu_bo *pfp_fw_obj; 385 uint64_t pfp_fw_gpu_addr; 386 uint32_t *pfp_fw_ptr; 387 388 struct amdgpu_bo *pfp_fw_data_obj; 389 uint64_t pfp_fw_data_gpu_addr; 390 uint32_t *pfp_fw_data_ptr; 391 }; 392 393 struct amdgpu_ce { 394 struct amdgpu_bo *ce_fw_obj; 395 uint64_t ce_fw_gpu_addr; 396 uint32_t *ce_fw_ptr; 397 }; 398 399 struct amdgpu_me { 400 struct amdgpu_bo *me_fw_obj; 401 uint64_t me_fw_gpu_addr; 402 uint32_t *me_fw_ptr; 403 404 struct amdgpu_bo *me_fw_data_obj; 405 uint64_t me_fw_data_gpu_addr; 406 uint32_t *me_fw_data_ptr; 407 408 uint32_t num_me; 409 uint32_t num_pipe_per_me; 410 uint32_t num_queue_per_pipe; 411 void *mqd_backup[AMDGPU_MAX_GFX_RINGS]; 412 bool use_mmio_for_reset; 413 414 /* These are the resources for which amdgpu takes ownership */ 415 DECLARE_BITMAP(queue_bitmap, AMDGPU_MAX_GFX_QUEUES); 416 }; 417 418 struct amdgpu_isolation_work { 419 struct amdgpu_device *adev; 420 u32 xcp_id; 421 struct delayed_work work; 422 }; 423 424 struct amdgpu_gfx { 425 struct mutex gpu_clock_mutex; 426 struct amdgpu_gfx_config config; 427 struct amdgpu_rlc rlc; 428 struct amdgpu_pfp pfp; 429 struct amdgpu_ce ce; 430 struct amdgpu_me me; 431 struct amdgpu_mec mec; 432 struct amdgpu_mec_bitmap mec_bitmap[AMDGPU_MAX_GC_INSTANCES]; 433 struct amdgpu_kiq kiq[AMDGPU_MAX_GC_INSTANCES]; 434 struct amdgpu_imu imu; 435 bool rs64_enable; /* firmware format */ 436 const struct firmware *me_fw; /* ME firmware */ 437 uint32_t me_fw_version; 438 const struct firmware *pfp_fw; /* PFP firmware */ 439 uint32_t pfp_fw_version; 440 const struct firmware *ce_fw; /* CE firmware */ 441 uint32_t ce_fw_version; 442 const struct firmware *rlc_fw; /* RLC firmware */ 443 uint32_t rlc_fw_version; 444 const struct firmware *mec_fw; /* MEC firmware */ 445 uint32_t mec_fw_version; 446 const struct firmware *mec2_fw; /* MEC2 firmware */ 447 uint32_t mec2_fw_version; 448 const struct firmware *imu_fw; /* IMU firmware */ 449 uint32_t imu_fw_version; 450 uint32_t me_feature_version; 451 uint32_t ce_feature_version; 452 uint32_t pfp_feature_version; 453 uint32_t rlc_feature_version; 454 uint32_t rlc_srlc_fw_version; 455 uint32_t rlc_srlc_feature_version; 456 uint32_t rlc_srlg_fw_version; 457 uint32_t rlc_srlg_feature_version; 458 uint32_t rlc_srls_fw_version; 459 uint32_t rlc_srls_feature_version; 460 uint32_t rlcp_ucode_version; 461 uint32_t rlcp_ucode_feature_version; 462 uint32_t rlcv_ucode_version; 463 uint32_t rlcv_ucode_feature_version; 464 uint32_t mec_feature_version; 465 uint32_t mec2_feature_version; 466 bool mec_fw_write_wait; 467 bool me_fw_write_wait; 468 bool cp_fw_write_wait; 469 struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS]; 470 unsigned num_gfx_rings; 471 struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS * AMDGPU_MAX_GC_INSTANCES]; 472 unsigned num_compute_rings; 473 struct amdgpu_irq_src eop_irq; 474 struct amdgpu_irq_src priv_reg_irq; 475 struct amdgpu_irq_src priv_inst_irq; 476 struct amdgpu_irq_src bad_op_irq; 477 struct amdgpu_irq_src cp_ecc_error_irq; 478 struct amdgpu_irq_src sq_irq; 479 struct amdgpu_irq_src rlc_gc_fed_irq; 480 struct amdgpu_irq_src rlc_poison_irq; 481 struct amdgpu_irq_src pmr_ea_irq; 482 struct sq_work sq_work; 483 484 /* gfx status */ 485 uint32_t gfx_current_status; 486 /* ce ram size*/ 487 unsigned ce_ram_size; 488 struct amdgpu_cu_info cu_info; 489 const struct amdgpu_gfx_funcs *funcs; 490 491 /* reset mask */ 492 uint32_t gfx_supported_reset; 493 uint32_t compute_supported_reset; 494 495 /* gfx off */ 496 bool gfx_off_state; /* true: enabled, false: disabled */ 497 struct mutex gfx_off_mutex; /* mutex to change gfxoff state */ 498 uint32_t gfx_off_req_count; /* default 1, enable gfx off: dec 1, disable gfx off: add 1 */ 499 struct delayed_work gfx_off_delay_work; /* async work to set gfx block off */ 500 uint32_t gfx_off_residency; /* last logged residency */ 501 uint64_t gfx_off_entrycount; /* count of times GPU has get into GFXOFF state */ 502 503 /* pipe reservation */ 504 struct mutex pipe_reserve_mutex; 505 DECLARE_BITMAP (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES); 506 507 /*ras */ 508 struct ras_common_if *ras_if; 509 struct amdgpu_gfx_ras *ras; 510 511 bool is_poweron; 512 513 struct amdgpu_ring sw_gfx_ring[AMDGPU_MAX_SW_GFX_RINGS]; 514 struct amdgpu_ring_mux muxer; 515 516 bool cp_gfx_shadow; /* for gfx11 */ 517 518 uint16_t xcc_mask; 519 uint32_t num_xcc_per_xcp; 520 struct mutex partition_mutex; 521 bool mcbp; /* mid command buffer preemption */ 522 523 /* IP reg dump */ 524 uint32_t *ip_dump_core; 525 uint32_t *ip_dump_compute_queues; 526 uint32_t *ip_dump_gfx_queues; 527 528 struct mutex reset_sem_mutex; 529 530 /* cleaner shader */ 531 struct amdgpu_bo *cleaner_shader_obj; 532 unsigned int cleaner_shader_size; 533 u64 cleaner_shader_gpu_addr; 534 void *cleaner_shader_cpu_ptr; 535 const void *cleaner_shader_ptr; 536 bool enable_cleaner_shader; 537 struct amdgpu_isolation_work enforce_isolation[MAX_XCP]; 538 /* Mutex for synchronizing KFD scheduler operations */ 539 struct mutex userq_sch_mutex; 540 u64 userq_sch_req_count[MAX_XCP]; 541 bool userq_sch_inactive[MAX_XCP]; 542 /* atomic bitmap of faulted gfx UQ slots (index = pipe | queue << 2) */ 543 unsigned long userq_priv_fault_slots; 544 struct work_struct userq_priv_fault_work; 545 unsigned long enforce_isolation_jiffies[MAX_XCP]; 546 unsigned long enforce_isolation_time[MAX_XCP]; 547 548 atomic_t total_submission_cnt; 549 struct delayed_work idle_work; 550 bool workload_profile_active; 551 struct mutex workload_profile_mutex; 552 553 bool disable_kq; 554 bool disable_uq; 555 }; 556 557 struct amdgpu_gfx_deferred_entry { 558 struct amdgpu_ring *ring; 559 struct amdgpu_fence *fence; 560 }; 561 562 struct amdgpu_gfx_ras_reg_entry { 563 struct amdgpu_ras_err_status_reg_entry reg_entry; 564 enum amdgpu_gfx_ras_mem_id_type mem_id_type; 565 uint32_t se_num; 566 }; 567 568 struct amdgpu_gfx_ras_mem_id_entry { 569 const struct amdgpu_ras_memory_id_entry *mem_id_ent; 570 uint32_t size; 571 }; 572 573 #define AMDGPU_GFX_MEMID_ENT(x) {(x), ARRAY_SIZE(x)}, 574 575 #define amdgpu_gfx_get_gpu_clock_counter(adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev)) 576 #define amdgpu_gfx_select_se_sh(adev, se, sh, instance, xcc_id) ((adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance), (xcc_id))) 577 #define amdgpu_gfx_select_me_pipe_q(adev, me, pipe, q, vmid, xcc_id) ((adev)->gfx.funcs->select_me_pipe_q((adev), (me), (pipe), (q), (vmid), (xcc_id))) 578 #define amdgpu_gfx_init_spm_golden(adev) (adev)->gfx.funcs->init_spm_golden((adev)) 579 #define amdgpu_gfx_get_gfx_shadow_info(adev, si) ((adev)->gfx.funcs->get_gfx_shadow_info((adev), (si), false)) 580 581 /** 582 * amdgpu_gfx_create_bitmask - create a bitmask 583 * 584 * @bit_width: length of the mask 585 * 586 * create a variable length bit mask. 587 * Returns the bitmask. 588 */ 589 static inline u32 amdgpu_gfx_create_bitmask(u32 bit_width) 590 { 591 return (u32)((1ULL << bit_width) - 1); 592 } 593 594 void amdgpu_gfx_parse_disable_cu(struct amdgpu_device *adev, unsigned int *mask, 595 unsigned int max_se, unsigned int max_sh); 596 597 int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, int xcc_id); 598 599 void amdgpu_gfx_kiq_free_ring(struct amdgpu_ring *ring); 600 601 void amdgpu_gfx_kiq_fini(struct amdgpu_device *adev, int xcc_id); 602 int amdgpu_gfx_kiq_init(struct amdgpu_device *adev, 603 unsigned hpd_size, int xcc_id); 604 605 int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev, 606 unsigned mqd_size, int xcc_id); 607 void amdgpu_gfx_mqd_sw_fini(struct amdgpu_device *adev, int xcc_id); 608 void amdgpu_gfx_mqd_symmetrically_map_cu_mask(struct amdgpu_device *adev, const uint32_t *cu_mask, 609 uint32_t cu_mask_count, uint32_t *se_mask); 610 int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id); 611 int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev, int xcc_id); 612 int amdgpu_gfx_disable_kgq(struct amdgpu_device *adev, int xcc_id); 613 int amdgpu_gfx_enable_kgq(struct amdgpu_device *adev, int xcc_id); 614 615 void amdgpu_gfx_compute_queue_acquire(struct amdgpu_device *adev); 616 void amdgpu_gfx_graphics_queue_acquire(struct amdgpu_device *adev); 617 618 int amdgpu_gfx_mec_queue_to_bit(struct amdgpu_device *adev, int mec, 619 int pipe, int queue); 620 void amdgpu_queue_mask_bit_to_mec_queue(struct amdgpu_device *adev, int bit, 621 int *mec, int *pipe, int *queue); 622 bool amdgpu_gfx_is_mec_queue_enabled(struct amdgpu_device *adev, int xcc_id, 623 int mec, int pipe, int queue); 624 bool amdgpu_gfx_is_high_priority_compute_queue(struct amdgpu_device *adev, 625 struct amdgpu_ring *ring); 626 bool amdgpu_gfx_is_high_priority_graphics_queue(struct amdgpu_device *adev, 627 struct amdgpu_ring *ring); 628 bool amdgpu_gfx_is_me_queue_enabled(struct amdgpu_device *adev, int me, 629 int pipe, int queue); 630 void amdgpu_gfx_handle_priv_fault(struct amdgpu_device *adev, 631 struct amdgpu_iv_entry *entry, 632 u8 me_id, u8 pipe_id, u8 queue_id); 633 void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable); 634 void amdgpu_gfx_off_ctrl_immediate(struct amdgpu_device *adev, bool enable); 635 int amdgpu_get_gfx_off_status(struct amdgpu_device *adev, uint32_t *value); 636 int amdgpu_gfx_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block); 637 void amdgpu_gfx_ras_suspend(struct amdgpu_device *adev, struct ras_common_if *ras_block); 638 void amdgpu_gfx_ras_fini(struct amdgpu_device *adev, struct ras_common_if *ras_block); 639 int amdgpu_get_gfx_off_entrycount(struct amdgpu_device *adev, u64 *value); 640 int amdgpu_get_gfx_off_residency(struct amdgpu_device *adev, u32 *residency); 641 int amdgpu_set_gfx_off_residency(struct amdgpu_device *adev, bool value); 642 int amdgpu_gfx_process_ras_data_cb(struct amdgpu_device *adev, 643 void *err_data, 644 struct amdgpu_iv_entry *entry); 645 int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev, 646 struct amdgpu_irq_src *source, 647 struct amdgpu_iv_entry *entry); 648 uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg, uint32_t xcc_id); 649 void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, uint32_t xcc_id); 650 void amdgpu_gfx_get_hdp_flush_mask(struct amdgpu_ring *ring, 651 uint32_t *ref_and_mask, uint32_t *reg_mem_engine); 652 int amdgpu_kiq_hdp_flush(struct amdgpu_device *adev); 653 int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev); 654 void amdgpu_gfx_cp_init_microcode(struct amdgpu_device *adev, uint32_t ucode_id); 655 656 int amdgpu_gfx_ras_sw_init(struct amdgpu_device *adev); 657 int amdgpu_gfx_poison_consumption_handler(struct amdgpu_device *adev, 658 struct amdgpu_iv_entry *entry); 659 660 bool amdgpu_gfx_is_master_xcc(struct amdgpu_device *adev, int xcc_id); 661 int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev); 662 void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev); 663 int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev, 664 struct amdgpu_ring *ring, 665 struct amdgpu_fence *guilty_fence, 666 struct amdgpu_usermode_queue *uq, 667 unsigned int *hung_queue_count, 668 void *faulty_queue_input); 669 void amdgpu_gfx_ras_error_func(struct amdgpu_device *adev, 670 void *ras_error_status, 671 void (*func)(struct amdgpu_device *adev, void *ras_error_status, 672 int xcc_id)); 673 int amdgpu_gfx_cleaner_shader_sw_init(struct amdgpu_device *adev, 674 unsigned int cleaner_shader_size); 675 void amdgpu_gfx_cleaner_shader_sw_fini(struct amdgpu_device *adev); 676 void amdgpu_gfx_cleaner_shader_init(struct amdgpu_device *adev, 677 unsigned int cleaner_shader_size, 678 const void *cleaner_shader_ptr); 679 void amdgpu_gfx_enforce_isolation_handler(struct work_struct *work); 680 void amdgpu_gfx_enforce_isolation_ring_begin_use(struct amdgpu_ring *ring); 681 void amdgpu_gfx_enforce_isolation_ring_end_use(struct amdgpu_ring *ring); 682 683 void amdgpu_gfx_profile_idle_work_handler(struct work_struct *work); 684 void amdgpu_gfx_profile_ring_begin_use(struct amdgpu_ring *ring); 685 void amdgpu_gfx_profile_ring_end_use(struct amdgpu_ring *ring); 686 u32 amdgpu_gfx_csb_preamble_start(u32 *buffer); 687 u32 amdgpu_gfx_csb_data_parser(struct amdgpu_device *adev, u32 *buffer, u32 count); 688 void amdgpu_gfx_csb_preamble_end(u32 *buffer, u32 count); 689 690 void amdgpu_debugfs_gfx_sched_mask_init(struct amdgpu_device *adev); 691 void amdgpu_debugfs_compute_sched_mask_init(struct amdgpu_device *adev); 692 693 int amdgpu_gfx_ring_preempt_ib(struct amdgpu_ring *ring); 694 695 int amdgpu_gfx_mes_reset_queue(struct amdgpu_ring *ring, 696 unsigned int vmid, 697 struct amdgpu_fence *timedout_fence, 698 bool use_mmio); 699 700 static inline const char *amdgpu_gfx_compute_mode_desc(int mode) 701 { 702 switch (mode) { 703 case AMDGPU_SPX_PARTITION_MODE: 704 return "SPX"; 705 case AMDGPU_DPX_PARTITION_MODE: 706 return "DPX"; 707 case AMDGPU_TPX_PARTITION_MODE: 708 return "TPX"; 709 case AMDGPU_QPX_PARTITION_MODE: 710 return "QPX"; 711 case AMDGPU_CPX_PARTITION_MODE: 712 return "CPX"; 713 default: 714 return "UNKNOWN"; 715 } 716 } 717 718 static inline const char *amdgpu_gfx_compute_mem_alloc_mode_desc(int mode) 719 { 720 switch (mode) { 721 case AMDGPU_PARTITION_MEM_CAPPING_EVEN: 722 return "CAPPING"; 723 case AMDGPU_PARTITION_MEM_ALLOC_ALL: 724 return "ALL"; 725 default: 726 return "UNKNOWN"; 727 } 728 } 729 730 #endif 731