diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/si_dpm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/si_dpm.c | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c index d63873f3f574..05b3dbf585d5 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c | |||
@@ -3060,9 +3060,9 @@ static int si_get_vce_clock_voltage(struct amdgpu_device *adev, | |||
3060 | return ret; | 3060 | return ret; |
3061 | } | 3061 | } |
3062 | 3062 | ||
3063 | static bool si_dpm_vblank_too_short(struct amdgpu_device *adev) | 3063 | static bool si_dpm_vblank_too_short(void *handle) |
3064 | { | 3064 | { |
3065 | 3065 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
3066 | u32 vblank_time = amdgpu_dpm_get_vblank_time(adev); | 3066 | u32 vblank_time = amdgpu_dpm_get_vblank_time(adev); |
3067 | /* we never hit the non-gddr5 limit so disable it */ | 3067 | /* we never hit the non-gddr5 limit so disable it */ |
3068 | u32 switch_limit = adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5 ? 450 : 0; | 3068 | u32 switch_limit = adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5 ? 450 : 0; |
@@ -3871,9 +3871,10 @@ static int si_restrict_performance_levels_before_switch(struct amdgpu_device *ad | |||
3871 | 0 : -EINVAL; | 3871 | 0 : -EINVAL; |
3872 | } | 3872 | } |
3873 | 3873 | ||
3874 | static int si_dpm_force_performance_level(struct amdgpu_device *adev, | 3874 | static int si_dpm_force_performance_level(void *handle, |
3875 | enum amd_dpm_forced_level level) | 3875 | enum amd_dpm_forced_level level) |
3876 | { | 3876 | { |
3877 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
3877 | struct amdgpu_ps *rps = adev->pm.dpm.current_ps; | 3878 | struct amdgpu_ps *rps = adev->pm.dpm.current_ps; |
3878 | struct si_ps *ps = si_get_ps(rps); | 3879 | struct si_ps *ps = si_get_ps(rps); |
3879 | u32 levels = ps->performance_level_count; | 3880 | u32 levels = ps->performance_level_count; |
@@ -6575,11 +6576,12 @@ static int si_fan_ctrl_stop_smc_fan_control(struct amdgpu_device *adev) | |||
6575 | } | 6576 | } |
6576 | } | 6577 | } |
6577 | 6578 | ||
6578 | static int si_dpm_get_fan_speed_percent(struct amdgpu_device *adev, | 6579 | static int si_dpm_get_fan_speed_percent(void *handle, |
6579 | u32 *speed) | 6580 | u32 *speed) |
6580 | { | 6581 | { |
6581 | u32 duty, duty100; | 6582 | u32 duty, duty100; |
6582 | u64 tmp64; | 6583 | u64 tmp64; |
6584 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
6583 | 6585 | ||
6584 | if (adev->pm.no_fan) | 6586 | if (adev->pm.no_fan) |
6585 | return -ENOENT; | 6587 | return -ENOENT; |
@@ -6600,9 +6602,10 @@ static int si_dpm_get_fan_speed_percent(struct amdgpu_device *adev, | |||
6600 | return 0; | 6602 | return 0; |
6601 | } | 6603 | } |
6602 | 6604 | ||
6603 | static int si_dpm_set_fan_speed_percent(struct amdgpu_device *adev, | 6605 | static int si_dpm_set_fan_speed_percent(void *handle, |
6604 | u32 speed) | 6606 | u32 speed) |
6605 | { | 6607 | { |
6608 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
6606 | struct si_power_info *si_pi = si_get_pi(adev); | 6609 | struct si_power_info *si_pi = si_get_pi(adev); |
6607 | u32 tmp; | 6610 | u32 tmp; |
6608 | u32 duty, duty100; | 6611 | u32 duty, duty100; |
@@ -6633,8 +6636,10 @@ static int si_dpm_set_fan_speed_percent(struct amdgpu_device *adev, | |||
6633 | return 0; | 6636 | return 0; |
6634 | } | 6637 | } |
6635 | 6638 | ||
6636 | static void si_dpm_set_fan_control_mode(struct amdgpu_device *adev, u32 mode) | 6639 | static void si_dpm_set_fan_control_mode(void *handle, u32 mode) |
6637 | { | 6640 | { |
6641 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
6642 | |||
6638 | if (mode) { | 6643 | if (mode) { |
6639 | /* stop auto-manage */ | 6644 | /* stop auto-manage */ |
6640 | if (adev->pm.dpm.fan.ucode_fan_control) | 6645 | if (adev->pm.dpm.fan.ucode_fan_control) |
@@ -6649,8 +6654,9 @@ static void si_dpm_set_fan_control_mode(struct amdgpu_device *adev, u32 mode) | |||
6649 | } | 6654 | } |
6650 | } | 6655 | } |
6651 | 6656 | ||
6652 | static u32 si_dpm_get_fan_control_mode(struct amdgpu_device *adev) | 6657 | static u32 si_dpm_get_fan_control_mode(void *handle) |
6653 | { | 6658 | { |
6659 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
6654 | struct si_power_info *si_pi = si_get_pi(adev); | 6660 | struct si_power_info *si_pi = si_get_pi(adev); |
6655 | u32 tmp; | 6661 | u32 tmp; |
6656 | 6662 | ||
@@ -6946,8 +6952,9 @@ static void si_dpm_disable(struct amdgpu_device *adev) | |||
6946 | ni_update_current_ps(adev, boot_ps); | 6952 | ni_update_current_ps(adev, boot_ps); |
6947 | } | 6953 | } |
6948 | 6954 | ||
6949 | static int si_dpm_pre_set_power_state(struct amdgpu_device *adev) | 6955 | static int si_dpm_pre_set_power_state(void *handle) |
6950 | { | 6956 | { |
6957 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
6951 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | 6958 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); |
6952 | struct amdgpu_ps requested_ps = *adev->pm.dpm.requested_ps; | 6959 | struct amdgpu_ps requested_ps = *adev->pm.dpm.requested_ps; |
6953 | struct amdgpu_ps *new_ps = &requested_ps; | 6960 | struct amdgpu_ps *new_ps = &requested_ps; |
@@ -6984,8 +6991,9 @@ static int si_power_control_set_level(struct amdgpu_device *adev) | |||
6984 | return 0; | 6991 | return 0; |
6985 | } | 6992 | } |
6986 | 6993 | ||
6987 | static int si_dpm_set_power_state(struct amdgpu_device *adev) | 6994 | static int si_dpm_set_power_state(void *handle) |
6988 | { | 6995 | { |
6996 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
6989 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | 6997 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); |
6990 | struct amdgpu_ps *new_ps = &eg_pi->requested_rps; | 6998 | struct amdgpu_ps *new_ps = &eg_pi->requested_rps; |
6991 | struct amdgpu_ps *old_ps = &eg_pi->current_rps; | 6999 | struct amdgpu_ps *old_ps = &eg_pi->current_rps; |
@@ -7086,8 +7094,9 @@ static int si_dpm_set_power_state(struct amdgpu_device *adev) | |||
7086 | return 0; | 7094 | return 0; |
7087 | } | 7095 | } |
7088 | 7096 | ||
7089 | static void si_dpm_post_set_power_state(struct amdgpu_device *adev) | 7097 | static void si_dpm_post_set_power_state(void *handle) |
7090 | { | 7098 | { |
7099 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7091 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | 7100 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); |
7092 | struct amdgpu_ps *new_ps = &eg_pi->requested_rps; | 7101 | struct amdgpu_ps *new_ps = &eg_pi->requested_rps; |
7093 | 7102 | ||
@@ -7103,8 +7112,10 @@ void si_dpm_reset_asic(struct amdgpu_device *adev) | |||
7103 | } | 7112 | } |
7104 | #endif | 7113 | #endif |
7105 | 7114 | ||
7106 | static void si_dpm_display_configuration_changed(struct amdgpu_device *adev) | 7115 | static void si_dpm_display_configuration_changed(void *handle) |
7107 | { | 7116 | { |
7117 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7118 | |||
7108 | si_program_display_gap(adev); | 7119 | si_program_display_gap(adev); |
7109 | } | 7120 | } |
7110 | 7121 | ||
@@ -7486,9 +7497,10 @@ static void si_dpm_fini(struct amdgpu_device *adev) | |||
7486 | amdgpu_free_extended_power_table(adev); | 7497 | amdgpu_free_extended_power_table(adev); |
7487 | } | 7498 | } |
7488 | 7499 | ||
7489 | static void si_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev, | 7500 | static void si_dpm_debugfs_print_current_performance_level(void *handle, |
7490 | struct seq_file *m) | 7501 | struct seq_file *m) |
7491 | { | 7502 | { |
7503 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7492 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | 7504 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); |
7493 | struct amdgpu_ps *rps = &eg_pi->current_rps; | 7505 | struct amdgpu_ps *rps = &eg_pi->current_rps; |
7494 | struct si_ps *ps = si_get_ps(rps); | 7506 | struct si_ps *ps = si_get_ps(rps); |
@@ -7860,10 +7872,11 @@ static int si_dpm_set_powergating_state(void *handle, | |||
7860 | } | 7872 | } |
7861 | 7873 | ||
7862 | /* get temperature in millidegrees */ | 7874 | /* get temperature in millidegrees */ |
7863 | static int si_dpm_get_temp(struct amdgpu_device *adev) | 7875 | static int si_dpm_get_temp(void *handle) |
7864 | { | 7876 | { |
7865 | u32 temp; | 7877 | u32 temp; |
7866 | int actual_temp = 0; | 7878 | int actual_temp = 0; |
7879 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7867 | 7880 | ||
7868 | temp = (RREG32(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >> | 7881 | temp = (RREG32(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >> |
7869 | CTF_TEMP_SHIFT; | 7882 | CTF_TEMP_SHIFT; |
@@ -7878,8 +7891,9 @@ static int si_dpm_get_temp(struct amdgpu_device *adev) | |||
7878 | return actual_temp; | 7891 | return actual_temp; |
7879 | } | 7892 | } |
7880 | 7893 | ||
7881 | static u32 si_dpm_get_sclk(struct amdgpu_device *adev, bool low) | 7894 | static u32 si_dpm_get_sclk(void *handle, bool low) |
7882 | { | 7895 | { |
7896 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7883 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | 7897 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); |
7884 | struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps); | 7898 | struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps); |
7885 | 7899 | ||
@@ -7889,8 +7903,9 @@ static u32 si_dpm_get_sclk(struct amdgpu_device *adev, bool low) | |||
7889 | return requested_state->performance_levels[requested_state->performance_level_count - 1].sclk; | 7903 | return requested_state->performance_levels[requested_state->performance_level_count - 1].sclk; |
7890 | } | 7904 | } |
7891 | 7905 | ||
7892 | static u32 si_dpm_get_mclk(struct amdgpu_device *adev, bool low) | 7906 | static u32 si_dpm_get_mclk(void *handle, bool low) |
7893 | { | 7907 | { |
7908 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7894 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | 7909 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); |
7895 | struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps); | 7910 | struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps); |
7896 | 7911 | ||
@@ -7900,9 +7915,11 @@ static u32 si_dpm_get_mclk(struct amdgpu_device *adev, bool low) | |||
7900 | return requested_state->performance_levels[requested_state->performance_level_count - 1].mclk; | 7915 | return requested_state->performance_levels[requested_state->performance_level_count - 1].mclk; |
7901 | } | 7916 | } |
7902 | 7917 | ||
7903 | static void si_dpm_print_power_state(struct amdgpu_device *adev, | 7918 | static void si_dpm_print_power_state(void *handle, |
7904 | struct amdgpu_ps *rps) | 7919 | void *current_ps) |
7905 | { | 7920 | { |
7921 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7922 | struct amdgpu_ps *rps = (struct amdgpu_ps *)current_ps; | ||
7906 | struct si_ps *ps = si_get_ps(rps); | 7923 | struct si_ps *ps = si_get_ps(rps); |
7907 | struct rv7xx_pl *pl; | 7924 | struct rv7xx_pl *pl; |
7908 | int i; | 7925 | int i; |
@@ -7942,20 +7959,23 @@ static inline bool si_are_power_levels_equal(const struct rv7xx_pl *si_cpl1, | |||
7942 | (si_cpl1->vddci == si_cpl2->vddci)); | 7959 | (si_cpl1->vddci == si_cpl2->vddci)); |
7943 | } | 7960 | } |
7944 | 7961 | ||
7945 | static int si_check_state_equal(struct amdgpu_device *adev, | 7962 | static int si_check_state_equal(void *handle, |
7946 | struct amdgpu_ps *cps, | 7963 | void *current_ps, |
7947 | struct amdgpu_ps *rps, | 7964 | void *request_ps, |
7948 | bool *equal) | 7965 | bool *equal) |
7949 | { | 7966 | { |
7950 | struct si_ps *si_cps; | 7967 | struct si_ps *si_cps; |
7951 | struct si_ps *si_rps; | 7968 | struct si_ps *si_rps; |
7952 | int i; | 7969 | int i; |
7970 | struct amdgpu_ps *cps = (struct amdgpu_ps *)current_ps; | ||
7971 | struct amdgpu_ps *rps = (struct amdgpu_ps *)request_ps; | ||
7972 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7953 | 7973 | ||
7954 | if (adev == NULL || cps == NULL || rps == NULL || equal == NULL) | 7974 | if (adev == NULL || cps == NULL || rps == NULL || equal == NULL) |
7955 | return -EINVAL; | 7975 | return -EINVAL; |
7956 | 7976 | ||
7957 | si_cps = si_get_ps(cps); | 7977 | si_cps = si_get_ps((struct amdgpu_ps *)cps); |
7958 | si_rps = si_get_ps(rps); | 7978 | si_rps = si_get_ps((struct amdgpu_ps *)rps); |
7959 | 7979 | ||
7960 | if (si_cps == NULL) { | 7980 | if (si_cps == NULL) { |
7961 | printk("si_cps is NULL\n"); | 7981 | printk("si_cps is NULL\n"); |
@@ -7983,9 +8003,10 @@ static int si_check_state_equal(struct amdgpu_device *adev, | |||
7983 | return 0; | 8003 | return 0; |
7984 | } | 8004 | } |
7985 | 8005 | ||
7986 | static int si_dpm_read_sensor(struct amdgpu_device *adev, int idx, | 8006 | static int si_dpm_read_sensor(void *handle, int idx, |
7987 | void *value, int *size) | 8007 | void *value, int *size) |
7988 | { | 8008 | { |
8009 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
7989 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | 8010 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); |
7990 | struct amdgpu_ps *rps = &eg_pi->current_rps; | 8011 | struct amdgpu_ps *rps = &eg_pi->current_rps; |
7991 | struct si_ps *ps = si_get_ps(rps); | 8012 | struct si_ps *ps = si_get_ps(rps); |
@@ -8041,7 +8062,7 @@ const struct amd_ip_funcs si_dpm_ip_funcs = { | |||
8041 | .set_powergating_state = si_dpm_set_powergating_state, | 8062 | .set_powergating_state = si_dpm_set_powergating_state, |
8042 | }; | 8063 | }; |
8043 | 8064 | ||
8044 | static const struct amdgpu_dpm_funcs si_dpm_funcs = { | 8065 | static const struct amd_pm_funcs si_dpm_funcs = { |
8045 | .get_temperature = &si_dpm_get_temp, | 8066 | .get_temperature = &si_dpm_get_temp, |
8046 | .pre_set_power_state = &si_dpm_pre_set_power_state, | 8067 | .pre_set_power_state = &si_dpm_pre_set_power_state, |
8047 | .set_power_state = &si_dpm_set_power_state, | 8068 | .set_power_state = &si_dpm_set_power_state, |