* [PATCH] drm/amdgpu/ctx: only reset stable pstate if the user changed it (v2)
@ 2022-05-10 14:37 Alex Deucher
2022-05-11 4:42 ` Lazar, Lijo
0 siblings, 1 reply; 2+ messages in thread
From: Alex Deucher @ 2022-05-10 14:37 UTC (permalink / raw)
To: amd-gfx; +Cc: Alex Deucher
Check if the requested stable pstate matches the current one before
changing it. This avoids changing the stable pstate on context
destroy if the user never changed it in the first place via the
IOCTL.
v2: compare the current and requested rather than setting a flag (Lijo)
Fixes: 8cda7a4f96e435 ("drm/amdgpu/UAPI: add new CTX OP to get/set stable pstates")
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 5981c7d9bd48..94c3a52df131 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -295,6 +295,7 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx,
{
struct amdgpu_device *adev = ctx->adev;
enum amd_dpm_forced_level level;
+ u32 current_stable_pstate;
int r;
mutex_lock(&adev->pm.stable_pstate_ctx_lock);
@@ -303,6 +304,10 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx,
goto done;
}
+ r = amdgpu_ctx_get_stable_pstate(ctx, ¤t_stable_pstate);
+ if (r || (stable_pstate == current_stable_pstate))
+ goto done;
+
switch (stable_pstate) {
case AMDGPU_CTX_STABLE_PSTATE_NONE:
level = AMD_DPM_FORCED_LEVEL_AUTO;
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdgpu/ctx: only reset stable pstate if the user changed it (v2)
2022-05-10 14:37 [PATCH] drm/amdgpu/ctx: only reset stable pstate if the user changed it (v2) Alex Deucher
@ 2022-05-11 4:42 ` Lazar, Lijo
0 siblings, 0 replies; 2+ messages in thread
From: Lazar, Lijo @ 2022-05-11 4:42 UTC (permalink / raw)
To: Alex Deucher, amd-gfx
On 5/10/2022 8:07 PM, Alex Deucher wrote:
> Check if the requested stable pstate matches the current one before
> changing it. This avoids changing the stable pstate on context
> destroy if the user never changed it in the first place via the
> IOCTL.
>
> v2: compare the current and requested rather than setting a flag (Lijo)
>
> Fixes: 8cda7a4f96e435 ("drm/amdgpu/UAPI: add new CTX OP to get/set stable pstates")
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Thanks,
Lijo
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index 5981c7d9bd48..94c3a52df131 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -295,6 +295,7 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx,
> {
> struct amdgpu_device *adev = ctx->adev;
> enum amd_dpm_forced_level level;
> + u32 current_stable_pstate;
> int r;
>
> mutex_lock(&adev->pm.stable_pstate_ctx_lock);
> @@ -303,6 +304,10 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx,
> goto done;
> }
>
> + r = amdgpu_ctx_get_stable_pstate(ctx, ¤t_stable_pstate);
> + if (r || (stable_pstate == current_stable_pstate))
> + goto done;
> +
> switch (stable_pstate) {
> case AMDGPU_CTX_STABLE_PSTATE_NONE:
> level = AMD_DPM_FORCED_LEVEL_AUTO;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-11 4:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-10 14:37 [PATCH] drm/amdgpu/ctx: only reset stable pstate if the user changed it (v2) Alex Deucher
2022-05-11 4:42 ` Lazar, Lijo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.