Commit 780f3a9c authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

drm/amd/powerplay: some cosmetic fixes

Drop redundant check, duplicate check, duplicate setting
and fix the return value.
Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d3a593e9
...@@ -317,13 +317,6 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, ...@@ -317,13 +317,6 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
(ddev->switch_power_state != DRM_SWITCH_POWER_ON)) (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return -EINVAL; return -EINVAL;
if (!amdgpu_sriov_vf(adev)) {
if (is_support_sw_smu(adev))
current_level = smu_get_performance_level(&adev->smu);
else if (adev->powerplay.pp_funcs->get_performance_level)
current_level = amdgpu_dpm_get_performance_level(adev);
}
if (strncmp("low", buf, strlen("low")) == 0) { if (strncmp("low", buf, strlen("low")) == 0) {
level = AMD_DPM_FORCED_LEVEL_LOW; level = AMD_DPM_FORCED_LEVEL_LOW;
} else if (strncmp("high", buf, strlen("high")) == 0) { } else if (strncmp("high", buf, strlen("high")) == 0) {
...@@ -347,6 +340,7 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, ...@@ -347,6 +340,7 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
goto fail; goto fail;
} }
/* handle sriov case here */
if (amdgpu_sriov_vf(adev)) { if (amdgpu_sriov_vf(adev)) {
if (amdgim_is_hwperf(adev) && if (amdgim_is_hwperf(adev) &&
adev->virt.ops->force_dpm_level) { adev->virt.ops->force_dpm_level) {
...@@ -359,6 +353,11 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, ...@@ -359,6 +353,11 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
} }
} }
if (is_support_sw_smu(adev))
current_level = smu_get_performance_level(&adev->smu);
else if (adev->powerplay.pp_funcs->get_performance_level)
current_level = amdgpu_dpm_get_performance_level(adev);
if (current_level == level) if (current_level == level)
return count; return count;
......
...@@ -1444,6 +1444,7 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu, ...@@ -1444,6 +1444,7 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,
if (!smu->pm_enabled) if (!smu->pm_enabled)
return -EINVAL; return -EINVAL;
if (!skip_display_settings) { if (!skip_display_settings) {
ret = smu_display_config_changed(smu); ret = smu_display_config_changed(smu);
if (ret) { if (ret) {
...@@ -1452,8 +1453,6 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu, ...@@ -1452,8 +1453,6 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,
} }
} }
if (!smu->pm_enabled)
return -EINVAL;
ret = smu_apply_clocks_adjust_rules(smu); ret = smu_apply_clocks_adjust_rules(smu);
if (ret) { if (ret) {
pr_err("Failed to apply clocks adjust rules!"); pr_err("Failed to apply clocks adjust rules!");
...@@ -1472,8 +1471,13 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu, ...@@ -1472,8 +1471,13 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,
ret = smu_asic_set_performance_level(smu, level); ret = smu_asic_set_performance_level(smu, level);
if (ret) { if (ret) {
ret = smu_default_set_performance_level(smu, level); ret = smu_default_set_performance_level(smu, level);
if (ret) {
pr_err("Failed to set performance level!");
return ret;
} }
if (!ret) }
/* update the saved copy */
smu_dpm_ctx->dpm_level = level; smu_dpm_ctx->dpm_level = level;
} }
...@@ -1533,28 +1537,18 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu) ...@@ -1533,28 +1537,18 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu)
int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level) int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level)
{ {
int ret = 0;
int i;
struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
int ret = 0;
if (!smu_dpm_ctx->dpm_context) if (!smu_dpm_ctx->dpm_context)
return -EINVAL; return -EINVAL;
for (i = 0; i < smu->adev->num_ip_blocks; i++) { ret = smu_enable_umd_pstate(smu, &level);
if (smu->adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC)
break;
}
smu->adev->ip_blocks[i].version->funcs->enable_umd_pstate(smu, &level);
ret = smu_handle_task(smu, level,
AMD_PP_TASK_READJUST_POWER_STATE);
if (ret) if (ret)
return ret; return ret;
mutex_lock(&smu->mutex); ret = smu_handle_task(smu, level,
smu_dpm_ctx->dpm_level = level; AMD_PP_TASK_READJUST_POWER_STATE);
mutex_unlock(&smu->mutex);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment