question about potential dead code in vce_v2_0_enable_mgcg()
Subsystems (2)
Hello everybody,
While looking into Coverity ID 1198635 I ran into the following piece of code at drivers/gpu/drm/radeon/vce_v2_0.c:107:
107void vce_v2_0_enable_mgcg(struct radeon_device *rdev, bool enable) 108{
109 bool sw_cg = false;
110
111 if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_VCE_MGCG)) {
112 if (sw_cg)
113 vce_v2_0_set_sw_cg(rdev, true);
114 else
115 vce_v2_0_set_dyn_cg(rdev, true);
116 } else {
117 vce_v2_0_disable_cg(rdev);
118
119 if (sw_cg)
120 vce_v2_0_set_sw_cg(rdev, false);
121 else
122 vce_v2_0_set_dyn_cg(rdev, false);
123 }
124}
The issue here is that local variable sw_cg is never updated again after its initialization; which cause some code to be logically dead.
My question here is if such variable is there for testing purposes or if it is a sort of an old code leftover that should be removed?
In any case I can send a patch to add a comment or remove the dead code.
I'd really appreciate any comments on this.
Thank you!
--
Gustavo A. R. Silva
Deucher, Alexander
maintainerQuoted 38 lines
-----Original Message-----
From: Gustavo A. R. Silva [mailto:[email protected]]
Sent: Wednesday, June 28, 2017 10:22 AM
To: Deucher, Alexander; Koenig, Christian; David Airlie
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: [gpu-drm-radeon] question about potential dead code invce_v2_0_enable_mgcg()Hello everybody,
While looking into Coverity ID 1198635 I ran into the following piece of code at
drivers/gpu/drm/radeon/vce_v2_0.c:107:107void
vce_v2_0_enable_mgcg(struct radeon_device *rdev, bool enable)108{
109 boolsw_cg= false;
110
111 if (enable && (rdev->cg_flags&RADEON_CG_SUPPORT_VCE_MGCG)) {
112 if (sw_cg)
113vce_v2_0_set_sw_cg(rdev, true);
114 else
115vce_v2_0_set_dyn_cg(rdev, true);
116 } else {
117vce_v2_0_disable_cg(rdev);
118
119 if (sw_cg)
120vce_v2_0_set_sw_cg(rdev, false);
121 else
122vce_v2_0_set_dyn_cg(rdev, false);
123 }
124}The issue here is that local variable
sw_cgis never updated again after its initialization; which cause some code to be logically dead.
Quoted 6 lines
My question here is if such variable is there for testing purposes or if it is a sort of an old code leftover that should be removed?
In any case I can send a patch to add a comment or remove the dead code.
I'd really appreciate any comments on this.
I wanted to leave the code in for debugging if we ran into problems with dynamic clockgating.
Alex
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Alex,
Quoting "Deucher, Alexander" <[email protected]>:
Quoted 38 lines
Quoted 38 lines
-----Original Message-----
From: Gustavo A. R. Silva [mailto:[email protected]]
Sent: Wednesday, June 28, 2017 10:22 AM
To: Deucher, Alexander; Koenig, Christian; David Airlie
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: [gpu-drm-radeon] question about potential dead code invce_v2_0_enable_mgcg()Hello everybody,
While looking into Coverity ID 1198635 I ran into the following piece of code at
drivers/gpu/drm/radeon/vce_v2_0.c:107:107void
vce_v2_0_enable_mgcg(struct radeon_device *rdev, bool enable)108{
109 boolsw_cg= false;
110
111 if (enable && (rdev->cg_flags&RADEON_CG_SUPPORT_VCE_MGCG)) {
112 if (sw_cg)
113vce_v2_0_set_sw_cg(rdev, true);
114 else
115vce_v2_0_set_dyn_cg(rdev, true);
116 } else {
117vce_v2_0_disable_cg(rdev);
118
119 if (sw_cg)
120vce_v2_0_set_sw_cg(rdev, false);
121 else
122vce_v2_0_set_dyn_cg(rdev, false);
123 }
124}The issue here is that local variable
sw_cgis never updated again after its initialization; which cause some code to be logically dead.
Quoted 9 lines
Quoted 6 lines
My question here is if such variable is there for testing purposes or if it is a sort of an old code leftover that should be removed?
In any case I can send a patch to add a comment or remove the dead code.
I'd really appreciate any comments on this.
I wanted to leave the code in for debugging if we ran into problems with dynamic clockgating.
Do you mind if I send a patch to add such comment and make it clear the purpose of that variable?
drivers/gpu/drm/radeon/vce_v2_0.c +4 -0
@@ -104,6 +104,10 @@ static void vce_v2_0_disable_cg(struct radeon_device *rdev)WREG32 (VCE_CGTT_CLK_OVERRIDE ,7 ); } +/* +* Local variable sw_cg is used for debugging purposes, in case we +* ran into problems with dynamic clock gating. Don't remove it. +*/ void vce_v2_0_enable_mgcg (struct radeon_device *rdev,bool enable) {bool sw_cg = false;
Thanks for clarifying!
--
Gustavo A. R. Silva
Quoted 51 lines · Gustavo A. R. Silva
Hi Alex,
Quoting "Deucher, Alexander" <[email protected]>:
Quoted 47 lines
Quoted 45 lines
-----Original Message-----
From: Gustavo A. R. Silva [mailto:[email protected]]
Sent: Wednesday, June 28, 2017 10:22 AM
To: Deucher, Alexander; Koenig, Christian; David Airlie
Cc: [email protected]; [email protected]; linux-
[email protected]
Subject: [gpu-drm-radeon] question about potential dead code invce_v2_0_enable_mgcg()Hello everybody,
While looking into Coverity ID 1198635 I ran into the following piece of code at
drivers/gpu/drm/radeon/vce_v2_0.c:107:107void
vce_v2_0_enable_mgcg(struct radeon_device *rdev, bool enable)108{
109 boolsw_cg= false;
110
111 if (enable && (rdev->cg_flags&RADEON_CG_SUPPORT_VCE_MGCG)) {
112 if (sw_cg)
113vce_v2_0_set_sw_cg(rdev, true);
114 else
115vce_v2_0_set_dyn_cg(rdev, true);
116 } else {
117vce_v2_0_disable_cg(rdev);
118
119 if (sw_cg)
120vce_v2_0_set_sw_cg(rdev, false);
121 else
122vce_v2_0_set_dyn_cg(rdev, false);
123 }
124}The issue here is that local variable
sw_cgis never updated again after its initialization; which cause some code to be logically dead.My question here is if such variable is there for testing purposes or if it is a sort of an old code leftover that should be removed?
In any case I can send a patch to add a comment or remove the dead code.
I'd really appreciate any comments on this.
Quoted 6 lines
Quoted 3 lines
I wanted to leave the code in for debugging if we ran into problems with dynamic clockgating.
Do you mind if I send a patch to add such comment and make it clear the purpose of that variable?
Sure. Thanks.
Alex
Quoted 26 lines
drivers/gpu/drm/radeon/vce_v2_0.c +4
-0@@ -104,6 +104,10 @@ static void vce_v2_0_disable_cg(struct radeon_device *rdev)WREG32 (VCE_CGTT_CLK_OVERRIDE ,7 ); } +/* +* Local variable sw_cg is used for debugging purposes, in case we +* ran into problems with dynamic clock gating. Don't remove it. +*/ void vce_v2_0_enable_mgcg (struct radeon_device *rdev,bool enable) {bool sw_cg = false;Thanks for clarifying!
--
Gustavo A. R. Silva
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg()
Add function header comment to make it clear that local variable sw_cg is used for debugging and it should not be removed.
Addresses-Coverity-ID: 1198635
--- drivers/gpu/drm/radeon/vce_v2_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/vce_v2_0.c +4 -0
@@ -104,6 +104,10 @@ static void vce_v2_0_disable_cg(struct radeon_device *rdev)WREG32 (VCE_CGTT_CLK_OVERRIDE ,7 ); } +/* +* Local variable sw_cg is used for debugging purposes, in case we +* ran into problems with dynamic clock gating. Don't remove it. +*/ void vce_v2_0_enable_mgcg (struct radeon_device *rdev,bool enable) {bool sw_cg = false;
Signature · 1 line
2.5.0
Alex Deucher
AppliedRe: [PATCH] drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg()
Quoted 6 lines · Gustavo A. R. Silva
Add function header comment to make it clear that local variable
sw_cgis used for debugging and it should not be removed.Addresses-Coverity-ID: 1198635
Cc Alex Deucher <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>
Applied. thanks!
Alex
Quoted 20 lines
--- drivers/gpu/drm/radeon/vce_v2_0.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/radeon/vce_v2_0.c +4
-1@@ -104,6 +104,10 @@ static void vce_v2_0_disable_cg(struct radeon_device *rdev)WREG32 (VCE_CGTT_CLK_OVERRIDE ,7 ); } +/* +* Local variable sw_cg is used for debugging purposes, in case we +* ran into problems with dynamic clock gating. Don't remove it. +*/ void vce_v2_0_enable_mgcg (struct radeon_device *rdev,bool enable) {bool sw_cg = false; --
Quoted 2 lines
2.5.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg()
Quoting Alex Deucher <[email protected]>:
Quoted 11 lines
Quoted 6 lines · Gustavo A. R. Silva
Add function header comment to make it clear that local variable
sw_cgis used for debugging and it should not be removed.Addresses-Coverity-ID: 1198635
Cc Alex Deucher <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>Applied. thanks!
Great, glad to help :)
Thanks
--
Gustavo A. R. Silva