Skip to contentSkip to conversation

drm/amdgpu/ctx: only reset stable pstate if the user changed it (v2)

PATCH In review Alex Deucher 2 participants 2 messages May 10, 2022 – May 11, 2022

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu/ctx: only reset stable pstate if the user changed it (v2)

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")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +5 -0
index 5981c7d9bd48..94c3a52df131 100644
@@ -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, &current_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;
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · 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")

Thanks,
Lijo

Quoted 28 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +5 -0
index 5981c7d9bd48..94c3a52df131 100644
@@ -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, &current_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;