Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Doorbell layout for vega20 and future asic

This introduces new doorbell layout for vega20 and future asics

v2: Use enum definition instead of hardcoded value

Signed-off-by: Oak Zeng <ozeng@amd.com>
Suggested-by: Felix Kuehling <Felix.Kuehling@amd.com>
Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Oak Zeng and committed by
Alex Deucher
c93aa775 4e2c1ac2

+105 -1
+50
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 392 392 u32 num_doorbells; /* Number of doorbells actually reserved for amdgpu. */ 393 393 }; 394 394 395 + typedef enum _AMDGPU_VEGA20_DOORBELL_ASSIGNMENT 396 + { 397 + /* Compute + GFX: 0~255 */ 398 + AMDGPU_VEGA20_DOORBELL_KIQ = 0x000, 399 + AMDGPU_VEGA20_DOORBELL_HIQ = 0x001, 400 + AMDGPU_VEGA20_DOORBELL_DIQ = 0x002, 401 + AMDGPU_VEGA20_DOORBELL_MEC_RING0 = 0x003, 402 + AMDGPU_VEGA20_DOORBELL_MEC_RING1 = 0x004, 403 + AMDGPU_VEGA20_DOORBELL_MEC_RING2 = 0x005, 404 + AMDGPU_VEGA20_DOORBELL_MEC_RING3 = 0x006, 405 + AMDGPU_VEGA20_DOORBELL_MEC_RING4 = 0x007, 406 + AMDGPU_VEGA20_DOORBELL_MEC_RING5 = 0x008, 407 + AMDGPU_VEGA20_DOORBELL_MEC_RING6 = 0x009, 408 + AMDGPU_VEGA20_DOORBELL_MEC_RING7 = 0x00A, 409 + AMDGPU_VEGA20_DOORBELL_USERQUEUE_START = 0x00B, 410 + AMDGPU_VEGA20_DOORBELL_USERQUEUE_END = 0x08A, 411 + AMDGPU_VEGA20_DOORBELL_GFX_RING0 = 0x08B, 412 + /* SDMA:256~335*/ 413 + AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE0 = 0x100, 414 + AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE1 = 0x10A, 415 + AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE2 = 0x114, 416 + AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE3 = 0x11E, 417 + AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE4 = 0x128, 418 + AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE5 = 0x132, 419 + AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE6 = 0x13C, 420 + AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE7 = 0x146, 421 + /* IH: 376~391 */ 422 + AMDGPU_VEGA20_DOORBELL_IH = 0x178, 423 + /* MMSCH: 392~407 424 + * overlap the doorbell assignment with VCN as they are mutually exclusive 425 + * VCE engine's doorbell is 32 bit and two VCE ring share one QWORD 426 + */ 427 + AMDGPU_VEGA20_DOORBELL64_VCN0_1 = 0x188, /* lower 32 bits for VNC0 and upper 32 bits for VNC1 */ 428 + AMDGPU_VEGA20_DOORBELL64_VCN2_3 = 0x189, 429 + AMDGPU_VEGA20_DOORBELL64_VCN4_5 = 0x18A, 430 + AMDGPU_VEGA20_DOORBELL64_VCN6_7 = 0x18B, 431 + 432 + AMDGPU_VEGA20_DOORBELL64_UVD_RING0_1 = 0x188, 433 + AMDGPU_VEGA20_DOORBELL64_UVD_RING2_3 = 0x189, 434 + AMDGPU_VEGA20_DOORBELL64_UVD_RING4_5 = 0x18A, 435 + AMDGPU_VEGA20_DOORBELL64_UVD_RING6_7 = 0x18B, 436 + 437 + AMDGPU_VEGA20_DOORBELL64_VCE_RING0_1 = 0x18C, 438 + AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3 = 0x18D, 439 + AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5 = 0x18E, 440 + AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 = 0x18F, 441 + AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT = 0x18F, 442 + AMDGPU_VEGA20_DOORBELL_INVALID = 0xFFFF 443 + } AMDGPU_VEGA20_DOORBELL_ASSIGNMENT; 444 + 395 445 /* 396 446 * 64bit doorbell, offset are in QWORD, occupy 2KB doorbell space 397 447 */
+21 -1
drivers/gpu/drm/amd/amdgpu/soc15.c
··· 609 609 .init_doorbell_index = &vega10_doorbell_index_init, 610 610 }; 611 611 612 + static const struct amdgpu_asic_funcs vega20_asic_funcs = 613 + { 614 + .read_disabled_bios = &soc15_read_disabled_bios, 615 + .read_bios_from_rom = &soc15_read_bios_from_rom, 616 + .read_register = &soc15_read_register, 617 + .reset = &soc15_asic_reset, 618 + .set_vga_state = &soc15_vga_set_state, 619 + .get_xclk = &soc15_get_xclk, 620 + .set_uvd_clocks = &soc15_set_uvd_clocks, 621 + .set_vce_clocks = &soc15_set_vce_clocks, 622 + .get_config_memsize = &soc15_get_config_memsize, 623 + .flush_hdp = &soc15_flush_hdp, 624 + .invalidate_hdp = &soc15_invalidate_hdp, 625 + .need_full_reset = &soc15_need_full_reset, 626 + .init_doorbell_index = &vega20_doorbell_index_init, 627 + }; 628 + 612 629 static int soc15_common_early_init(void *handle) 613 630 { 614 631 struct amdgpu_device *adev = (struct amdgpu_device *)handle; ··· 643 626 adev->se_cac_rreg = &soc15_se_cac_rreg; 644 627 adev->se_cac_wreg = &soc15_se_cac_wreg; 645 628 646 - adev->asic_funcs = &soc15_asic_funcs; 647 629 648 630 adev->external_rev_id = 0xFF; 649 631 switch (adev->asic_type) { 650 632 case CHIP_VEGA10: 633 + adev->asic_funcs = &soc15_asic_funcs; 651 634 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | 652 635 AMD_CG_SUPPORT_GFX_MGLS | 653 636 AMD_CG_SUPPORT_GFX_RLC_LS | ··· 671 654 adev->external_rev_id = 0x1; 672 655 break; 673 656 case CHIP_VEGA12: 657 + adev->asic_funcs = &soc15_asic_funcs; 674 658 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | 675 659 AMD_CG_SUPPORT_GFX_MGLS | 676 660 AMD_CG_SUPPORT_GFX_CGCG | ··· 694 676 adev->external_rev_id = adev->rev_id + 0x14; 695 677 break; 696 678 case CHIP_VEGA20: 679 + adev->asic_funcs = &vega20_asic_funcs; 697 680 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | 698 681 AMD_CG_SUPPORT_GFX_MGLS | 699 682 AMD_CG_SUPPORT_GFX_CGCG | ··· 717 698 adev->external_rev_id = adev->rev_id + 0x28; 718 699 break; 719 700 case CHIP_RAVEN: 701 + adev->asic_funcs = &soc15_asic_funcs; 720 702 if (adev->rev_id >= 0x8) 721 703 adev->external_rev_id = adev->rev_id + 0x81; 722 704 else if (adev->pdev->device == 0x15d8)
+1
drivers/gpu/drm/amd/amdgpu/soc15.h
··· 59 59 int vega20_reg_base_init(struct amdgpu_device *adev); 60 60 61 61 void vega10_doorbell_index_init(struct amdgpu_device *adev); 62 + void vega20_doorbell_index_init(struct amdgpu_device *adev); 62 63 #endif
+33
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c
··· 54 54 return 0; 55 55 } 56 56 57 + void vega20_doorbell_index_init(struct amdgpu_device *adev) 58 + { 59 + adev->doorbell_index.kiq = AMDGPU_VEGA20_DOORBELL_KIQ; 60 + adev->doorbell_index.mec_ring0 = AMDGPU_VEGA20_DOORBELL_MEC_RING0; 61 + adev->doorbell_index.mec_ring1 = AMDGPU_VEGA20_DOORBELL_MEC_RING1; 62 + adev->doorbell_index.mec_ring2 = AMDGPU_VEGA20_DOORBELL_MEC_RING2; 63 + adev->doorbell_index.mec_ring3 = AMDGPU_VEGA20_DOORBELL_MEC_RING3; 64 + adev->doorbell_index.mec_ring4 = AMDGPU_VEGA20_DOORBELL_MEC_RING4; 65 + adev->doorbell_index.mec_ring5 = AMDGPU_VEGA20_DOORBELL_MEC_RING5; 66 + adev->doorbell_index.mec_ring6 = AMDGPU_VEGA20_DOORBELL_MEC_RING6; 67 + adev->doorbell_index.mec_ring7 = AMDGPU_VEGA20_DOORBELL_MEC_RING7; 68 + adev->doorbell_index.userqueue_start = AMDGPU_VEGA20_DOORBELL_USERQUEUE_START; 69 + adev->doorbell_index.userqueue_end = AMDGPU_VEGA20_DOORBELL_USERQUEUE_END; 70 + adev->doorbell_index.gfx_ring0 = AMDGPU_VEGA20_DOORBELL_GFX_RING0; 71 + adev->doorbell_index.sdma_engine0 = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE0; 72 + adev->doorbell_index.sdma_engine1 = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE1; 73 + adev->doorbell_index.sdma_engine2 = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE2; 74 + adev->doorbell_index.sdma_engine3 = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE3; 75 + adev->doorbell_index.sdma_engine4 = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE4; 76 + adev->doorbell_index.sdma_engine5 = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE5; 77 + adev->doorbell_index.sdma_engine6 = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE6; 78 + adev->doorbell_index.sdma_engine7 = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE7; 79 + adev->doorbell_index.ih = AMDGPU_VEGA20_DOORBELL_IH; 80 + adev->doorbell_index.uvd_vce.uvd_ring0_1 = AMDGPU_VEGA20_DOORBELL64_UVD_RING0_1; 81 + adev->doorbell_index.uvd_vce.uvd_ring2_3 = AMDGPU_VEGA20_DOORBELL64_UVD_RING2_3; 82 + adev->doorbell_index.uvd_vce.uvd_ring4_5 = AMDGPU_VEGA20_DOORBELL64_UVD_RING4_5; 83 + adev->doorbell_index.uvd_vce.uvd_ring6_7 = AMDGPU_VEGA20_DOORBELL64_UVD_RING6_7; 84 + adev->doorbell_index.uvd_vce.vce_ring0_1 = AMDGPU_VEGA20_DOORBELL64_VCE_RING0_1; 85 + adev->doorbell_index.uvd_vce.vce_ring2_3 = AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3; 86 + adev->doorbell_index.uvd_vce.vce_ring4_5 = AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5; 87 + adev->doorbell_index.uvd_vce.vce_ring6_7 = AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7; 88 + adev->doorbell_index.max_assignment = AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT << 1; 89 + } 57 90