aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
diff options
context:
space:
mode:
authorRex Zhu <Rex.Zhu@amd.com>2017-09-06 03:27:59 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-09-18 23:30:34 -0400
commitcfa289fd4986c504b0396cce167802dfcf4943d0 (patch)
tree8c616086e99e4a5b777a22d8f6e95b22bd4d1a9d /drivers/gpu/drm/amd/amdgpu/kv_dpm.c
parent698f88e697cc8852558d120fdecfdb38c18c2ff7 (diff)
drm/amdgpu: rename amdgpu_dpm_funcs to amd_pm_funcs
renamed amdgpu_dpm_funcs and moved to amd_shared.h so can shared with powerplay. Reviewed-by: Alex Deucher <alexander.deucher@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/amd/amdgpu/kv_dpm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/kv_dpm.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
index 3bbf2ccfca89..f68d7abe1ed9 100644
--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
@@ -64,7 +64,7 @@ static int kv_set_thermal_temperature_range(struct amdgpu_device *adev,
64 int min_temp, int max_temp); 64 int min_temp, int max_temp);
65static int kv_init_fps_limits(struct amdgpu_device *adev); 65static int kv_init_fps_limits(struct amdgpu_device *adev);
66 66
67static void kv_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate); 67static void kv_dpm_powergate_uvd(void *handle, bool gate);
68static void kv_dpm_powergate_vce(struct amdgpu_device *adev, bool gate); 68static void kv_dpm_powergate_vce(struct amdgpu_device *adev, bool gate);
69static void kv_dpm_powergate_samu(struct amdgpu_device *adev, bool gate); 69static void kv_dpm_powergate_samu(struct amdgpu_device *adev, bool gate);
70static void kv_dpm_powergate_acp(struct amdgpu_device *adev, bool gate); 70static void kv_dpm_powergate_acp(struct amdgpu_device *adev, bool gate);
@@ -1245,8 +1245,9 @@ static void kv_update_requested_ps(struct amdgpu_device *adev,
1245 adev->pm.dpm.requested_ps = &pi->requested_rps; 1245 adev->pm.dpm.requested_ps = &pi->requested_rps;
1246} 1246}
1247 1247
1248static void kv_dpm_enable_bapm(struct amdgpu_device *adev, bool enable) 1248static void kv_dpm_enable_bapm(void *handle, bool enable)
1249{ 1249{
1250 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1250 struct kv_power_info *pi = kv_get_pi(adev); 1251 struct kv_power_info *pi = kv_get_pi(adev);
1251 int ret; 1252 int ret;
1252 1253
@@ -1672,8 +1673,9 @@ static int kv_update_acp_dpm(struct amdgpu_device *adev, bool gate)
1672 return kv_enable_acp_dpm(adev, !gate); 1673 return kv_enable_acp_dpm(adev, !gate);
1673} 1674}
1674 1675
1675static void kv_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate) 1676static void kv_dpm_powergate_uvd(void *handle, bool gate)
1676{ 1677{
1678 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1677 struct kv_power_info *pi = kv_get_pi(adev); 1679 struct kv_power_info *pi = kv_get_pi(adev);
1678 int ret; 1680 int ret;
1679 1681
@@ -1868,10 +1870,11 @@ static int kv_enable_nb_dpm(struct amdgpu_device *adev,
1868 return ret; 1870 return ret;
1869} 1871}
1870 1872
1871static int kv_dpm_force_performance_level(struct amdgpu_device *adev, 1873static int kv_dpm_force_performance_level(void *handle,
1872 enum amd_dpm_forced_level level) 1874 enum amd_dpm_forced_level level)
1873{ 1875{
1874 int ret; 1876 int ret;
1877 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1875 1878
1876 if (level == AMD_DPM_FORCED_LEVEL_HIGH) { 1879 if (level == AMD_DPM_FORCED_LEVEL_HIGH) {
1877 ret = kv_force_dpm_highest(adev); 1880 ret = kv_force_dpm_highest(adev);
@@ -1892,8 +1895,9 @@ static int kv_dpm_force_performance_level(struct amdgpu_device *adev,
1892 return 0; 1895 return 0;
1893} 1896}
1894 1897
1895static int kv_dpm_pre_set_power_state(struct amdgpu_device *adev) 1898static int kv_dpm_pre_set_power_state(void *handle)
1896{ 1899{
1900 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1897 struct kv_power_info *pi = kv_get_pi(adev); 1901 struct kv_power_info *pi = kv_get_pi(adev);
1898 struct amdgpu_ps requested_ps = *adev->pm.dpm.requested_ps; 1902 struct amdgpu_ps requested_ps = *adev->pm.dpm.requested_ps;
1899 struct amdgpu_ps *new_ps = &requested_ps; 1903 struct amdgpu_ps *new_ps = &requested_ps;
@@ -1907,8 +1911,9 @@ static int kv_dpm_pre_set_power_state(struct amdgpu_device *adev)
1907 return 0; 1911 return 0;
1908} 1912}
1909 1913
1910static int kv_dpm_set_power_state(struct amdgpu_device *adev) 1914static int kv_dpm_set_power_state(void *handle)
1911{ 1915{
1916 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1912 struct kv_power_info *pi = kv_get_pi(adev); 1917 struct kv_power_info *pi = kv_get_pi(adev);
1913 struct amdgpu_ps *new_ps = &pi->requested_rps; 1918 struct amdgpu_ps *new_ps = &pi->requested_rps;
1914 struct amdgpu_ps *old_ps = &pi->current_rps; 1919 struct amdgpu_ps *old_ps = &pi->current_rps;
@@ -1981,8 +1986,9 @@ static int kv_dpm_set_power_state(struct amdgpu_device *adev)
1981 return 0; 1986 return 0;
1982} 1987}
1983 1988
1984static void kv_dpm_post_set_power_state(struct amdgpu_device *adev) 1989static void kv_dpm_post_set_power_state(void *handle)
1985{ 1990{
1991 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1986 struct kv_power_info *pi = kv_get_pi(adev); 1992 struct kv_power_info *pi = kv_get_pi(adev);
1987 struct amdgpu_ps *new_ps = &pi->requested_rps; 1993 struct amdgpu_ps *new_ps = &pi->requested_rps;
1988 1994
@@ -2848,9 +2854,10 @@ static int kv_dpm_init(struct amdgpu_device *adev)
2848} 2854}
2849 2855
2850static void 2856static void
2851kv_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev, 2857kv_dpm_debugfs_print_current_performance_level(void *handle,
2852 struct seq_file *m) 2858 struct seq_file *m)
2853{ 2859{
2860 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
2854 struct kv_power_info *pi = kv_get_pi(adev); 2861 struct kv_power_info *pi = kv_get_pi(adev);
2855 u32 current_index = 2862 u32 current_index =
2856 (RREG32_SMC(ixTARGET_AND_CURRENT_PROFILE_INDEX) & 2863 (RREG32_SMC(ixTARGET_AND_CURRENT_PROFILE_INDEX) &
@@ -2875,11 +2882,12 @@ kv_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev,
2875} 2882}
2876 2883
2877static void 2884static void
2878kv_dpm_print_power_state(struct amdgpu_device *adev, 2885kv_dpm_print_power_state(void *handle, void *request_ps)
2879 struct amdgpu_ps *rps)
2880{ 2886{
2881 int i; 2887 int i;
2888 struct amdgpu_ps *rps = (struct amdgpu_ps *)request_ps;
2882 struct kv_ps *ps = kv_get_ps(rps); 2889 struct kv_ps *ps = kv_get_ps(rps);
2890 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
2883 2891
2884 amdgpu_dpm_print_class_info(rps->class, rps->class2); 2892 amdgpu_dpm_print_class_info(rps->class, rps->class2);
2885 amdgpu_dpm_print_cap_info(rps->caps); 2893 amdgpu_dpm_print_cap_info(rps->caps);
@@ -2905,13 +2913,14 @@ static void kv_dpm_fini(struct amdgpu_device *adev)
2905 amdgpu_free_extended_power_table(adev); 2913 amdgpu_free_extended_power_table(adev);
2906} 2914}
2907 2915
2908static void kv_dpm_display_configuration_changed(struct amdgpu_device *adev) 2916static void kv_dpm_display_configuration_changed(void *handle)
2909{ 2917{
2910 2918
2911} 2919}
2912 2920
2913static u32 kv_dpm_get_sclk(struct amdgpu_device *adev, bool low) 2921static u32 kv_dpm_get_sclk(void *handle, bool low)
2914{ 2922{
2923 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
2915 struct kv_power_info *pi = kv_get_pi(adev); 2924 struct kv_power_info *pi = kv_get_pi(adev);
2916 struct kv_ps *requested_state = kv_get_ps(&pi->requested_rps); 2925 struct kv_ps *requested_state = kv_get_ps(&pi->requested_rps);
2917 2926
@@ -2921,18 +2930,20 @@ static u32 kv_dpm_get_sclk(struct amdgpu_device *adev, bool low)
2921 return requested_state->levels[requested_state->num_levels - 1].sclk; 2930 return requested_state->levels[requested_state->num_levels - 1].sclk;
2922} 2931}
2923 2932
2924static u32 kv_dpm_get_mclk(struct amdgpu_device *adev, bool low) 2933static u32 kv_dpm_get_mclk(void *handle, bool low)
2925{ 2934{
2935 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
2926 struct kv_power_info *pi = kv_get_pi(adev); 2936 struct kv_power_info *pi = kv_get_pi(adev);
2927 2937
2928 return pi->sys_info.bootup_uma_clk; 2938 return pi->sys_info.bootup_uma_clk;
2929} 2939}
2930 2940
2931/* get temperature in millidegrees */ 2941/* get temperature in millidegrees */
2932static int kv_dpm_get_temp(struct amdgpu_device *adev) 2942static int kv_dpm_get_temp(void *handle)
2933{ 2943{
2934 u32 temp; 2944 u32 temp;
2935 int actual_temp = 0; 2945 int actual_temp = 0;
2946 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
2936 2947
2937 temp = RREG32_SMC(0xC0300E0C); 2948 temp = RREG32_SMC(0xC0300E0C);
2938 2949
@@ -3222,14 +3233,17 @@ static inline bool kv_are_power_levels_equal(const struct kv_pl *kv_cpl1,
3222 (kv_cpl1->force_nbp_state == kv_cpl2->force_nbp_state)); 3233 (kv_cpl1->force_nbp_state == kv_cpl2->force_nbp_state));
3223} 3234}
3224 3235
3225static int kv_check_state_equal(struct amdgpu_device *adev, 3236static int kv_check_state_equal(void *handle,
3226 struct amdgpu_ps *cps, 3237 void *current_ps,
3227 struct amdgpu_ps *rps, 3238 void *request_ps,
3228 bool *equal) 3239 bool *equal)
3229{ 3240{
3230 struct kv_ps *kv_cps; 3241 struct kv_ps *kv_cps;
3231 struct kv_ps *kv_rps; 3242 struct kv_ps *kv_rps;
3232 int i; 3243 int i;
3244 struct amdgpu_ps *cps = (struct amdgpu_ps *)current_ps;
3245 struct amdgpu_ps *rps = (struct amdgpu_ps *)request_ps;
3246 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
3233 3247
3234 if (adev == NULL || cps == NULL || rps == NULL || equal == NULL) 3248 if (adev == NULL || cps == NULL || rps == NULL || equal == NULL)
3235 return -EINVAL; 3249 return -EINVAL;
@@ -3262,9 +3276,10 @@ static int kv_check_state_equal(struct amdgpu_device *adev,
3262 return 0; 3276 return 0;
3263} 3277}
3264 3278
3265static int kv_dpm_read_sensor(struct amdgpu_device *adev, int idx, 3279static int kv_dpm_read_sensor(void *handle, int idx,
3266 void *value, int *size) 3280 void *value, int *size)
3267{ 3281{
3282 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
3268 struct kv_power_info *pi = kv_get_pi(adev); 3283 struct kv_power_info *pi = kv_get_pi(adev);
3269 uint32_t sclk; 3284 uint32_t sclk;
3270 u32 pl_index = 3285 u32 pl_index =
@@ -3312,7 +3327,7 @@ const struct amd_ip_funcs kv_dpm_ip_funcs = {
3312 .set_powergating_state = kv_dpm_set_powergating_state, 3327 .set_powergating_state = kv_dpm_set_powergating_state,
3313}; 3328};
3314 3329
3315static const struct amdgpu_dpm_funcs kv_dpm_funcs = { 3330static const struct amd_pm_funcs kv_dpm_funcs = {
3316 .get_temperature = &kv_dpm_get_temp, 3331 .get_temperature = &kv_dpm_get_temp,
3317 .pre_set_power_state = &kv_dpm_pre_set_power_state, 3332 .pre_set_power_state = &kv_dpm_pre_set_power_state,
3318 .set_power_state = &kv_dpm_set_power_state, 3333 .set_power_state = &kv_dpm_set_power_state,