diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/ci_dpm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c index 578878d1d4c0..b00e81db522d 100644 --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c | |||
@@ -6936,6 +6936,48 @@ static int ci_dpm_switch_power_profile(struct amdgpu_device *adev, | |||
6936 | return 0; | 6936 | return 0; |
6937 | } | 6937 | } |
6938 | 6938 | ||
6939 | static int ci_dpm_read_sensor(struct amdgpu_device *adev, int idx, | ||
6940 | void *value, int *size) | ||
6941 | { | ||
6942 | u32 activity_percent = 50; | ||
6943 | int ret; | ||
6944 | |||
6945 | /* size must be at least 4 bytes for all sensors */ | ||
6946 | if (*size < 4) | ||
6947 | return -EINVAL; | ||
6948 | |||
6949 | switch (idx) { | ||
6950 | case AMDGPU_PP_SENSOR_GFX_SCLK: | ||
6951 | *((uint32_t *)value) = ci_get_average_sclk_freq(adev); | ||
6952 | *size = 4; | ||
6953 | return 0; | ||
6954 | case AMDGPU_PP_SENSOR_GFX_MCLK: | ||
6955 | *((uint32_t *)value) = ci_get_average_mclk_freq(adev); | ||
6956 | *size = 4; | ||
6957 | return 0; | ||
6958 | case AMDGPU_PP_SENSOR_GPU_TEMP: | ||
6959 | *((uint32_t *)value) = ci_dpm_get_temp(adev); | ||
6960 | *size = 4; | ||
6961 | return 0; | ||
6962 | case AMDGPU_PP_SENSOR_GPU_LOAD: | ||
6963 | ret = ci_read_smc_soft_register(adev, | ||
6964 | offsetof(SMU7_SoftRegisters, | ||
6965 | AverageGraphicsA), | ||
6966 | &activity_percent); | ||
6967 | if (ret == 0) { | ||
6968 | activity_percent += 0x80; | ||
6969 | activity_percent >>= 8; | ||
6970 | activity_percent = | ||
6971 | activity_percent > 100 ? 100 : activity_percent; | ||
6972 | } | ||
6973 | *((uint32_t *)value) = activity_percent; | ||
6974 | *size = 4; | ||
6975 | return 0; | ||
6976 | default: | ||
6977 | return -EINVAL; | ||
6978 | } | ||
6979 | } | ||
6980 | |||
6939 | const struct amd_ip_funcs ci_dpm_ip_funcs = { | 6981 | const struct amd_ip_funcs ci_dpm_ip_funcs = { |
6940 | .name = "ci_dpm", | 6982 | .name = "ci_dpm", |
6941 | .early_init = ci_dpm_early_init, | 6983 | .early_init = ci_dpm_early_init, |
@@ -6982,6 +7024,7 @@ static const struct amdgpu_dpm_funcs ci_dpm_funcs = { | |||
6982 | .set_power_profile_state = ci_dpm_set_power_profile_state, | 7024 | .set_power_profile_state = ci_dpm_set_power_profile_state, |
6983 | .reset_power_profile_state = ci_dpm_reset_power_profile_state, | 7025 | .reset_power_profile_state = ci_dpm_reset_power_profile_state, |
6984 | .switch_power_profile = ci_dpm_switch_power_profile, | 7026 | .switch_power_profile = ci_dpm_switch_power_profile, |
7027 | .read_sensor = ci_dpm_read_sensor, | ||
6985 | }; | 7028 | }; |
6986 | 7029 | ||
6987 | static void ci_dpm_set_dpm_funcs(struct amdgpu_device *adev) | 7030 | static void ci_dpm_set_dpm_funcs(struct amdgpu_device *adev) |