Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752762AbdF2MfC (ORCPT ); Thu, 29 Jun 2017 08:35:02 -0400 Received: from mail-yb0-f176.google.com ([209.85.213.176]:34567 "EHLO mail-yb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751893AbdF2Mez (ORCPT ); Thu, 29 Jun 2017 08:34:55 -0400 MIME-Version: 1.0 In-Reply-To: <20170628180843.Horde.KKnryIaN7wki5B896j1w8Sa@gator4166.hostgator.com> References: <20170628092229.Horde.Hsk18WJyYojTJE5OKzhVd3d@gator4166.hostgator.com> <20170628180843.Horde.KKnryIaN7wki5B896j1w8Sa@gator4166.hostgator.com> From: Alex Deucher Date: Thu, 29 Jun 2017 08:34:53 -0400 Message-ID: Subject: Re: [gpu-drm-radeon] question about potential dead code in vce_v2_0_enable_mgcg() To: "Gustavo A. R. Silva" Cc: "Deucher, Alexander" , David Airlie , Maling list - DRI developers , "Koenig, Christian" , amd-gfx list , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2797 Lines: 94 On Wed, Jun 28, 2017 at 7:08 PM, Gustavo A. R. Silva wrote: > Hi Alex, > > Quoting "Deucher, Alexander" : > >>> -----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