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

drm/amd/pm: Add STB support in sienna_cichlid

Add STB implementation for sienna_cichlid

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Andrey Grodzovsky and committed by
Alex Deucher
db5b5c67 79aae67e

+74
+7
drivers/gpu/drm/amd/include/asic_reg/mp/mp_11_0_offset.h
··· 354 354 #define mmMP1_SMN_EXT_SCRATCH7 0x03c7 355 355 #define mmMP1_SMN_EXT_SCRATCH7_BASE_IDX 0 356 356 357 + /* 358 + * addressBlock: mp_SmuMp1Pub_MmuDec 359 + * base address: 0x0 360 + */ 361 + #define smnMP1_PMI_3_START 0x3030204 362 + #define smnMP1_PMI_3_FIFO 0x3030208 363 + #define smnMP1_PMI_3 0x3030600 357 364 358 365 #endif
+12
drivers/gpu/drm/amd/include/asic_reg/mp/mp_11_0_sh_mask.h
··· 959 959 #define MP1_SMN_EXT_SCRATCH7__DATA__SHIFT 0x0 960 960 #define MP1_SMN_EXT_SCRATCH7__DATA_MASK 0xFFFFFFFFL 961 961 962 + // MP1_PMI_3_START 963 + #define MP1_PMI_3_START__ENABLE_MASK 0x80000000L 964 + // MP1_PMI_3_FIFO 965 + #define MP1_PMI_3_FIFO__DEPTH_MASK 0x00000fffL 966 + 967 + // MP1_PMI_3_START 968 + #define MP1_PMI_3_START__ENABLE__SHIFT 0x0000001f 969 + // MP1_PMI_3_FIFO 970 + #define MP1_PMI_3_FIFO__DEPTH__SHIFT 0x00000000 971 + 972 + 973 + 962 974 963 975 #endif
+55
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
··· 80 80 (*member) = (smu->smu_table.driver_pptable + offsetof(PPTable_t, field));\ 81 81 } while(0) 82 82 83 + /* STB FIFO depth is in 64bit units */ 84 + #define SIENNA_CICHLID_STB_DEPTH_UNIT_BYTES 8 85 + 83 86 static int get_table_size(struct smu_context *smu) 84 87 { 85 88 if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 13)) ··· 653 650 return 0; 654 651 } 655 652 653 + static void sienna_cichlid_stb_init(struct smu_context *smu); 654 + 656 655 static int sienna_cichlid_init_smc_tables(struct smu_context *smu) 657 656 { 658 657 int ret = 0; ··· 666 661 ret = sienna_cichlid_allocate_dpm_context(smu); 667 662 if (ret) 668 663 return ret; 664 + 665 + sienna_cichlid_stb_init(smu); 669 666 670 667 return smu_v11_0_init_smc_tables(smu); 671 668 } ··· 3800 3793 return ret; 3801 3794 } 3802 3795 3796 + static void sienna_cichlid_stb_init(struct smu_context *smu) 3797 + { 3798 + struct amdgpu_device *adev = smu->adev; 3799 + uint32_t reg; 3800 + 3801 + reg = RREG32_PCIE(MP1_Public | smnMP1_PMI_3_START); 3802 + smu->stb_context.enabled = REG_GET_FIELD(reg, MP1_PMI_3_START, ENABLE); 3803 + 3804 + /* STB is disabled */ 3805 + if (!smu->stb_context.enabled) 3806 + return; 3807 + 3808 + spin_lock_init(&smu->stb_context.lock); 3809 + 3810 + /* STB buffer size in bytes as function of FIFO depth */ 3811 + reg = RREG32_PCIE(MP1_Public | smnMP1_PMI_3_FIFO); 3812 + smu->stb_context.stb_buf_size = 1 << REG_GET_FIELD(reg, MP1_PMI_3_FIFO, DEPTH); 3813 + smu->stb_context.stb_buf_size *= SIENNA_CICHLID_STB_DEPTH_UNIT_BYTES; 3814 + 3815 + dev_info(smu->adev->dev, "STB initialized to %d entries", 3816 + smu->stb_context.stb_buf_size / SIENNA_CICHLID_STB_DEPTH_UNIT_BYTES); 3817 + 3818 + } 3819 + 3820 + int sienna_cichlid_stb_get_data_direct(struct smu_context *smu, 3821 + void *buf, 3822 + uint32_t size) 3823 + { 3824 + uint32_t *p = buf; 3825 + struct amdgpu_device *adev = smu->adev; 3826 + 3827 + /* No need to disable interrupts for now as we don't lock it yet from ISR */ 3828 + spin_lock(&smu->stb_context.lock); 3829 + 3830 + /* 3831 + * Read the STB FIFO in units of 32bit since this is the accessor window 3832 + * (register width) we have. 3833 + */ 3834 + buf = ((char *) buf) + size; 3835 + while ((void *)p < buf) 3836 + *p++ = cpu_to_le32(RREG32_PCIE(MP1_Public | smnMP1_PMI_3)); 3837 + 3838 + spin_unlock(&smu->stb_context.lock); 3839 + 3840 + return 0; 3841 + } 3842 + 3803 3843 static const struct pptable_funcs sienna_cichlid_ppt_funcs = { 3804 3844 .get_allowed_feature_mask = sienna_cichlid_get_allowed_feature_mask, 3805 3845 .set_default_dpm_table = sienna_cichlid_set_default_dpm_table, ··· 3936 3882 .interrupt_work = smu_v11_0_interrupt_work, 3937 3883 .gpo_control = sienna_cichlid_gpo_control, 3938 3884 .set_mp1_state = sienna_cichlid_set_mp1_state, 3885 + .stb_collect_info = sienna_cichlid_stb_get_data_direct, 3939 3886 }; 3940 3887 3941 3888 void sienna_cichlid_set_ppt_funcs(struct smu_context *smu)