* [gpu-drm-radeon] question about potential dead code in vce_v2_0_enable_mgcg()
@ 2017-06-28 14:22 Gustavo A. R. Silva
2017-06-28 15:40 ` Deucher, Alexander
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-28 14:22 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie
Cc: amd-gfx, dri-devel, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [gpu-drm-radeon] question about potential dead code in vce_v2_0_enable_mgcg()
2017-06-28 14:22 [gpu-drm-radeon] question about potential dead code in vce_v2_0_enable_mgcg() Gustavo A. R. Silva
@ 2017-06-28 15:40 ` Deucher, Alexander
2017-06-28 23:08 ` Gustavo A. R. Silva
0 siblings, 1 reply; 7+ messages in thread
From: Deucher, Alexander @ 2017-06-28 15:40 UTC (permalink / raw)
To: 'Gustavo A. R. Silva', Koenig, Christian, David Airlie
Cc: amd-gfx, dri-devel, linux-kernel
> -----Original Message-----
> From: Gustavo A. R. Silva [mailto:garsilva@embeddedor.com]
> Sent: Wednesday, June 28, 2017 10:22 AM
> To: Deucher, Alexander; Koenig, Christian; David Airlie
> Cc: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-
> kernel@vger.kernel.org
> Subject: [gpu-drm-radeon] question about potential dead code in
> vce_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 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.
I wanted to leave the code in for debugging if we ran into problems with dynamic clockgating.
Alex
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gpu-drm-radeon] question about potential dead code in vce_v2_0_enable_mgcg()
2017-06-28 15:40 ` Deucher, Alexander
@ 2017-06-28 23:08 ` Gustavo A. R. Silva
2017-06-29 12:34 ` Alex Deucher
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-28 23:08 UTC (permalink / raw)
To: Deucher, Alexander
Cc: Koenig, Christian, David Airlie, amd-gfx, dri-devel, linux-kernel
Hi Alex,
Quoting "Deucher, Alexander" <Alexander.Deucher@amd.com>:
>> -----Original Message-----
>> From: Gustavo A. R. Silva [mailto:garsilva@embeddedor.com]
>> Sent: Wednesday, June 28, 2017 10:22 AM
>> To: Deucher, Alexander; Koenig, Christian; David Airlie
>> Cc: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-
>> kernel@vger.kernel.org
>> Subject: [gpu-drm-radeon] question about potential dead code in
>> vce_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 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.
>
> 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?
--- a/drivers/gpu/drm/radeon/vce_v2_0.c
+++ b/drivers/gpu/drm/radeon/vce_v2_0.c
@@ -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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gpu-drm-radeon] question about potential dead code in vce_v2_0_enable_mgcg()
2017-06-28 23:08 ` Gustavo A. R. Silva
@ 2017-06-29 12:34 ` Alex Deucher
2017-06-29 17:38 ` [PATCH] drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg() Gustavo A. R. Silva
0 siblings, 1 reply; 7+ messages in thread
From: Alex Deucher @ 2017-06-29 12:34 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Deucher, Alexander, David Airlie, Maling list - DRI developers,
Koenig, Christian, amd-gfx list, LKML
On Wed, Jun 28, 2017 at 7:08 PM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> Hi Alex,
>
> Quoting "Deucher, Alexander" <Alexander.Deucher@amd.com>:
>
>>> -----Original Message-----
>>> From: Gustavo A. R. Silva [mailto:garsilva@embeddedor.com]
>>> Sent: Wednesday, June 28, 2017 10:22 AM
>>> To: Deucher, Alexander; Koenig, Christian; David Airlie
>>> Cc: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org;
>>> linux-
>>> kernel@vger.kernel.org
>>> Subject: [gpu-drm-radeon] question about potential dead code in
>>> vce_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 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.
>>
>>
>> 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
>
> --- a/drivers/gpu/drm/radeon/vce_v2_0.c
> +++ b/drivers/gpu/drm/radeon/vce_v2_0.c
> @@ -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
>
>
>
>
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg()
2017-06-29 12:34 ` Alex Deucher
@ 2017-06-29 17:38 ` Gustavo A. R. Silva
2017-06-29 19:25 ` Alex Deucher
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-29 17:38 UTC (permalink / raw)
To: Alex Deucher, Alex Deucher, Christian König, David Airlie
Cc: amd-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva
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
Cc: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
drivers/gpu/drm/radeon/vce_v2_0.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/radeon/vce_v2_0.c b/drivers/gpu/drm/radeon/vce_v2_0.c
index fce2144..b0a43b6 100644
--- a/drivers/gpu/drm/radeon/vce_v2_0.c
+++ b/drivers/gpu/drm/radeon/vce_v2_0.c
@@ -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;
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg()
2017-06-29 17:38 ` [PATCH] drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg() Gustavo A. R. Silva
@ 2017-06-29 19:25 ` Alex Deucher
2017-06-29 19:52 ` Gustavo A. R. Silva
0 siblings, 1 reply; 7+ messages in thread
From: Alex Deucher @ 2017-06-29 19:25 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Alex Deucher, Christian König, David Airlie, amd-gfx list,
Maling list - DRI developers, LKML
On Thu, Jun 29, 2017 at 1:38 PM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> 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
> Cc: Alex Deucher <alexdeucher@gmail.com>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Applied. thanks!
Alex
> ---
> drivers/gpu/drm/radeon/vce_v2_0.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/vce_v2_0.c b/drivers/gpu/drm/radeon/vce_v2_0.c
> index fce2144..b0a43b6 100644
> --- a/drivers/gpu/drm/radeon/vce_v2_0.c
> +++ b/drivers/gpu/drm/radeon/vce_v2_0.c
> @@ -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;
> --
> 2.5.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg()
2017-06-29 19:25 ` Alex Deucher
@ 2017-06-29 19:52 ` Gustavo A. R. Silva
0 siblings, 0 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-29 19:52 UTC (permalink / raw)
To: Alex Deucher
Cc: Alex Deucher, Christian König, David Airlie, amd-gfx list,
Maling list - DRI developers, LKML
Quoting Alex Deucher <alexdeucher@gmail.com>:
> On Thu, Jun 29, 2017 at 1:38 PM, Gustavo A. R. Silva
> <garsilva@embeddedor.com> wrote:
>> 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
>> Cc: Alex Deucher <alexdeucher@gmail.com>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>
> Applied. thanks!
>
Great, glad to help :)
Thanks
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-06-29 19:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 14:22 [gpu-drm-radeon] question about potential dead code in vce_v2_0_enable_mgcg() Gustavo A. R. Silva
2017-06-28 15:40 ` Deucher, Alexander
2017-06-28 23:08 ` Gustavo A. R. Silva
2017-06-29 12:34 ` Alex Deucher
2017-06-29 17:38 ` [PATCH] drm/radeon: add header comment for clarification to vce_v2_0_enable_mgcg() Gustavo A. R. Silva
2017-06-29 19:25 ` Alex Deucher
2017-06-29 19:52 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).