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

Configure Feed

Select the types of activity you want to include in your feed.

amdgpu/pm: Optimize emit_clock_levels for arcturus - part 3

split switch statement into two and consolidate the common
code for printing most of the types of clock speeds

Signed-off-by: Darren Powell <darren.powell@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Darren Powell and committed by
Alex Deucher
433c4dea 2c98de56

+24 -53
+24 -53
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
··· 787 787 single_dpm_table = &(dpm_context->dpm_tables.gfx_table); 788 788 arcturus_get_clk_table(smu, &clocks, single_dpm_table); 789 789 790 - /* 791 - * For DPM disabled case, there will be only one clock level. 792 - * And it's safe to assume that is always the current clock. 793 - */ 794 - for (i = 0; i < clocks.num_levels; i++) { 795 - clock_mhz = clocks.data[i].clocks_in_khz / 1000; 796 - freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); 797 - freq_match |= (clocks.num_levels == 1); 798 - 799 - *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", 800 - i, clock_mhz, 801 - freq_match ? "*" : ""); 802 - } 803 790 break; 804 791 805 792 case SMU_MCLK: ··· 799 812 single_dpm_table = &(dpm_context->dpm_tables.uclk_table); 800 813 arcturus_get_clk_table(smu, &clocks, single_dpm_table); 801 814 802 - for (i = 0; i < clocks.num_levels; i++) { 803 - clock_mhz = clocks.data[i].clocks_in_khz / 1000; 804 - freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); 805 - freq_match |= (clocks.num_levels == 1); 806 - 807 - *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", 808 - i, clock_mhz, 809 - freq_match ? "*" : ""); 810 - } 811 815 break; 812 816 813 817 case SMU_SOCCLK: ··· 811 833 single_dpm_table = &(dpm_context->dpm_tables.soc_table); 812 834 arcturus_get_clk_table(smu, &clocks, single_dpm_table); 813 835 814 - for (i = 0; i < clocks.num_levels; i++) { 815 - clock_mhz = clocks.data[i].clocks_in_khz / 1000; 816 - freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); 817 - freq_match |= (clocks.num_levels == 1); 818 - 819 - *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", 820 - i, clock_mhz, 821 - freq_match ? "*" : ""); 822 - } 823 836 break; 824 837 825 838 case SMU_FCLK: ··· 823 854 single_dpm_table = &(dpm_context->dpm_tables.fclk_table); 824 855 arcturus_get_clk_table(smu, &clocks, single_dpm_table); 825 856 826 - for (i = 0; i < clocks.num_levels; i++) { 827 - clock_mhz = clocks.data[i].clocks_in_khz / 1000; 828 - freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); 829 - freq_match |= (clocks.num_levels == 1); 830 - 831 - *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", 832 - i, clock_mhz, 833 - freq_match ? "*" : ""); 834 - } 835 857 break; 836 858 837 859 case SMU_VCLK: ··· 835 875 single_dpm_table = &(dpm_context->dpm_tables.vclk_table); 836 876 arcturus_get_clk_table(smu, &clocks, single_dpm_table); 837 877 838 - for (i = 0; i < clocks.num_levels; i++) { 839 - clock_mhz = clocks.data[i].clocks_in_khz / 1000; 840 - freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); 841 - freq_match |= (clocks.num_levels == 1); 842 - 843 - *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", 844 - i, clock_mhz, 845 - freq_match ? "*" : ""); 846 - } 847 878 break; 848 879 849 880 case SMU_DCLK: ··· 847 896 single_dpm_table = &(dpm_context->dpm_tables.dclk_table); 848 897 arcturus_get_clk_table(smu, &clocks, single_dpm_table); 849 898 899 + break; 900 + 901 + case SMU_PCIE: 902 + gen_speed = smu_v11_0_get_current_pcie_link_speed_level(smu); 903 + lane_width = smu_v11_0_get_current_pcie_link_width_level(smu); 904 + break; 905 + 906 + default: 907 + return -EINVAL; 908 + } 909 + 910 + switch (type) { 911 + case SMU_SCLK: 912 + case SMU_MCLK: 913 + case SMU_SOCCLK: 914 + case SMU_FCLK: 915 + case SMU_VCLK: 916 + case SMU_DCLK: 917 + /* 918 + * For DPM disabled case, there will be only one clock level. 919 + * And it's safe to assume that is always the current clock. 920 + */ 850 921 for (i = 0; i < clocks.num_levels; i++) { 851 922 clock_mhz = clocks.data[i].clocks_in_khz / 1000; 852 923 freq_match = arcturus_freqs_in_same_level(clock_mhz, cur_value); 853 924 freq_match |= (clocks.num_levels == 1); 854 925 855 926 *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", 856 - i, clock_mhz, 857 - freq_match ? "*" : ""); 927 + i, clock_mhz, 928 + freq_match ? "*" : ""); 858 929 } 859 930 break; 860 931 861 932 case SMU_PCIE: 862 - gen_speed = smu_v11_0_get_current_pcie_link_speed_level(smu); 863 - lane_width = smu_v11_0_get_current_pcie_link_width_level(smu); 864 933 *offset += sysfs_emit_at(buf, *offset, "0: %s %s %dMhz *\n", 865 934 (gen_speed == 0) ? "2.5GT/s," : 866 935 (gen_speed == 1) ? "5.0GT/s," :