From patchwork Wed Jun 28 23:08:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 9815703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A672A602B1 for ; Thu, 29 Jun 2017 00:42:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9753728497 for ; Thu, 29 Jun 2017 00:42:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B3B3284B2; Thu, 29 Jun 2017 00:42:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_NUMERIC_HELO autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED7F028497 for ; Thu, 29 Jun 2017 00:42:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3A756E611; Thu, 29 Jun 2017 00:42:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 1500 seconds by postgrey-1.35 at gabe; Wed, 28 Jun 2017 23:56:39 UTC Received: from gateway31.websitewelcome.com (gateway31.websitewelcome.com [192.185.143.38]) by gabe.freedesktop.org (Postfix) with ESMTPS id 927646E112 for ; Wed, 28 Jun 2017 23:56:39 +0000 (UTC) Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 9CD2E316C5 for ; Wed, 28 Jun 2017 18:08:43 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id QM4edvDaq6R1uQM4edhY0V; Wed, 28 Jun 2017 18:08:40 -0500 Received: from gator4166.hostgator.com ([108.167.133.22]:54902) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1dQM4h-002QD9-Ay; Wed, 28 Jun 2017 18:08:43 -0500 Received: from 189.152.189.231 ([189.152.189.231]) by gator4166.hostgator.com (Horde Framework) with HTTPS; Wed, 28 Jun 2017 18:08:43 -0500 Date: Wed, 28 Jun 2017 18:08:43 -0500 Message-ID: <20170628180843.Horde.KKnryIaN7wki5B896j1w8Sa@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: "Deucher, Alexander" Subject: Re: [gpu-drm-radeon] question about potential dead code in vce_v2_0_enable_mgcg() References: <20170628092229.Horde.Hsk18WJyYojTJE5OKzhVd3d@gator4166.hostgator.com> In-Reply-To: User-Agent: Horde Application Framework 5 MIME-Version: 1.0 Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - lists.freedesktop.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 108.167.133.22 X-Exim-ID: 1dQM4h-002QD9-Ay X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:54902 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 2 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Mailman-Approved-At: Thu, 29 Jun 2017 00:41:57 +0000 Cc: dri-devel@lists.freedesktop.org, "Koenig, Christian" , amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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? bool sw_cg = false; Thanks for clarifying! --- Gustavo A. R. Silva --- 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) {