From patchwork Tue Oct 20 14:47:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Larouche X-Patchwork-Id: 7454301 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB1409F37F for ; Wed, 21 Oct 2015 03:36:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CBBF920902 for ; Wed, 21 Oct 2015 03:36:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F12312053E for ; Wed, 21 Oct 2015 03:36:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3CAA16ECDB; Tue, 20 Oct 2015 20:36:55 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 589 seconds by postgrey-1.34 at gabe; Tue, 20 Oct 2015 07:56:56 PDT Received: from mtxmxout2.matrox.com (mtxmxout2.matrox.com [138.11.2.92]) by gabe.freedesktop.org (Postfix) with ESMTPS id D70EB6E238 for ; Tue, 20 Oct 2015 07:56:56 -0700 (PDT) Received: from venus.matrox.com (unknown [192.168.1.36]) by mtxmxout2.matrox.com (Postfix) with ESMTP id 58D3E98385 for ; Tue, 20 Oct 2015 10:47:06 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=matrox.com; s=dkim; t=1445352426; bh=7MUJYoqcmgcsr0Ogw3IUV4o1g7lhOAZqe75HI90v+M8=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=FXyEOZ+/CdRy0UL5xyWW3/wbfGPgQzNqSnjN0WmKlw6TmQklrlVLLnnQNwqEBWy+F WOmlEuOIhGWFAeZAL2xfJMwho6FIuRHNSgnnroJ6K5OOQIYFCDAhWprDp4T3i1yYiN ScBqtUM8gKYWrZY4iZmKpx/m/liVIhM2a2crvbGc= Received: (from ssmsp@localhost) by venus.matrox.com (8.14.6/8.13.2) id t9KEl6IO026716 for dri-devel@lists.freedesktop.org; Tue, 20 Oct 2015 10:47:06 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by venus.matrox.com (Postfix) with ESMTP id 42F9D5F753; Tue, 20 Oct 2015 10:47:06 -0400 (EDT) X-Virus-MTX-Scanned: by Matrox Virus scanner at venus.matrox.com Received: from venus.matrox.com ([127.0.0.1]) by localhost (venus.matrox.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 07d60gJ55x4M; Tue, 20 Oct 2015 10:47:06 -0400 (EDT) Received: from venus-in.matrox.com (localhost.localdomain [127.0.0.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by venus.matrox.com (Postfix) with ESMTPS id 2FA945F747; Tue, 20 Oct 2015 10:47:06 -0400 (EDT) Received: from [192.168.152.161] (dyn-152-161.matrox.com [192.168.152.161]) by venus-in.matrox.com (Postfix) with ESMTP id 2CBA061BE0; Tue, 20 Oct 2015 10:47:06 -0400 (EDT) Message-ID: <562653EA.1030009@matrox.com> Date: Tue, 20 Oct 2015 10:47:06 -0400 From: Mathieu Larouche Organization: Matrox Graphics Inc. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Jan Beulich , airlied@linux.ie Subject: Re: drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls() References: <5624E21E02000078000AC48B@prv-mh.provo.novell.com> In-Reply-To: <5624E21E02000078000AC48B@prv-mh.provo.novell.com> X-Mailman-Approved-At: Tue, 20 Oct 2015 20:35:38 -0700 Cc: dri-devel@lists.freedesktop.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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 19/10/2015 6:29 AM, Jan Beulich wrote: > I can only guess that instead of testm/testn (which are either > uninitialized or have pre-determined values at the end of the preceding > loops) n and m were meant to be used by commit e829d7ef9f > ("drm/mgag200: Add support for a new rev of G200e"). In any event the > compiler is right in warning that testm/testn are possibly uninitalized > at this point, i.e. some change is needed no matter what. > > Signed-off-by: Jan Beulich > Cc: Mathieu Larouche > --- > drivers/gpu/drm/mgag200/mgag200_mode.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > --- 4.3-rc6/drivers/gpu/drm/mgag200/mgag200_mode.c > +++ 4.3-rc6-mgag200-uninit/drivers/gpu/drm/mgag200/mgag200_mode.c > @@ -194,7 +194,7 @@ static int mga_g200se_set_plls(struct mg > } > } > > - fvv = pllreffreq * testn / testm; > + fvv = pllreffreq * n / m; > fvv = (fvv - 800000) / 50000; > > if (fvv > 15) > > > > If you are using n/m instead of testn/testm, you need to add 1 to the variables to keep consistency. However, you have the same issue where m/n could be used without being initialized. So, I propose to keep testm, testn & testp and initialized them with the default value. Signed-off-by: Mathieu Larouche --- drivers/gpu/drm/mgag200/mgag200_mode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index c99d3fe..055799c 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -123,6 +123,9 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock) vcomax = 320000; vcomin = 160000; pllreffreq = 25000; + testm = 1; + testn = 17; + testp = 8; delta = 0xffffffff; permitteddelta = clock * 5 / 1000; @@ -157,6 +160,9 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock) vcomax = 1600000; vcomin = 800000; pllreffreq = 25000; + testm = 1; + testn = 50; + testp = 16; if (clock < 25000) clock = 25000;