drm/amdgpu/ctx: only reset stable pstate if the user changed it
Subsystems (2)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu/ctx: only reset stable pstate if the user changed it
Track whether the user requested a stable pstate via the ctx IOCTL and only reset the pstate on context destroy if the user actually changed it. This avoids changing the pstate on contex destroy if the user never changed it in the first place via the IOCTL.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -1
@@ -330,6 +330,8 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx, adev->pm.stable_pstate_ctx =NULL ; else adev->pm.stable_pstate_ctx = ctx; + + ctx->stable_pstate_requested = true; done:mutex_unlock (&adev->pm.stable_pstate_ctx_lock);
@@ -353,7 +355,8 @@ static void amdgpu_ctx_fini(struct kref *ref) }if (drm_dev_enter (&adev->ddev, &idx)) { -amdgpu_ctx_set_stable_pstate (ctx,AMDGPU_CTX_STABLE_PSTATE_NONE ); +if (ctx->stable_pstate_requested) +amdgpu_ctx_set_stable_pstate (ctx,AMDGPU_CTX_STABLE_PSTATE_NONE );drm_dev_exit (idx); }
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +1 -0
@@ -53,6 +53,7 @@ struct amdgpu_ctx {unsigned long ras_counter_ce;unsigned long ras_counter_ue;uint32_t stable_pstate; +bool stable_pstate_requested; };struct amdgpu_ctx_mgr {
Signature · 1 line
2.35.1
[AMD Official Use Only - General]
Quoted 65 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, May 10, 2022 4:04 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu/ctx: only reset stable pstate if the user changed itTrack whether the user requested a stable pstate via the ctx IOCTL and only reset the pstate on context destroy if the user actually changed it. This avoids changing the pstate on contex destroy if the user never changed it in the first place via the IOCTL.
Fixes 8cda7a4f96e435 ("drm/amdgpu/UAPI: add new CTX OP to get/setstable pstates")
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4
-1@@ -330,6 +330,8 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx, adev->pm.stable_pstate_ctx =NULL ; else adev->pm.stable_pstate_ctx = ctx; + + ctx->stable_pstate_requested = true; done:mutex_unlock (&adev->pm.stable_pstate_ctx_lock);@@ -353,7 +355,8 @@ static void amdgpu_ctx_fini(struct kref *ref) }if (drm_dev_enter (&adev->ddev, &idx)) { -amdgpu_ctx_set_stable_pstate (ctx, AMDGPU_CTX_STABLE_PSTATE_NONE); +if (ctx->stable_pstate_requested) +amdgpu_ctx_set_stable_pstate (ctx,AMDGPU_CTX_STABLE_PSTATE_NONE );drm_dev_exit (idx);drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0
-0}drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +1
-1@@ -53,6 +53,7 @@ struct amdgpu_ctx {unsigned long ras_counter_ce;unsigned long ras_counter_ue;uint32_t stable_pstate; +bool stable_pstate_requested; };struct amdgpu_ctx_mgr { --2.35.1
Quoted 27 lines · Alex Deucher
Track whether the user requested a stable pstate via the ctx IOCTL and only reset the pstate on context destroy if the user actually changed it. This avoids changing the pstate on contex destroy if the user never changed it in the first place via the IOCTL.
Fixes 8cda7a4f96e435 ("drm/amdgpu/UAPI: add new CTX OP to get/set stable pstates")Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +2
-0@@ -330,6 +330,8 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx, adev->pm.stable_pstate_ctx =NULL ; else adev->pm.stable_pstate_ctx = ctx; + + ctx->stable_pstate_requested = true; done:mutex_unlock (&adev->pm.stable_pstate_ctx_lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c static void amdgpu_ctx_fini(struct kref *ref) · line 359
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +2
-1@@ -353,7 +355,8 @@ static void amdgpu_ctx_fini(struct kref *ref) }if (drm_dev_enter (&adev->ddev, &idx)) { -amdgpu_ctx_set_stable_pstate (ctx,AMDGPU_CTX_STABLE_PSTATE_NONE ); +if (ctx->stable_pstate_requested) +amdgpu_ctx_set_stable_pstate (ctx,AMDGPU_CTX_STABLE_PSTATE_NONE );
Why not have the check inside amdgpu_ctx_set_stable_pstate - if current stable pstate is not the same as the requested one, then only switch. If the user has not made a request, it will be NONE and the call doesn't have any effect.
Thanks,
Lijo
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0
-0drm_dev_exit (idx); }drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +1
-0@@ -53,6 +53,7 @@ struct amdgpu_ctx {unsigned long ras_counter_ce;unsigned long ras_counter_ue;uint32_t stable_pstate; +bool stable_pstate_requested; };struct amdgpu_ctx_mgr {
Quoted 33 lines · Lijo
Quoted 29 lines · Alex Deucher
Track whether the user requested a stable pstate via the ctx IOCTL and only reset the pstate on context destroy if the user actually changed it. This avoids changing the pstate on contex destroy if the user never changed it in the first place via the IOCTL.
Fixes 8cda7a4f96e435 ("drm/amdgpu/UAPI: add new CTX OP to get/set stable pstates")Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +2
-0@@ -330,6 +330,8 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx, adev->pm.stable_pstate_ctx =NULL ; else adev->pm.stable_pstate_ctx = ctx; + + ctx->stable_pstate_requested = true; done:mutex_unlock (&adev->pm.stable_pstate_ctx_lock);@@ -353,7 +355,8 @@ static void amdgpu_ctx_fini(struct kref *ref) }
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c static void amdgpu_ctx_fini(struct kref *ref) · line 359
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +2
-1if (drm_dev_enter (&adev->ddev, &idx)) { -amdgpu_ctx_set_stable_pstate (ctx,AMDGPU_CTX_STABLE_PSTATE_NONE ); +if (ctx->stable_pstate_requested) +amdgpu_ctx_set_stable_pstate (ctx,AMDGPU_CTX_STABLE_PSTATE_NONE );Why not have the check inside
amdgpu_ctx_set_stable_pstate- if current stable pstate is not the same as the requested one, then only switch. If the user has not made a request, it will be NONE and the call doesn't have any effect.
Good idea. New patch sent out earlier today.
Alex
Quoted 20 lines
Thanks,
LijoQuoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0
-0drm_dev_exit (idx); }drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +1
-0@@ -53,6 +53,7 @@ struct amdgpu_ctx {unsigned long ras_counter_ce;unsigned long ras_counter_ue;uint32_t stable_pstate; +bool stable_pstate_requested; };struct amdgpu_ctx_mgr {