<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Series is:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Evan Quan <evan.quan@amd.com><br>
<b>Sent:</b> Tuesday, July 23, 2019 4:41 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH 2/2] drm/amd/powerplay: some cosmetic fixes</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Drop redundant check, duplicate check, duplicate setting<br>
and fix the return value.<br>
<br>
Change-Id: I04171bcac82f17152371d05e6958d4fc072c0f6b<br>
Signed-off-by: Evan Quan <evan.quan@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 33 +++++++++++-----------<br>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 30 ++++++++------------<br>
2 files changed, 28 insertions(+), 35 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
index 866097d5cf26..aad3e105901b 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
@@ -367,13 +367,6 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,<br>
(ddev->switch_power_state != DRM_SWITCH_POWER_ON))<br>
return -EINVAL;<br>
<br>
- if (!amdgpu_sriov_vf(adev)) {<br>
- if (is_support_sw_smu(adev))<br>
- current_level = smu_get_performance_level(&adev->smu);<br>
- else if (adev->powerplay.pp_funcs->get_performance_level)<br>
- current_level = amdgpu_dpm_get_performance_level(adev);<br>
- }<br>
-<br>
if (strncmp("low", buf, strlen("low")) == 0) {<br>
level = AMD_DPM_FORCED_LEVEL_LOW;<br>
} else if (strncmp("high", buf, strlen("high")) == 0) {<br>
@@ -397,17 +390,23 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,<br>
goto fail;<br>
}<br>
<br>
- if (amdgpu_sriov_vf(adev)) {<br>
- if (amdgim_is_hwperf(adev) &&<br>
- adev->virt.ops->force_dpm_level) {<br>
- mutex_lock(&adev->pm.mutex);<br>
- adev->virt.ops->force_dpm_level(adev, level);<br>
- mutex_unlock(&adev->pm.mutex);<br>
- return count;<br>
- } else {<br>
- return -EINVAL;<br>
+ /* handle sriov case here */<br>
+ if (amdgpu_sriov_vf(adev)) {<br>
+ if (amdgim_is_hwperf(adev) &&<br>
+ adev->virt.ops->force_dpm_level) {<br>
+ mutex_lock(&adev->pm.mutex);<br>
+ adev->virt.ops->force_dpm_level(adev, level);<br>
+ mutex_unlock(&adev->pm.mutex);<br>
+ return count;<br>
+ } else {<br>
+ return -EINVAL;<br>
}<br>
- }<br>
+ }<br>
+<br>
+ if (is_support_sw_smu(adev))<br>
+ current_level = smu_get_performance_level(&adev->smu);<br>
+ else if (adev->powerplay.pp_funcs->get_performance_level)<br>
+ current_level = amdgpu_dpm_get_performance_level(adev);<br>
<br>
if (current_level == level)<br>
return count;<br>
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
index 266614e27392..a92d13b513da 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
@@ -1398,6 +1398,7 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,<br>
<br>
if (!smu->pm_enabled)<br>
return -EINVAL;<br>
+<br>
if (!skip_display_settings) {<br>
ret = smu_display_config_changed(smu);<br>
if (ret) {<br>
@@ -1406,8 +1407,6 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,<br>
}<br>
}<br>
<br>
- if (!smu->pm_enabled)<br>
- return -EINVAL;<br>
ret = smu_apply_clocks_adjust_rules(smu);<br>
if (ret) {<br>
pr_err("Failed to apply clocks adjust rules!");<br>
@@ -1426,9 +1425,14 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,<br>
ret = smu_asic_set_performance_level(smu, level);<br>
if (ret) {<br>
ret = smu_default_set_performance_level(smu, level);<br>
+ if (ret) {<br>
+ pr_err("Failed to set performance level!");<br>
+ return ret;<br>
+ }<br>
}<br>
- if (!ret)<br>
- smu_dpm_ctx->dpm_level = level;<br>
+<br>
+ /* update the saved copy */<br>
+ smu_dpm_ctx->dpm_level = level;<br>
}<br>
<br>
if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {<br>
@@ -1487,28 +1491,18 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu)<br>
<br>
int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level)<br>
{<br>
- int ret = 0;<br>
- int i;<br>
struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);<br>
+ int ret = 0;<br>
<br>
if (!smu_dpm_ctx->dpm_context)<br>
return -EINVAL;<br>
<br>
- for (i = 0; i < smu->adev->num_ip_blocks; i++) {<br>
- if (smu->adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC)<br>
- break;<br>
- }<br>
-<br>
-<br>
- smu->adev->ip_blocks[i].version->funcs->enable_umd_pstate(smu, &level);<br>
- ret = smu_handle_task(smu, level,<br>
- AMD_PP_TASK_READJUST_POWER_STATE);<br>
+ ret = smu_enable_umd_pstate(smu, &level);<br>
if (ret)<br>
return ret;<br>
<br>
- mutex_lock(&smu->mutex);<br>
- smu_dpm_ctx->dpm_level = level;<br>
- mutex_unlock(&smu->mutex);<br>
+ ret = smu_handle_task(smu, level,<br>
+ AMD_PP_TASK_READJUST_POWER_STATE);<br>
<br>
return ret;<br>
}<br>
-- <br>
2.22.0<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></div>
</span></font></div>
</body>
</html>