From: Evan Quan <evan.quan@amd.com>
To: amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, Evan Quan <evan.quan@amd.com>
Subject: [PATCH 4/7] drm/amd/powerplay: simplify the code around setting power limit
Date: Mon, 8 Jun 2020 18:52:31 +0800 [thread overview]
Message-ID: <20200608105234.29864-4-evan.quan@amd.com> (raw)
In-Reply-To: <20200608105234.29864-1-evan.quan@amd.com>
Use the cached max/current power limit and move the input check
to the top layer.
Change-Id: Iefc7a89b871ce20422c2e70b8cd7ac85a0a7beba
Signed-off-by: Evan Quan <evan.quan@amd.com>
---
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 11 +++++++++++
drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 16 ++--------------
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 6757f65fd87e..7cde80c9614f 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -2239,9 +2239,20 @@ int smu_set_power_limit(struct smu_context *smu, uint32_t limit)
mutex_lock(&smu->mutex);
+ if (limit > smu->max_power_limit) {
+ dev_err(smu->adev->dev,
+ "New power limit (%d) is over the max allowed %d\n",
+ limit, smu->max_power_limit);
+ goto out;
+ }
+
+ if (!limit)
+ limit = smu->current_power_limit;
+
if (smu->ppt_funcs->set_power_limit)
ret = smu->ppt_funcs->set_power_limit(smu, limit);
+out:
mutex_unlock(&smu->mutex);
return ret;
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 358c903c4a86..34e9ae813000 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -1082,19 +1082,6 @@ int smu_v11_0_get_current_power_limit(struct smu_context *smu,
int smu_v11_0_set_power_limit(struct smu_context *smu, uint32_t n)
{
int ret = 0;
- uint32_t max_power_limit;
-
- max_power_limit = smu_get_max_power_limit(smu);
-
- if (n > max_power_limit) {
- dev_err(smu->adev->dev, "New power limit (%d) is over the max allowed %d\n",
- n,
- max_power_limit);
- return -EINVAL;
- }
-
- if (n == 0)
- n = smu->default_power_limit;
if (!smu_feature_is_enabled(smu, SMU_FEATURE_PPT_BIT)) {
dev_err(smu->adev->dev, "Setting new power limit is not supported!\n");
@@ -1106,7 +1093,8 @@ int smu_v11_0_set_power_limit(struct smu_context *smu, uint32_t n)
dev_err(smu->adev->dev, "[%s] Set power limit Failed!\n", __func__);
return ret;
}
- smu->power_limit = n;
+
+ smu->current_power_limit = n;
return 0;
}
--
2.27.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2020-06-08 10:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-08 10:52 [PATCH 1/7] drm/amd/powerplay: drop unnecessary get_pptable_power_limit wrappers Evan Quan
2020-06-08 10:52 ` [PATCH 2/7] drm/amd/powerplay: maximize code sharing around power limit Evan Quan
2020-06-08 10:52 ` [PATCH 3/7] drm/amd/powerplay: simplify the code around retrieving " Evan Quan
2020-06-08 10:52 ` Evan Quan [this message]
2020-06-08 10:52 ` [PATCH 5/7] drm/amd/powerplay: drop unused code around " Evan Quan
2020-06-08 10:52 ` [PATCH 6/7] drm/amd/powerplay: correct power limit retrieving based on current power source Evan Quan
2020-06-08 10:52 ` [PATCH 7/7] drm/amd/powerplay: add check for power limit OD support Evan Quan
2020-06-08 22:22 ` Alex Deucher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200608105234.29864-4-evan.quan@amd.com \
--to=evan.quan@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox