Skip to contentSkip to conversation

drm/amdgpu: fix pstate setting issue

PATCH Deucher, Alexander 1 participant 1 message Oct 18, 2022 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Deucher, Alexander

author maintainer Reviewed-by
#1 lore raw

[AMD Official Use Only - General]

________________________________
From: Chengming Gui <[email protected]>
Sent: Tuesday, October 18, 2022 6:12 AM
To: [email protected] <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>
Cc: Nie, Tobyn <[email protected]>; Gui, Jack <[email protected]>
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.

Change-Id I61cb68b2a5fe2544cd91233fc069b5919fadcb76
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -1
index 5fc3da020a55..331aa191910c 100644
@@ -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