[PATCH] drm/amdgpu: fix pstate setting issue

Deucher, Alexander Alexander.Deucher at amd.com
Tue Oct 18 13:34:26 UTC 2022


[AMD Official Use Only - General]

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
________________________________
From: Chengming Gui <Jack.Gui at amd.com>
Sent: Tuesday, October 18, 2022 6:12 AM
To: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher at amd.com>; Zhang, Hawking <Hawking.Zhang at amd.com>
Cc: Nie, Tobyn <Tobyn.Nie at amd.com>; Gui, Jack <Jack.Gui at amd.com>
Subject: [PATCH] drm/amdgpu: fix pstate setting issue

[WHY]
0, original pstate X
1, ctx_A_create -> ctx_A->stable_pstate = X
2, ctx_A_set_pstate (Y) -> current pstate is Y (PEAK or STANDARD)
3, ctx_B_create -> ctx_B->stable_pstate =  Y
4, ctx_A_destroy -> restore pstate to X
5, ctx_B_destroy -> restore pstate to Y
Above sequence will cause final pstate is wrong (Y), should be original X.

[HOW]
When ctx_B create,
if  ctx_A touched pstate setting
(not auto, stable_pstate_ctx != NULL),
set ctx_B->stable_pstate the same value as ctx_A saved,
if stable_pstate_ctx == NULL,
fetch current pstate to fill
ctx_B->stable_pstate.

Signed-off-by: Chengming Gui <Jack.Gui at amd.com>
Change-Id: I61cb68b2a5fe2544cd91233fc069b5919fadcb76
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 5fc3da020a55..331aa191910c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -326,7 +326,10 @@ static int amdgpu_ctx_init(struct amdgpu_ctx_mgr *mgr, int32_t priority,
         if (r)
                 return r;

-       ctx->stable_pstate = current_stable_pstate;
+       if (mgr->adev->pm.stable_pstate_ctx)
+               ctx->stable_pstate = mgr->adev->pm.stable_pstate_ctx->stable_pstate;
+       else
+               ctx->stable_pstate = current_stable_pstate;

         return 0;
 }
--
2.37.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20221018/f1e8ea1e/attachment.htm>


More information about the amd-gfx mailing list