aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorRex Zhu <Rex.Zhu@amd.com>2018-02-24 06:53:41 -0500
committerAlex Deucher <alexander.deucher@amd.com>2018-03-06 13:12:38 -0500
commita5278e511dce23349e71d681dfa7e8c600d19603 (patch)
treed6c0db8c32e0de35300c7d7e2db6f6a9b6905613 /drivers/gpu/drm
parent180a8bebdd50fc8ce4677e579d49d9b73880caa7 (diff)
drm/amd/pp: Revert gfx/compute profile switch sysfs
The gfx/compute profiling mode switch is only for internally test. Not a complete solution and unexpectly upstream. so revert it. Reviewed-by: Evan Quan <evan.quan@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c180
-rw-r--r--drivers/gpu/drm/amd/amdgpu/ci_dpm.c256
-rw-r--r--drivers/gpu/drm/amd/amdgpu/ci_dpm.h7
-rw-r--r--drivers/gpu/drm/amd/include/kgd_pp_interface.h7
-rw-r--r--drivers/gpu/drm/amd/powerplay/amd_powerplay.c114
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c17
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c77
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c86
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h1
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hwmgr.h9
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/smumgr.h3
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c27
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c66
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c64
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c10
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c64
18 files changed, 0 insertions, 998 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
index bd745a4fae0c..9c373f8f465c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
@@ -341,14 +341,6 @@ enum amdgpu_pcie_gen {
341 ((adev)->powerplay.pp_funcs->reset_power_profile_state(\ 341 ((adev)->powerplay.pp_funcs->reset_power_profile_state(\
342 (adev)->powerplay.pp_handle, request)) 342 (adev)->powerplay.pp_handle, request))
343 343
344#define amdgpu_dpm_get_power_profile_state(adev, query) \
345 ((adev)->powerplay.pp_funcs->get_power_profile_state(\
346 (adev)->powerplay.pp_handle, query))
347
348#define amdgpu_dpm_set_power_profile_state(adev, request) \
349 ((adev)->powerplay.pp_funcs->set_power_profile_state(\
350 (adev)->powerplay.pp_handle, request))
351
352#define amdgpu_dpm_switch_power_profile(adev, type) \ 344#define amdgpu_dpm_switch_power_profile(adev, type) \
353 ((adev)->powerplay.pp_funcs->switch_power_profile(\ 345 ((adev)->powerplay.pp_funcs->switch_power_profile(\
354 (adev)->powerplay.pp_handle, type)) 346 (adev)->powerplay.pp_handle, type))
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 9e73cbcfce44..632b18670098 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -734,161 +734,6 @@ fail:
734 return -EINVAL; 734 return -EINVAL;
735} 735}
736 736
737static ssize_t amdgpu_get_pp_power_profile(struct device *dev,
738 char *buf, struct amd_pp_profile *query)
739{
740 struct drm_device *ddev = dev_get_drvdata(dev);
741 struct amdgpu_device *adev = ddev->dev_private;
742 int ret = 0xff;
743
744 if (adev->powerplay.pp_funcs->get_power_profile_state)
745 ret = amdgpu_dpm_get_power_profile_state(
746 adev, query);
747
748 if (ret)
749 return ret;
750
751 return snprintf(buf, PAGE_SIZE,
752 "%d %d %d %d %d\n",
753 query->min_sclk / 100,
754 query->min_mclk / 100,
755 query->activity_threshold,
756 query->up_hyst,
757 query->down_hyst);
758}
759
760static ssize_t amdgpu_get_pp_gfx_power_profile(struct device *dev,
761 struct device_attribute *attr,
762 char *buf)
763{
764 struct amd_pp_profile query = {0};
765
766 query.type = AMD_PP_GFX_PROFILE;
767
768 return amdgpu_get_pp_power_profile(dev, buf, &query);
769}
770
771static ssize_t amdgpu_get_pp_compute_power_profile(struct device *dev,
772 struct device_attribute *attr,
773 char *buf)
774{
775 struct amd_pp_profile query = {0};
776
777 query.type = AMD_PP_COMPUTE_PROFILE;
778
779 return amdgpu_get_pp_power_profile(dev, buf, &query);
780}
781
782static ssize_t amdgpu_set_pp_power_profile(struct device *dev,
783 const char *buf,
784 size_t count,
785 struct amd_pp_profile *request)
786{
787 struct drm_device *ddev = dev_get_drvdata(dev);
788 struct amdgpu_device *adev = ddev->dev_private;
789 uint32_t loop = 0;
790 char *sub_str, buf_cpy[128], *tmp_str;
791 const char delimiter[3] = {' ', '\n', '\0'};
792 long int value;
793 int ret = 0xff;
794
795 if (strncmp("reset", buf, strlen("reset")) == 0) {
796 if (adev->powerplay.pp_funcs->reset_power_profile_state)
797 ret = amdgpu_dpm_reset_power_profile_state(
798 adev, request);
799 if (ret) {
800 count = -EINVAL;
801 goto fail;
802 }
803 return count;
804 }
805
806 if (strncmp("set", buf, strlen("set")) == 0) {
807 if (adev->powerplay.pp_funcs->set_power_profile_state)
808 ret = amdgpu_dpm_set_power_profile_state(
809 adev, request);
810
811 if (ret) {
812 count = -EINVAL;
813 goto fail;
814 }
815 return count;
816 }
817
818 if (count + 1 >= 128) {
819 count = -EINVAL;
820 goto fail;
821 }
822
823 memcpy(buf_cpy, buf, count + 1);
824 tmp_str = buf_cpy;
825
826 while (tmp_str[0]) {
827 sub_str = strsep(&tmp_str, delimiter);
828 ret = kstrtol(sub_str, 0, &value);
829 if (ret) {
830 count = -EINVAL;
831 goto fail;
832 }
833
834 switch (loop) {
835 case 0:
836 /* input unit MHz convert to dpm table unit 10KHz*/
837 request->min_sclk = (uint32_t)value * 100;
838 break;
839 case 1:
840 /* input unit MHz convert to dpm table unit 10KHz*/
841 request->min_mclk = (uint32_t)value * 100;
842 break;
843 case 2:
844 request->activity_threshold = (uint16_t)value;
845 break;
846 case 3:
847 request->up_hyst = (uint8_t)value;
848 break;
849 case 4:
850 request->down_hyst = (uint8_t)value;
851 break;
852 default:
853 break;
854 }
855
856 loop++;
857 }
858 if (adev->powerplay.pp_funcs->set_power_profile_state)
859 ret = amdgpu_dpm_set_power_profile_state(adev, request);
860
861 if (ret)
862 count = -EINVAL;
863
864fail:
865 return count;
866}
867
868static ssize_t amdgpu_set_pp_gfx_power_profile(struct device *dev,
869 struct device_attribute *attr,
870 const char *buf,
871 size_t count)
872{
873 struct amd_pp_profile request = {0};
874
875 request.type = AMD_PP_GFX_PROFILE;
876
877 return amdgpu_set_pp_power_profile(dev, buf, count, &request);
878}
879
880static ssize_t amdgpu_set_pp_compute_power_profile(struct device *dev,
881 struct device_attribute *attr,
882 const char *buf,
883 size_t count)
884{
885 struct amd_pp_profile request = {0};
886
887 request.type = AMD_PP_COMPUTE_PROFILE;
888
889 return amdgpu_set_pp_power_profile(dev, buf, count, &request);
890}
891
892static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state); 737static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state);
893static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, 738static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR,
894 amdgpu_get_dpm_forced_performance_level, 739 amdgpu_get_dpm_forced_performance_level,
@@ -916,12 +761,6 @@ static DEVICE_ATTR(pp_sclk_od, S_IRUGO | S_IWUSR,
916static DEVICE_ATTR(pp_mclk_od, S_IRUGO | S_IWUSR, 761static DEVICE_ATTR(pp_mclk_od, S_IRUGO | S_IWUSR,
917 amdgpu_get_pp_mclk_od, 762 amdgpu_get_pp_mclk_od,
918 amdgpu_set_pp_mclk_od); 763 amdgpu_set_pp_mclk_od);
919static DEVICE_ATTR(pp_gfx_power_profile, S_IRUGO | S_IWUSR,
920 amdgpu_get_pp_gfx_power_profile,
921 amdgpu_set_pp_gfx_power_profile);
922static DEVICE_ATTR(pp_compute_power_profile, S_IRUGO | S_IWUSR,
923 amdgpu_get_pp_compute_power_profile,
924 amdgpu_set_pp_compute_power_profile);
925static DEVICE_ATTR(pp_power_profile_mode, S_IRUGO | S_IWUSR, 764static DEVICE_ATTR(pp_power_profile_mode, S_IRUGO | S_IWUSR,
926 amdgpu_get_pp_power_profile_mode, 765 amdgpu_get_pp_power_profile_mode,
927 amdgpu_set_pp_power_profile_mode); 766 amdgpu_set_pp_power_profile_mode);
@@ -1767,21 +1606,6 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
1767 return ret; 1606 return ret;
1768 } 1607 }
1769 ret = device_create_file(adev->dev, 1608 ret = device_create_file(adev->dev,
1770 &dev_attr_pp_gfx_power_profile);
1771 if (ret) {
1772 DRM_ERROR("failed to create device file "
1773 "pp_gfx_power_profile\n");
1774 return ret;
1775 }
1776 ret = device_create_file(adev->dev,
1777 &dev_attr_pp_compute_power_profile);
1778 if (ret) {
1779 DRM_ERROR("failed to create device file "
1780 "pp_compute_power_profile\n");
1781 return ret;
1782 }
1783
1784 ret = device_create_file(adev->dev,
1785 &dev_attr_pp_power_profile_mode); 1609 &dev_attr_pp_power_profile_mode);
1786 if (ret) { 1610 if (ret) {
1787 DRM_ERROR("failed to create device file " 1611 DRM_ERROR("failed to create device file "
@@ -1827,10 +1651,6 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
1827 device_remove_file(adev->dev, &dev_attr_pp_sclk_od); 1651 device_remove_file(adev->dev, &dev_attr_pp_sclk_od);
1828 device_remove_file(adev->dev, &dev_attr_pp_mclk_od); 1652 device_remove_file(adev->dev, &dev_attr_pp_mclk_od);
1829 device_remove_file(adev->dev, 1653 device_remove_file(adev->dev,
1830 &dev_attr_pp_gfx_power_profile);
1831 device_remove_file(adev->dev,
1832 &dev_attr_pp_compute_power_profile);
1833 device_remove_file(adev->dev,
1834 &dev_attr_pp_power_profile_mode); 1654 &dev_attr_pp_power_profile_mode);
1835 device_remove_file(adev->dev, 1655 device_remove_file(adev->dev,
1836 &dev_attr_pp_od_clk_voltage); 1656 &dev_attr_pp_od_clk_voltage);
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index f82f40fb3bea..ddb814f7e952 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
@@ -3695,40 +3695,6 @@ static int ci_find_boot_level(struct ci_single_dpm_table *table,
3695 return ret; 3695 return ret;
3696} 3696}
3697 3697
3698static void ci_save_default_power_profile(struct amdgpu_device *adev)
3699{
3700 struct ci_power_info *pi = ci_get_pi(adev);
3701 struct SMU7_Discrete_GraphicsLevel *levels =
3702 pi->smc_state_table.GraphicsLevel;
3703 uint32_t min_level = 0;
3704
3705 pi->default_gfx_power_profile.activity_threshold =
3706 be16_to_cpu(levels[0].ActivityLevel);
3707 pi->default_gfx_power_profile.up_hyst = levels[0].UpH;
3708 pi->default_gfx_power_profile.down_hyst = levels[0].DownH;
3709 pi->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE;
3710
3711 pi->default_compute_power_profile = pi->default_gfx_power_profile;
3712 pi->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE;
3713
3714 /* Optimize compute power profile: Use only highest
3715 * 2 power levels (if more than 2 are available), Hysteresis:
3716 * 0ms up, 5ms down
3717 */
3718 if (pi->smc_state_table.GraphicsDpmLevelCount > 2)
3719 min_level = pi->smc_state_table.GraphicsDpmLevelCount - 2;
3720 else if (pi->smc_state_table.GraphicsDpmLevelCount == 2)
3721 min_level = 1;
3722 pi->default_compute_power_profile.min_sclk =
3723 be32_to_cpu(levels[min_level].SclkFrequency);
3724
3725 pi->default_compute_power_profile.up_hyst = 0;
3726 pi->default_compute_power_profile.down_hyst = 5;
3727
3728 pi->gfx_power_profile = pi->default_gfx_power_profile;
3729 pi->compute_power_profile = pi->default_compute_power_profile;
3730}
3731
3732static int ci_init_smc_table(struct amdgpu_device *adev) 3698static int ci_init_smc_table(struct amdgpu_device *adev)
3733{ 3699{
3734 struct ci_power_info *pi = ci_get_pi(adev); 3700 struct ci_power_info *pi = ci_get_pi(adev);
@@ -3874,8 +3840,6 @@ static int ci_init_smc_table(struct amdgpu_device *adev)
3874 if (ret) 3840 if (ret)
3875 return ret; 3841 return ret;
3876 3842
3877 ci_save_default_power_profile(adev);
3878
3879 return 0; 3843 return 0;
3880} 3844}
3881 3845
@@ -6753,222 +6717,6 @@ static int ci_dpm_set_mclk_od(void *handle, uint32_t value)
6753 return 0; 6717 return 0;
6754} 6718}
6755 6719
6756static int ci_dpm_get_power_profile_state(void *handle,
6757 struct amd_pp_profile *query)
6758{
6759 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6760 struct ci_power_info *pi = ci_get_pi(adev);
6761
6762 if (!pi || !query)
6763 return -EINVAL;
6764
6765 if (query->type == AMD_PP_GFX_PROFILE)
6766 memcpy(query, &pi->gfx_power_profile,
6767 sizeof(struct amd_pp_profile));
6768 else if (query->type == AMD_PP_COMPUTE_PROFILE)
6769 memcpy(query, &pi->compute_power_profile,
6770 sizeof(struct amd_pp_profile));
6771 else
6772 return -EINVAL;
6773
6774 return 0;
6775}
6776
6777static int ci_populate_requested_graphic_levels(struct amdgpu_device *adev,
6778 struct amd_pp_profile *request)
6779{
6780 struct ci_power_info *pi = ci_get_pi(adev);
6781 struct ci_dpm_table *dpm_table = &(pi->dpm_table);
6782 struct SMU7_Discrete_GraphicsLevel *levels =
6783 pi->smc_state_table.GraphicsLevel;
6784 uint32_t array = pi->dpm_table_start +
6785 offsetof(SMU7_Discrete_DpmTable, GraphicsLevel);
6786 uint32_t array_size = sizeof(struct SMU7_Discrete_GraphicsLevel) *
6787 SMU7_MAX_LEVELS_GRAPHICS;
6788 uint32_t i;
6789
6790 for (i = 0; i < dpm_table->sclk_table.count; i++) {
6791 levels[i].ActivityLevel =
6792 cpu_to_be16(request->activity_threshold);
6793 levels[i].EnabledForActivity = 1;
6794 levels[i].UpH = request->up_hyst;
6795 levels[i].DownH = request->down_hyst;
6796 }
6797
6798 return amdgpu_ci_copy_bytes_to_smc(adev, array, (uint8_t *)levels,
6799 array_size, pi->sram_end);
6800}
6801
6802static void ci_find_min_clock_masks(struct amdgpu_device *adev,
6803 uint32_t *sclk_mask, uint32_t *mclk_mask,
6804 uint32_t min_sclk, uint32_t min_mclk)
6805{
6806 struct ci_power_info *pi = ci_get_pi(adev);
6807 struct ci_dpm_table *dpm_table = &(pi->dpm_table);
6808 uint32_t i;
6809
6810 for (i = 0; i < dpm_table->sclk_table.count; i++) {
6811 if (dpm_table->sclk_table.dpm_levels[i].enabled &&
6812 dpm_table->sclk_table.dpm_levels[i].value >= min_sclk)
6813 *sclk_mask |= 1 << i;
6814 }
6815
6816 for (i = 0; i < dpm_table->mclk_table.count; i++) {
6817 if (dpm_table->mclk_table.dpm_levels[i].enabled &&
6818 dpm_table->mclk_table.dpm_levels[i].value >= min_mclk)
6819 *mclk_mask |= 1 << i;
6820 }
6821}
6822
6823static int ci_set_power_profile_state(struct amdgpu_device *adev,
6824 struct amd_pp_profile *request)
6825{
6826 struct ci_power_info *pi = ci_get_pi(adev);
6827 int tmp_result, result = 0;
6828 uint32_t sclk_mask = 0, mclk_mask = 0;
6829
6830 tmp_result = ci_freeze_sclk_mclk_dpm(adev);
6831 if (tmp_result) {
6832 DRM_ERROR("Failed to freeze SCLK MCLK DPM!");
6833 result = tmp_result;
6834 }
6835
6836 tmp_result = ci_populate_requested_graphic_levels(adev,
6837 request);
6838 if (tmp_result) {
6839 DRM_ERROR("Failed to populate requested graphic levels!");
6840 result = tmp_result;
6841 }
6842
6843 tmp_result = ci_unfreeze_sclk_mclk_dpm(adev);
6844 if (tmp_result) {
6845 DRM_ERROR("Failed to unfreeze SCLK MCLK DPM!");
6846 result = tmp_result;
6847 }
6848
6849 ci_find_min_clock_masks(adev, &sclk_mask, &mclk_mask,
6850 request->min_sclk, request->min_mclk);
6851
6852 if (sclk_mask) {
6853 if (!pi->sclk_dpm_key_disabled)
6854 amdgpu_ci_send_msg_to_smc_with_parameter(
6855 adev,
6856 PPSMC_MSG_SCLKDPM_SetEnabledMask,
6857 pi->dpm_level_enable_mask.
6858 sclk_dpm_enable_mask &
6859 sclk_mask);
6860 }
6861
6862 if (mclk_mask) {
6863 if (!pi->mclk_dpm_key_disabled)
6864 amdgpu_ci_send_msg_to_smc_with_parameter(
6865 adev,
6866 PPSMC_MSG_MCLKDPM_SetEnabledMask,
6867 pi->dpm_level_enable_mask.
6868 mclk_dpm_enable_mask &
6869 mclk_mask);
6870 }
6871
6872
6873 return result;
6874}
6875
6876static int ci_dpm_set_power_profile_state(void *handle,
6877 struct amd_pp_profile *request)
6878{
6879 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6880 struct ci_power_info *pi = ci_get_pi(adev);
6881 int ret = -1;
6882
6883 if (!pi || !request)
6884 return -EINVAL;
6885
6886 if (adev->pm.dpm.forced_level !=
6887 AMD_DPM_FORCED_LEVEL_AUTO)
6888 return -EINVAL;
6889
6890 if (request->min_sclk ||
6891 request->min_mclk ||
6892 request->activity_threshold ||
6893 request->up_hyst ||
6894 request->down_hyst) {
6895 if (request->type == AMD_PP_GFX_PROFILE)
6896 memcpy(&pi->gfx_power_profile, request,
6897 sizeof(struct amd_pp_profile));
6898 else if (request->type == AMD_PP_COMPUTE_PROFILE)
6899 memcpy(&pi->compute_power_profile, request,
6900 sizeof(struct amd_pp_profile));
6901 else
6902 return -EINVAL;
6903
6904 if (request->type == pi->current_power_profile)
6905 ret = ci_set_power_profile_state(
6906 adev,
6907 request);
6908 } else {
6909 /* set power profile if it exists */
6910 switch (request->type) {
6911 case AMD_PP_GFX_PROFILE:
6912 ret = ci_set_power_profile_state(
6913 adev,
6914 &pi->gfx_power_profile);
6915 break;
6916 case AMD_PP_COMPUTE_PROFILE:
6917 ret = ci_set_power_profile_state(
6918 adev,
6919 &pi->compute_power_profile);
6920 break;
6921 default:
6922 return -EINVAL;
6923 }
6924 }
6925
6926 if (!ret)
6927 pi->current_power_profile = request->type;
6928
6929 return 0;
6930}
6931
6932static int ci_dpm_reset_power_profile_state(void *handle,
6933 struct amd_pp_profile *request)
6934{
6935 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6936 struct ci_power_info *pi = ci_get_pi(adev);
6937
6938 if (!pi || !request)
6939 return -EINVAL;
6940
6941 if (request->type == AMD_PP_GFX_PROFILE) {
6942 pi->gfx_power_profile = pi->default_gfx_power_profile;
6943 return ci_dpm_set_power_profile_state(adev,
6944 &pi->gfx_power_profile);
6945 } else if (request->type == AMD_PP_COMPUTE_PROFILE) {
6946 pi->compute_power_profile =
6947 pi->default_compute_power_profile;
6948 return ci_dpm_set_power_profile_state(adev,
6949 &pi->compute_power_profile);
6950 } else
6951 return -EINVAL;
6952}
6953
6954static int ci_dpm_switch_power_profile(void *handle,
6955 enum amd_pp_profile_type type)
6956{
6957 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6958 struct ci_power_info *pi = ci_get_pi(adev);
6959 struct amd_pp_profile request = {0};
6960
6961 if (!pi)
6962 return -EINVAL;
6963
6964 if (pi->current_power_profile != type) {
6965 request.type = type;
6966 return ci_dpm_set_power_profile_state(adev, &request);
6967 }
6968
6969 return 0;
6970}
6971
6972static int ci_dpm_read_sensor(void *handle, int idx, 6720static int ci_dpm_read_sensor(void *handle, int idx,
6973 void *value, int *size) 6721 void *value, int *size)
6974{ 6722{
@@ -7053,10 +6801,6 @@ const struct amd_pm_funcs ci_dpm_funcs = {
7053 .set_mclk_od = ci_dpm_set_mclk_od, 6801 .set_mclk_od = ci_dpm_set_mclk_od,
7054 .check_state_equal = ci_check_state_equal, 6802 .check_state_equal = ci_check_state_equal,
7055 .get_vce_clock_state = amdgpu_get_vce_clock_state, 6803 .get_vce_clock_state = amdgpu_get_vce_clock_state,
7056 .get_power_profile_state = ci_dpm_get_power_profile_state,
7057 .set_power_profile_state = ci_dpm_set_power_profile_state,
7058 .reset_power_profile_state = ci_dpm_reset_power_profile_state,
7059 .switch_power_profile = ci_dpm_switch_power_profile,
7060 .read_sensor = ci_dpm_read_sensor, 6804 .read_sensor = ci_dpm_read_sensor,
7061}; 6805};
7062 6806
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.h b/drivers/gpu/drm/amd/amdgpu/ci_dpm.h
index 84cbc9c45f4d..91be2996ae7c 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.h
@@ -295,13 +295,6 @@ struct ci_power_info {
295 bool fan_is_controlled_by_smc; 295 bool fan_is_controlled_by_smc;
296 u32 t_min; 296 u32 t_min;
297 u32 fan_ctrl_default_mode; 297 u32 fan_ctrl_default_mode;
298
299 /* power profile */
300 struct amd_pp_profile gfx_power_profile;
301 struct amd_pp_profile compute_power_profile;
302 struct amd_pp_profile default_gfx_power_profile;
303 struct amd_pp_profile default_compute_power_profile;
304 enum amd_pp_profile_type current_power_profile;
305}; 298};
306 299
307#define CISLANDS_VOLTAGE_CONTROL_NONE 0x0 300#define CISLANDS_VOLTAGE_CONTROL_NONE 0x0
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index 666a9e343270..e482daf394d3 100644
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
@@ -252,13 +252,6 @@ struct amd_pm_funcs {
252 int (*get_pp_table)(void *handle, char **table); 252 int (*get_pp_table)(void *handle, char **table);
253 int (*set_pp_table)(void *handle, const char *buf, size_t size); 253 int (*set_pp_table)(void *handle, const char *buf, size_t size);
254 void (*debugfs_print_current_performance_level)(void *handle, struct seq_file *m); 254 void (*debugfs_print_current_performance_level)(void *handle, struct seq_file *m);
255
256 int (*reset_power_profile_state)(void *handle,
257 struct amd_pp_profile *request);
258 int (*get_power_profile_state)(void *handle,
259 struct amd_pp_profile *query);
260 int (*set_power_profile_state)(void *handle,
261 struct amd_pp_profile *request);
262 int (*switch_power_profile)(void *handle, 255 int (*switch_power_profile)(void *handle,
263 enum amd_pp_profile_type type); 256 enum amd_pp_profile_type type);
264/* export to amdgpu */ 257/* export to amdgpu */
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 20ac0fc12483..a8705b5ad264 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -1018,58 +1018,6 @@ pp_dpm_get_vce_clock_state(void *handle, unsigned idx)
1018 return NULL; 1018 return NULL;
1019} 1019}
1020 1020
1021static int pp_dpm_reset_power_profile_state(void *handle,
1022 struct amd_pp_profile *request)
1023{
1024 struct pp_hwmgr *hwmgr;
1025 struct pp_instance *pp_handle = (struct pp_instance *)handle;
1026
1027 if (!request || pp_check(pp_handle))
1028 return -EINVAL;
1029
1030 hwmgr = pp_handle->hwmgr;
1031
1032 if (hwmgr->hwmgr_func->set_power_profile_state == NULL) {
1033 pr_info("%s was not implemented.\n", __func__);
1034 return 0;
1035 }
1036
1037 if (request->type == AMD_PP_GFX_PROFILE) {
1038 hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile;
1039 return hwmgr->hwmgr_func->set_power_profile_state(hwmgr,
1040 &hwmgr->gfx_power_profile);
1041 } else if (request->type == AMD_PP_COMPUTE_PROFILE) {
1042 hwmgr->compute_power_profile =
1043 hwmgr->default_compute_power_profile;
1044 return hwmgr->hwmgr_func->set_power_profile_state(hwmgr,
1045 &hwmgr->compute_power_profile);
1046 } else
1047 return -EINVAL;
1048}
1049
1050static int pp_dpm_get_power_profile_state(void *handle,
1051 struct amd_pp_profile *query)
1052{
1053 struct pp_hwmgr *hwmgr;
1054 struct pp_instance *pp_handle = (struct pp_instance *)handle;
1055
1056 if (!query || pp_check(pp_handle))
1057 return -EINVAL;
1058
1059 hwmgr = pp_handle->hwmgr;
1060
1061 if (query->type == AMD_PP_GFX_PROFILE)
1062 memcpy(query, &hwmgr->gfx_power_profile,
1063 sizeof(struct amd_pp_profile));
1064 else if (query->type == AMD_PP_COMPUTE_PROFILE)
1065 memcpy(query, &hwmgr->compute_power_profile,
1066 sizeof(struct amd_pp_profile));
1067 else
1068 return -EINVAL;
1069
1070 return 0;
1071}
1072
1073static int pp_get_power_profile_mode(void *handle, char *buf) 1021static int pp_get_power_profile_mode(void *handle, char *buf)
1074{ 1022{
1075 struct pp_hwmgr *hwmgr; 1023 struct pp_hwmgr *hwmgr;
@@ -1128,65 +1076,6 @@ static int pp_odn_edit_dpm_table(void *handle, uint32_t type, long *input, uint3
1128 return hwmgr->hwmgr_func->odn_edit_dpm_table(hwmgr, type, input, size); 1076 return hwmgr->hwmgr_func->odn_edit_dpm_table(hwmgr, type, input, size);
1129} 1077}
1130 1078
1131static int pp_dpm_set_power_profile_state(void *handle,
1132 struct amd_pp_profile *request)
1133{
1134 struct pp_hwmgr *hwmgr;
1135 struct pp_instance *pp_handle = (struct pp_instance *)handle;
1136 int ret = -1;
1137
1138 if (!request || pp_check(pp_handle))
1139 return -EINVAL;
1140
1141 hwmgr = pp_handle->hwmgr;
1142
1143 if (hwmgr->hwmgr_func->set_power_profile_state == NULL) {
1144 pr_info("%s was not implemented.\n", __func__);
1145 return 0;
1146 }
1147
1148 if (request->min_sclk ||
1149 request->min_mclk ||
1150 request->activity_threshold ||
1151 request->up_hyst ||
1152 request->down_hyst) {
1153 if (request->type == AMD_PP_GFX_PROFILE)
1154 memcpy(&hwmgr->gfx_power_profile, request,
1155 sizeof(struct amd_pp_profile));
1156 else if (request->type == AMD_PP_COMPUTE_PROFILE)
1157 memcpy(&hwmgr->compute_power_profile, request,
1158 sizeof(struct amd_pp_profile));
1159 else
1160 return -EINVAL;
1161
1162 if (request->type == hwmgr->current_power_profile)
1163 ret = hwmgr->hwmgr_func->set_power_profile_state(
1164 hwmgr,
1165 request);
1166 } else {
1167 /* set power profile if it exists */
1168 switch (request->type) {
1169 case AMD_PP_GFX_PROFILE:
1170 ret = hwmgr->hwmgr_func->set_power_profile_state(
1171 hwmgr,
1172 &hwmgr->gfx_power_profile);
1173 break;
1174 case AMD_PP_COMPUTE_PROFILE:
1175 ret = hwmgr->hwmgr_func->set_power_profile_state(
1176 hwmgr,
1177 &hwmgr->compute_power_profile);
1178 break;
1179 default:
1180 return -EINVAL;
1181 }
1182 }
1183
1184 if (!ret)
1185 hwmgr->current_power_profile = request->type;
1186
1187 return 0;
1188}
1189
1190static int pp_dpm_switch_power_profile(void *handle, 1079static int pp_dpm_switch_power_profile(void *handle,
1191 enum amd_pp_profile_type type) 1080 enum amd_pp_profile_type type)
1192{ 1081{
@@ -1584,9 +1473,6 @@ const struct amd_pm_funcs pp_dpm_funcs = {
1584 .set_mclk_od = pp_dpm_set_mclk_od, 1473 .set_mclk_od = pp_dpm_set_mclk_od,
1585 .read_sensor = pp_dpm_read_sensor, 1474 .read_sensor = pp_dpm_read_sensor,
1586 .get_vce_clock_state = pp_dpm_get_vce_clock_state, 1475 .get_vce_clock_state = pp_dpm_get_vce_clock_state,
1587 .reset_power_profile_state = pp_dpm_reset_power_profile_state,
1588 .get_power_profile_state = pp_dpm_get_power_profile_state,
1589 .set_power_profile_state = pp_dpm_set_power_profile_state,
1590 .switch_power_profile = pp_dpm_switch_power_profile, 1476 .switch_power_profile = pp_dpm_switch_power_profile,
1591 .set_clockgating_by_smu = pp_set_clockgating_by_smu, 1477 .set_clockgating_by_smu = pp_set_clockgating_by_smu,
1592 .notify_smu_memory_info = pp_dpm_notify_smu_memory_info, 1478 .notify_smu_memory_info = pp_dpm_notify_smu_memory_info,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
index 33480deb64b9..f06f8f42e776 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
@@ -128,23 +128,6 @@ int phm_force_dpm_levels(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level
128 return ret; 128 return ret;
129} 129}
130 130
131int phm_reset_power_profile_state(struct pp_hwmgr *hwmgr)
132{
133 int ret = 0;
134
135 if (hwmgr->hwmgr_func->set_power_profile_state) {
136 if (hwmgr->current_power_profile == AMD_PP_GFX_PROFILE)
137 ret = hwmgr->hwmgr_func->set_power_profile_state(
138 hwmgr,
139 &hwmgr->gfx_power_profile);
140 else if (hwmgr->current_power_profile == AMD_PP_COMPUTE_PROFILE)
141 ret = hwmgr->hwmgr_func->set_power_profile_state(
142 hwmgr,
143 &hwmgr->compute_power_profile);
144 }
145 return ret;
146}
147
148int phm_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, 131int phm_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
149 struct pp_power_state *adjusted_ps, 132 struct pp_power_state *adjusted_ps,
150 const struct pp_power_state *current_ps) 133 const struct pp_power_state *current_ps)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c
index 95ab772e0c3e..ed3bd1502c0d 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c
@@ -247,8 +247,6 @@ int psm_adjust_power_state_dynamic(struct pp_hwmgr *hwmgr, bool skip,
247 if (!phm_force_dpm_levels(hwmgr, hwmgr->request_dpm_level)) 247 if (!phm_force_dpm_levels(hwmgr, hwmgr->request_dpm_level))
248 hwmgr->dpm_level = hwmgr->request_dpm_level; 248 hwmgr->dpm_level = hwmgr->request_dpm_level;
249 249
250 phm_reset_power_profile_state(hwmgr);
251
252 return 0; 250 return 0;
253} 251}
254 252
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 3f894bc85c25..58e2e0a10b3d 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -4584,82 +4584,6 @@ static int smu7_get_clock_by_type(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type
4584 return 0; 4584 return 0;
4585} 4585}
4586 4586
4587static void smu7_find_min_clock_masks(struct pp_hwmgr *hwmgr,
4588 uint32_t *sclk_mask, uint32_t *mclk_mask,
4589 uint32_t min_sclk, uint32_t min_mclk)
4590{
4591 struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
4592 struct smu7_dpm_table *dpm_table = &(data->dpm_table);
4593 uint32_t i;
4594
4595 for (i = 0; i < dpm_table->sclk_table.count; i++) {
4596 if (dpm_table->sclk_table.dpm_levels[i].enabled &&
4597 dpm_table->sclk_table.dpm_levels[i].value >= min_sclk)
4598 *sclk_mask |= 1 << i;
4599 }
4600
4601 for (i = 0; i < dpm_table->mclk_table.count; i++) {
4602 if (dpm_table->mclk_table.dpm_levels[i].enabled &&
4603 dpm_table->mclk_table.dpm_levels[i].value >= min_mclk)
4604 *mclk_mask |= 1 << i;
4605 }
4606}
4607
4608static int smu7_set_power_profile_state(struct pp_hwmgr *hwmgr,
4609 struct amd_pp_profile *request)
4610{
4611 struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
4612 int tmp_result, result = 0;
4613 uint32_t sclk_mask = 0, mclk_mask = 0;
4614
4615 if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_AUTO)
4616 return -EINVAL;
4617
4618 if (smum_is_dpm_running(hwmgr)) {
4619 if (!data->sclk_dpm_key_disabled)
4620 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_SCLKDPM_FreezeLevel);
4621
4622 if (!data->mclk_dpm_key_disabled)
4623 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_MCLKDPM_FreezeLevel);
4624 }
4625
4626 tmp_result = smum_populate_requested_graphic_levels(hwmgr, request);
4627 PP_ASSERT_WITH_CODE(!tmp_result,
4628 "Failed to populate requested graphic levels!",
4629 result = tmp_result);
4630
4631 if (smum_is_dpm_running(hwmgr)) {
4632 if (!data->sclk_dpm_key_disabled)
4633 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_SCLKDPM_UnfreezeLevel);
4634
4635 if (!data->mclk_dpm_key_disabled)
4636 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_MCLKDPM_UnfreezeLevel);
4637 }
4638
4639 smu7_find_min_clock_masks(hwmgr, &sclk_mask, &mclk_mask,
4640 request->min_sclk, request->min_mclk);
4641
4642 if (sclk_mask) {
4643 if (!data->sclk_dpm_key_disabled)
4644 smum_send_msg_to_smc_with_parameter(hwmgr,
4645 PPSMC_MSG_SCLKDPM_SetEnabledMask,
4646 data->dpm_level_enable_mask.
4647 sclk_dpm_enable_mask &
4648 sclk_mask);
4649 }
4650
4651 if (mclk_mask) {
4652 if (!data->mclk_dpm_key_disabled)
4653 smum_send_msg_to_smc_with_parameter(hwmgr,
4654 PPSMC_MSG_MCLKDPM_SetEnabledMask,
4655 data->dpm_level_enable_mask.
4656 mclk_dpm_enable_mask &
4657 mclk_mask);
4658 }
4659
4660 return result;
4661}
4662
4663static int smu7_notify_cac_buffer_info(struct pp_hwmgr *hwmgr, 4587static int smu7_notify_cac_buffer_info(struct pp_hwmgr *hwmgr,
4664 uint32_t virtual_addr_low, 4588 uint32_t virtual_addr_low,
4665 uint32_t virtual_addr_hi, 4589 uint32_t virtual_addr_hi,
@@ -5104,7 +5028,6 @@ static const struct pp_hwmgr_func smu7_hwmgr_funcs = {
5104 .get_clock_by_type = smu7_get_clock_by_type, 5028 .get_clock_by_type = smu7_get_clock_by_type,
5105 .read_sensor = smu7_read_sensor, 5029 .read_sensor = smu7_read_sensor,
5106 .dynamic_state_management_disable = smu7_disable_dpm_tasks, 5030 .dynamic_state_management_disable = smu7_disable_dpm_tasks,
5107 .set_power_profile_state = smu7_set_power_profile_state,
5108 .avfs_control = smu7_avfs_control, 5031 .avfs_control = smu7_avfs_control,
5109 .disable_smc_firmware_ctf = smu7_thermal_disable_alert, 5032 .disable_smc_firmware_ctf = smu7_thermal_disable_alert,
5110 .start_thermal_controller = smu7_start_thermal_controller, 5033 .start_thermal_controller = smu7_start_thermal_controller,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index 1596fd84627a..d90a0f1dbb55 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -2408,34 +2408,6 @@ static int vega10_populate_and_upload_avfs_fuse_override(struct pp_hwmgr *hwmgr)
2408 return result; 2408 return result;
2409} 2409}
2410 2410
2411static int vega10_save_default_power_profile(struct pp_hwmgr *hwmgr)
2412{
2413 struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
2414 struct vega10_single_dpm_table *dpm_table = &(data->dpm_table.gfx_table);
2415 uint32_t min_level;
2416
2417 hwmgr->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE;
2418 hwmgr->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE;
2419
2420 /* Optimize compute power profile: Use only highest
2421 * 2 power levels (if more than 2 are available)
2422 */
2423 if (dpm_table->count > 2)
2424 min_level = dpm_table->count - 2;
2425 else if (dpm_table->count == 2)
2426 min_level = 1;
2427 else
2428 min_level = 0;
2429
2430 hwmgr->default_compute_power_profile.min_sclk =
2431 dpm_table->dpm_levels[min_level].value;
2432
2433 hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile;
2434 hwmgr->compute_power_profile = hwmgr->default_compute_power_profile;
2435
2436 return 0;
2437}
2438
2439/** 2411/**
2440* Initializes the SMC table and uploads it 2412* Initializes the SMC table and uploads it
2441* 2413*
@@ -2579,7 +2551,6 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr)
2579 PP_ASSERT_WITH_CODE(!result, "Attempt to enable AVFS feature Failed!", 2551 PP_ASSERT_WITH_CODE(!result, "Attempt to enable AVFS feature Failed!",
2580 return result); 2552 return result);
2581 vega10_acg_enable(hwmgr); 2553 vega10_acg_enable(hwmgr);
2582 vega10_save_default_power_profile(hwmgr);
2583 2554
2584 return 0; 2555 return 0;
2585} 2556}
@@ -4754,62 +4725,6 @@ static int vega10_power_off_asic(struct pp_hwmgr *hwmgr)
4754 return result; 4725 return result;
4755} 4726}
4756 4727
4757static void vega10_find_min_clock_index(struct pp_hwmgr *hwmgr,
4758 uint32_t *sclk_idx, uint32_t *mclk_idx,
4759 uint32_t min_sclk, uint32_t min_mclk)
4760{
4761 struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
4762 struct vega10_dpm_table *dpm_table = &(data->dpm_table);
4763 uint32_t i;
4764
4765 for (i = 0; i < dpm_table->gfx_table.count; i++) {
4766 if (dpm_table->gfx_table.dpm_levels[i].enabled &&
4767 dpm_table->gfx_table.dpm_levels[i].value >= min_sclk) {
4768 *sclk_idx = i;
4769 break;
4770 }
4771 }
4772
4773 for (i = 0; i < dpm_table->mem_table.count; i++) {
4774 if (dpm_table->mem_table.dpm_levels[i].enabled &&
4775 dpm_table->mem_table.dpm_levels[i].value >= min_mclk) {
4776 *mclk_idx = i;
4777 break;
4778 }
4779 }
4780}
4781
4782static int vega10_set_power_profile_state(struct pp_hwmgr *hwmgr,
4783 struct amd_pp_profile *request)
4784{
4785 struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
4786 uint32_t sclk_idx = ~0, mclk_idx = ~0;
4787
4788 if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_AUTO)
4789 return -EINVAL;
4790
4791 vega10_find_min_clock_index(hwmgr, &sclk_idx, &mclk_idx,
4792 request->min_sclk, request->min_mclk);
4793
4794 if (sclk_idx != ~0) {
4795 if (!data->registry_data.sclk_dpm_key_disabled)
4796 smum_send_msg_to_smc_with_parameter(
4797 hwmgr,
4798 PPSMC_MSG_SetSoftMinGfxclkByIndex,
4799 sclk_idx);
4800 }
4801
4802 if (mclk_idx != ~0) {
4803 if (!data->registry_data.mclk_dpm_key_disabled)
4804 smum_send_msg_to_smc_with_parameter(
4805 hwmgr,
4806 PPSMC_MSG_SetSoftMinUclkByIndex,
4807 mclk_idx);
4808 }
4809
4810 return 0;
4811}
4812
4813static int vega10_get_sclk_od(struct pp_hwmgr *hwmgr) 4728static int vega10_get_sclk_od(struct pp_hwmgr *hwmgr)
4814{ 4729{
4815 struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); 4730 struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
@@ -5103,7 +5018,6 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
5103 vega10_check_smc_update_required_for_display_configuration, 5018 vega10_check_smc_update_required_for_display_configuration,
5104 .power_off_asic = vega10_power_off_asic, 5019 .power_off_asic = vega10_power_off_asic,
5105 .disable_smc_firmware_ctf = vega10_thermal_disable_alert, 5020 .disable_smc_firmware_ctf = vega10_thermal_disable_alert,
5106 .set_power_profile_state = vega10_set_power_profile_state,
5107 .get_sclk_od = vega10_get_sclk_od, 5021 .get_sclk_od = vega10_get_sclk_od,
5108 .set_sclk_od = vega10_set_sclk_od, 5022 .set_sclk_od = vega10_set_sclk_od,
5109 .get_mclk_od = vega10_get_mclk_od, 5023 .get_mclk_od = vega10_get_mclk_od,
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h
index 6f528e662a6f..b366a5bd2d81 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h
@@ -448,6 +448,5 @@ extern int phm_display_clock_voltage_request(struct pp_hwmgr *hwmgr,
448 448
449extern int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); 449extern int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks);
450extern int phm_disable_smc_firmware_ctf(struct pp_hwmgr *hwmgr); 450extern int phm_disable_smc_firmware_ctf(struct pp_hwmgr *hwmgr);
451extern int phm_reset_power_profile_state(struct pp_hwmgr *hwmgr);
452#endif /* _HARDWARE_MANAGER_H_ */ 451#endif /* _HARDWARE_MANAGER_H_ */
453 452
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 2dc2e2c20a3a..65224dbb550d 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -236,8 +236,6 @@ struct pp_smumgr_func {
236 uint32_t (*get_offsetof)(uint32_t type, uint32_t member); 236 uint32_t (*get_offsetof)(uint32_t type, uint32_t member);
237 uint32_t (*get_mac_definition)(uint32_t value); 237 uint32_t (*get_mac_definition)(uint32_t value);
238 bool (*is_dpm_running)(struct pp_hwmgr *hwmgr); 238 bool (*is_dpm_running)(struct pp_hwmgr *hwmgr);
239 int (*populate_requested_graphic_levels)(struct pp_hwmgr *hwmgr,
240 struct amd_pp_profile *request);
241 bool (*is_hw_avfs_present)(struct pp_hwmgr *hwmgr); 239 bool (*is_hw_avfs_present)(struct pp_hwmgr *hwmgr);
242 int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void *profile_setting); 240 int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void *profile_setting);
243}; 241};
@@ -329,8 +327,6 @@ struct pp_hwmgr_func {
329 int (*get_mclk_od)(struct pp_hwmgr *hwmgr); 327 int (*get_mclk_od)(struct pp_hwmgr *hwmgr);
330 int (*set_mclk_od)(struct pp_hwmgr *hwmgr, uint32_t value); 328 int (*set_mclk_od)(struct pp_hwmgr *hwmgr, uint32_t value);
331 int (*read_sensor)(struct pp_hwmgr *hwmgr, int idx, void *value, int *size); 329 int (*read_sensor)(struct pp_hwmgr *hwmgr, int idx, void *value, int *size);
332 int (*set_power_profile_state)(struct pp_hwmgr *hwmgr,
333 struct amd_pp_profile *request);
334 int (*avfs_control)(struct pp_hwmgr *hwmgr, bool enable); 330 int (*avfs_control)(struct pp_hwmgr *hwmgr, bool enable);
335 int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr); 331 int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr);
336 int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count); 332 int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count);
@@ -753,11 +749,6 @@ struct pp_hwmgr {
753 uint32_t feature_mask; 749 uint32_t feature_mask;
754 750
755 /* UMD Pstate */ 751 /* UMD Pstate */
756 struct amd_pp_profile gfx_power_profile;
757 struct amd_pp_profile compute_power_profile;
758 struct amd_pp_profile default_gfx_power_profile;
759 struct amd_pp_profile default_compute_power_profile;
760 enum amd_pp_profile_type current_power_profile;
761 bool en_umd_pstate; 752 bool en_umd_pstate;
762 uint32_t power_profile_mode; 753 uint32_t power_profile_mode;
763 uint32_t default_power_profile_mode; 754 uint32_t default_power_profile_mode;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
index e05a57e2eedc..e1f6e830c84d 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
@@ -129,9 +129,6 @@ extern uint32_t smum_get_mac_definition(struct pp_hwmgr *hwmgr, uint32_t value);
129 129
130extern bool smum_is_dpm_running(struct pp_hwmgr *hwmgr); 130extern bool smum_is_dpm_running(struct pp_hwmgr *hwmgr);
131 131
132extern int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
133 struct amd_pp_profile *request);
134
135extern bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr); 132extern bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr);
136 133
137extern int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, void *profile_setting); 134extern int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, void *profile_setting);
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
index 179d00cd5514..5d6dfdfbbbb6 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
@@ -2766,32 +2766,6 @@ static bool ci_is_dpm_running(struct pp_hwmgr *hwmgr)
2766 return ci_is_smc_ram_running(hwmgr); 2766 return ci_is_smc_ram_running(hwmgr);
2767} 2767}
2768 2768
2769static int ci_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
2770 struct amd_pp_profile *request)
2771{
2772 struct ci_smumgr *smu_data = (struct ci_smumgr *)
2773 (hwmgr->smu_backend);
2774 struct SMU7_Discrete_GraphicsLevel *levels =
2775 smu_data->smc_state_table.GraphicsLevel;
2776 uint32_t array = smu_data->dpm_table_start +
2777 offsetof(SMU7_Discrete_DpmTable, GraphicsLevel);
2778 uint32_t array_size = sizeof(struct SMU7_Discrete_GraphicsLevel) *
2779 SMU7_MAX_LEVELS_GRAPHICS;
2780 uint32_t i;
2781
2782 for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) {
2783 levels[i].ActivityLevel =
2784 cpu_to_be16(request->activity_threshold);
2785 levels[i].EnabledForActivity = 1;
2786 levels[i].UpH = request->up_hyst;
2787 levels[i].DownH = request->down_hyst;
2788 }
2789
2790 return ci_copy_bytes_to_smc(hwmgr, array, (uint8_t *)levels,
2791 array_size, SMC_RAM_END);
2792}
2793
2794
2795static int ci_smu_init(struct pp_hwmgr *hwmgr) 2769static int ci_smu_init(struct pp_hwmgr *hwmgr)
2796{ 2770{
2797 struct ci_smumgr *ci_priv = NULL; 2771 struct ci_smumgr *ci_priv = NULL;
@@ -2936,6 +2910,5 @@ const struct pp_smumgr_func ci_smu_funcs = {
2936 .get_mac_definition = ci_get_mac_definition, 2910 .get_mac_definition = ci_get_mac_definition,
2937 .initialize_mc_reg_table = ci_initialize_mc_reg_table, 2911 .initialize_mc_reg_table = ci_initialize_mc_reg_table,
2938 .is_dpm_running = ci_is_dpm_running, 2912 .is_dpm_running = ci_is_dpm_running,
2939 .populate_requested_graphic_levels = ci_populate_requested_graphic_levels,
2940 .update_dpm_settings = ci_update_dpm_settings, 2913 .update_dpm_settings = ci_update_dpm_settings,
2941}; 2914};
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
index fc556f0af021..0b2b5d155e5e 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
@@ -1960,44 +1960,6 @@ static int fiji_init_arb_table_index(struct pp_hwmgr *hwmgr)
1960 smu_data->smu7_data.arb_table_start, tmp, SMC_RAM_END); 1960 smu_data->smu7_data.arb_table_start, tmp, SMC_RAM_END);
1961} 1961}
1962 1962
1963static int fiji_save_default_power_profile(struct pp_hwmgr *hwmgr)
1964{
1965 struct fiji_smumgr *data = (struct fiji_smumgr *)(hwmgr->smu_backend);
1966 struct SMU73_Discrete_GraphicsLevel *levels =
1967 data->smc_state_table.GraphicsLevel;
1968 unsigned min_level = 1;
1969
1970 hwmgr->default_gfx_power_profile.activity_threshold =
1971 be16_to_cpu(levels[0].ActivityLevel);
1972 hwmgr->default_gfx_power_profile.up_hyst = levels[0].UpHyst;
1973 hwmgr->default_gfx_power_profile.down_hyst = levels[0].DownHyst;
1974 hwmgr->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE;
1975
1976 hwmgr->default_compute_power_profile = hwmgr->default_gfx_power_profile;
1977 hwmgr->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE;
1978
1979 /* Workaround compute SDMA instability: disable lowest SCLK
1980 * DPM level. Optimize compute power profile: Use only highest
1981 * 2 power levels (if more than 2 are available), Hysteresis:
1982 * 0ms up, 5ms down
1983 */
1984 if (data->smc_state_table.GraphicsDpmLevelCount > 2)
1985 min_level = data->smc_state_table.GraphicsDpmLevelCount - 2;
1986 else if (data->smc_state_table.GraphicsDpmLevelCount == 2)
1987 min_level = 1;
1988 else
1989 min_level = 0;
1990 hwmgr->default_compute_power_profile.min_sclk =
1991 be32_to_cpu(levels[min_level].SclkFrequency);
1992 hwmgr->default_compute_power_profile.up_hyst = 0;
1993 hwmgr->default_compute_power_profile.down_hyst = 5;
1994
1995 hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile;
1996 hwmgr->compute_power_profile = hwmgr->default_compute_power_profile;
1997
1998 return 0;
1999}
2000
2001static int fiji_setup_dpm_led_config(struct pp_hwmgr *hwmgr) 1963static int fiji_setup_dpm_led_config(struct pp_hwmgr *hwmgr)
2002{ 1964{
2003 pp_atomctrl_voltage_table param_led_dpm; 1965 pp_atomctrl_voltage_table param_led_dpm;
@@ -2238,8 +2200,6 @@ static int fiji_init_smc_table(struct pp_hwmgr *hwmgr)
2238 PP_ASSERT_WITH_CODE(0 == result, 2200 PP_ASSERT_WITH_CODE(0 == result,
2239 "Failed to setup dpm led config", return result); 2201 "Failed to setup dpm led config", return result);
2240 2202
2241 fiji_save_default_power_profile(hwmgr);
2242
2243 return 0; 2203 return 0;
2244} 2204}
2245 2205
@@ -2694,31 +2654,6 @@ static bool fiji_is_dpm_running(struct pp_hwmgr *hwmgr)
2694 ? true : false; 2654 ? true : false;
2695} 2655}
2696 2656
2697static int fiji_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
2698 struct amd_pp_profile *request)
2699{
2700 struct fiji_smumgr *smu_data = (struct fiji_smumgr *)
2701 (hwmgr->smu_backend);
2702 struct SMU73_Discrete_GraphicsLevel *levels =
2703 smu_data->smc_state_table.GraphicsLevel;
2704 uint32_t array = smu_data->smu7_data.dpm_table_start +
2705 offsetof(SMU73_Discrete_DpmTable, GraphicsLevel);
2706 uint32_t array_size = sizeof(struct SMU73_Discrete_GraphicsLevel) *
2707 SMU73_MAX_LEVELS_GRAPHICS;
2708 uint32_t i;
2709
2710 for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) {
2711 levels[i].ActivityLevel =
2712 cpu_to_be16(request->activity_threshold);
2713 levels[i].EnabledForActivity = 1;
2714 levels[i].UpHyst = request->up_hyst;
2715 levels[i].DownHyst = request->down_hyst;
2716 }
2717
2718 return smu7_copy_bytes_to_smc(hwmgr, array, (uint8_t *)levels,
2719 array_size, SMC_RAM_END);
2720}
2721
2722static int fiji_update_dpm_settings(struct pp_hwmgr *hwmgr, 2657static int fiji_update_dpm_settings(struct pp_hwmgr *hwmgr,
2723 void *profile_setting) 2658 void *profile_setting)
2724{ 2659{
@@ -2838,7 +2773,6 @@ const struct pp_smumgr_func fiji_smu_funcs = {
2838 .get_mac_definition = fiji_get_mac_definition, 2773 .get_mac_definition = fiji_get_mac_definition,
2839 .initialize_mc_reg_table = fiji_initialize_mc_reg_table, 2774 .initialize_mc_reg_table = fiji_initialize_mc_reg_table,
2840 .is_dpm_running = fiji_is_dpm_running, 2775 .is_dpm_running = fiji_is_dpm_running,
2841 .populate_requested_graphic_levels = fiji_populate_requested_graphic_levels,
2842 .is_hw_avfs_present = fiji_is_hw_avfs_present, 2776 .is_hw_avfs_present = fiji_is_hw_avfs_present,
2843 .update_dpm_settings = fiji_update_dpm_settings, 2777 .update_dpm_settings = fiji_update_dpm_settings,
2844}; 2778};
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
index 757824875935..632d1ca2f69c 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
@@ -1840,42 +1840,6 @@ static void polaris10_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
1840 1840
1841} 1841}
1842 1842
1843static void polaris10_save_default_power_profile(struct pp_hwmgr *hwmgr)
1844{
1845 struct polaris10_smumgr *data = (struct polaris10_smumgr *)(hwmgr->smu_backend);
1846 struct SMU74_Discrete_GraphicsLevel *levels =
1847 data->smc_state_table.GraphicsLevel;
1848 unsigned min_level = 1;
1849
1850 hwmgr->default_gfx_power_profile.activity_threshold =
1851 be16_to_cpu(levels[0].ActivityLevel);
1852 hwmgr->default_gfx_power_profile.up_hyst = levels[0].UpHyst;
1853 hwmgr->default_gfx_power_profile.down_hyst = levels[0].DownHyst;
1854 hwmgr->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE;
1855
1856 hwmgr->default_compute_power_profile = hwmgr->default_gfx_power_profile;
1857 hwmgr->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE;
1858
1859 /* Workaround compute SDMA instability: disable lowest SCLK
1860 * DPM level. Optimize compute power profile: Use only highest
1861 * 2 power levels (if more than 2 are available), Hysteresis:
1862 * 0ms up, 5ms down
1863 */
1864 if (data->smc_state_table.GraphicsDpmLevelCount > 2)
1865 min_level = data->smc_state_table.GraphicsDpmLevelCount - 2;
1866 else if (data->smc_state_table.GraphicsDpmLevelCount == 2)
1867 min_level = 1;
1868 else
1869 min_level = 0;
1870 hwmgr->default_compute_power_profile.min_sclk =
1871 be32_to_cpu(levels[min_level].SclkSetting.SclkFrequency);
1872 hwmgr->default_compute_power_profile.up_hyst = 0;
1873 hwmgr->default_compute_power_profile.down_hyst = 5;
1874
1875 hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile;
1876 hwmgr->compute_power_profile = hwmgr->default_compute_power_profile;
1877}
1878
1879static int polaris10_init_smc_table(struct pp_hwmgr *hwmgr) 1843static int polaris10_init_smc_table(struct pp_hwmgr *hwmgr)
1880{ 1844{
1881 int result; 1845 int result;
@@ -2090,8 +2054,6 @@ static int polaris10_init_smc_table(struct pp_hwmgr *hwmgr)
2090 PP_ASSERT_WITH_CODE(0 == result, 2054 PP_ASSERT_WITH_CODE(0 == result,
2091 "Failed to populate PM fuses to SMC memory!", return result); 2055 "Failed to populate PM fuses to SMC memory!", return result);
2092 2056
2093 polaris10_save_default_power_profile(hwmgr);
2094
2095 return 0; 2057 return 0;
2096} 2058}
2097 2059
@@ -2550,31 +2512,6 @@ static bool polaris10_is_dpm_running(struct pp_hwmgr *hwmgr)
2550 ? true : false; 2512 ? true : false;
2551} 2513}
2552 2514
2553static int polaris10_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
2554 struct amd_pp_profile *request)
2555{
2556 struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)
2557 (hwmgr->smu_backend);
2558 struct SMU74_Discrete_GraphicsLevel *levels =
2559 smu_data->smc_state_table.GraphicsLevel;
2560 uint32_t array = smu_data->smu7_data.dpm_table_start +
2561 offsetof(SMU74_Discrete_DpmTable, GraphicsLevel);
2562 uint32_t array_size = sizeof(struct SMU74_Discrete_GraphicsLevel) *
2563 SMU74_MAX_LEVELS_GRAPHICS;
2564 uint32_t i;
2565
2566 for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) {
2567 levels[i].ActivityLevel =
2568 cpu_to_be16(request->activity_threshold);
2569 levels[i].EnabledForActivity = 1;
2570 levels[i].UpHyst = request->up_hyst;
2571 levels[i].DownHyst = request->down_hyst;
2572 }
2573
2574 return smu7_copy_bytes_to_smc(hwmgr, array, (uint8_t *)levels,
2575 array_size, SMC_RAM_END);
2576}
2577
2578static int polaris10_update_dpm_settings(struct pp_hwmgr *hwmgr, 2515static int polaris10_update_dpm_settings(struct pp_hwmgr *hwmgr,
2579 void *profile_setting) 2516 void *profile_setting)
2580{ 2517{
@@ -2693,7 +2630,6 @@ const struct pp_smumgr_func polaris10_smu_funcs = {
2693 .populate_all_memory_levels = polaris10_populate_all_memory_levels, 2630 .populate_all_memory_levels = polaris10_populate_all_memory_levels,
2694 .get_mac_definition = polaris10_get_mac_definition, 2631 .get_mac_definition = polaris10_get_mac_definition,
2695 .is_dpm_running = polaris10_is_dpm_running, 2632 .is_dpm_running = polaris10_is_dpm_running,
2696 .populate_requested_graphic_levels = polaris10_populate_requested_graphic_levels,
2697 .is_hw_avfs_present = polaris10_is_hw_avfs_present, 2633 .is_hw_avfs_present = polaris10_is_hw_avfs_present,
2698 .update_dpm_settings = polaris10_update_dpm_settings, 2634 .update_dpm_settings = polaris10_update_dpm_settings,
2699}; 2635};
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
index 1ce4959cba6e..43b1010ae7ee 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
@@ -236,16 +236,6 @@ bool smum_is_dpm_running(struct pp_hwmgr *hwmgr)
236 return true; 236 return true;
237} 237}
238 238
239int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
240 struct amd_pp_profile *request)
241{
242 if (hwmgr->smumgr_funcs->populate_requested_graphic_levels)
243 return hwmgr->smumgr_funcs->populate_requested_graphic_levels(
244 hwmgr, request);
245
246 return 0;
247}
248
249bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr) 239bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr)
250{ 240{
251 if (hwmgr->smumgr_funcs->is_hw_avfs_present) 241 if (hwmgr->smumgr_funcs->is_hw_avfs_present)
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
index 86fb7709a1c4..39d6f4ef96ce 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
@@ -2256,42 +2256,6 @@ static void tonga_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
2256 smu_data->power_tune_defaults = &tonga_power_tune_data_set_array[0]; 2256 smu_data->power_tune_defaults = &tonga_power_tune_data_set_array[0];
2257} 2257}
2258 2258
2259static void tonga_save_default_power_profile(struct pp_hwmgr *hwmgr)
2260{
2261 struct tonga_smumgr *data = (struct tonga_smumgr *)(hwmgr->smu_backend);
2262 struct SMU72_Discrete_GraphicsLevel *levels =
2263 data->smc_state_table.GraphicsLevel;
2264 unsigned min_level = 1;
2265
2266 hwmgr->default_gfx_power_profile.activity_threshold =
2267 be16_to_cpu(levels[0].ActivityLevel);
2268 hwmgr->default_gfx_power_profile.up_hyst = levels[0].UpHyst;
2269 hwmgr->default_gfx_power_profile.down_hyst = levels[0].DownHyst;
2270 hwmgr->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE;
2271
2272 hwmgr->default_compute_power_profile = hwmgr->default_gfx_power_profile;
2273 hwmgr->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE;
2274
2275 /* Workaround compute SDMA instability: disable lowest SCLK
2276 * DPM level. Optimize compute power profile: Use only highest
2277 * 2 power levels (if more than 2 are available), Hysteresis:
2278 * 0ms up, 5ms down
2279 */
2280 if (data->smc_state_table.GraphicsDpmLevelCount > 2)
2281 min_level = data->smc_state_table.GraphicsDpmLevelCount - 2;
2282 else if (data->smc_state_table.GraphicsDpmLevelCount == 2)
2283 min_level = 1;
2284 else
2285 min_level = 0;
2286 hwmgr->default_compute_power_profile.min_sclk =
2287 be32_to_cpu(levels[min_level].SclkFrequency);
2288 hwmgr->default_compute_power_profile.up_hyst = 0;
2289 hwmgr->default_compute_power_profile.down_hyst = 5;
2290
2291 hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile;
2292 hwmgr->compute_power_profile = hwmgr->default_compute_power_profile;
2293}
2294
2295static int tonga_init_smc_table(struct pp_hwmgr *hwmgr) 2259static int tonga_init_smc_table(struct pp_hwmgr *hwmgr)
2296{ 2260{
2297 int result; 2261 int result;
@@ -2533,8 +2497,6 @@ static int tonga_init_smc_table(struct pp_hwmgr *hwmgr)
2533 PP_ASSERT_WITH_CODE((!result), 2497 PP_ASSERT_WITH_CODE((!result),
2534 "Failed to populate initialize MC Reg table !", return result); 2498 "Failed to populate initialize MC Reg table !", return result);
2535 2499
2536 tonga_save_default_power_profile(hwmgr);
2537
2538 return 0; 2500 return 0;
2539} 2501}
2540 2502
@@ -3252,31 +3214,6 @@ static bool tonga_is_dpm_running(struct pp_hwmgr *hwmgr)
3252 ? true : false; 3214 ? true : false;
3253} 3215}
3254 3216
3255static int tonga_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
3256 struct amd_pp_profile *request)
3257{
3258 struct tonga_smumgr *smu_data = (struct tonga_smumgr *)
3259 (hwmgr->smu_backend);
3260 struct SMU72_Discrete_GraphicsLevel *levels =
3261 smu_data->smc_state_table.GraphicsLevel;
3262 uint32_t array = smu_data->smu7_data.dpm_table_start +
3263 offsetof(SMU72_Discrete_DpmTable, GraphicsLevel);
3264 uint32_t array_size = sizeof(struct SMU72_Discrete_GraphicsLevel) *
3265 SMU72_MAX_LEVELS_GRAPHICS;
3266 uint32_t i;
3267
3268 for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) {
3269 levels[i].ActivityLevel =
3270 cpu_to_be16(request->activity_threshold);
3271 levels[i].EnabledForActivity = 1;
3272 levels[i].UpHyst = request->up_hyst;
3273 levels[i].DownHyst = request->down_hyst;
3274 }
3275
3276 return smu7_copy_bytes_to_smc(hwmgr, array, (uint8_t *)levels,
3277 array_size, SMC_RAM_END);
3278}
3279
3280static int tonga_update_dpm_settings(struct pp_hwmgr *hwmgr, 3217static int tonga_update_dpm_settings(struct pp_hwmgr *hwmgr,
3281 void *profile_setting) 3218 void *profile_setting)
3282{ 3219{
@@ -3395,6 +3332,5 @@ const struct pp_smumgr_func tonga_smu_funcs = {
3395 .get_mac_definition = tonga_get_mac_definition, 3332 .get_mac_definition = tonga_get_mac_definition,
3396 .initialize_mc_reg_table = tonga_initialize_mc_reg_table, 3333 .initialize_mc_reg_table = tonga_initialize_mc_reg_table,
3397 .is_dpm_running = tonga_is_dpm_running, 3334 .is_dpm_running = tonga_is_dpm_running,
3398 .populate_requested_graphic_levels = tonga_populate_requested_graphic_levels,
3399 .update_dpm_settings = tonga_update_dpm_settings, 3335 .update_dpm_settings = tonga_update_dpm_settings,
3400}; 3336};