Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4717669rwl; Tue, 28 Mar 2023 10:18:24 -0700 (PDT) X-Google-Smtp-Source: AK7set/IEhmdRiau8nUXDEeDizHm1lkufPCkm7p+DDUzA7caXtDIjQGLRO/vgq/arSCEVhB+JcOz X-Received: by 2002:a05:6402:2920:b0:500:2cc6:36d5 with SMTP id ee32-20020a056402292000b005002cc636d5mr23953495edb.8.1680023904644; Tue, 28 Mar 2023 10:18:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680023904; cv=none; d=google.com; s=arc-20160816; b=ZcNBJX2ihObc2cEnY4vt2+Wye5qT1XS7P/PGiKYVVATMVxN4YGGYiQwlgGZQVXoPXK JB8rrlMNNXfJQSMYsmA5YncKRXJn8iPYgKYwKLS9MMT74daQ5G2Y0UhwJmgkCDZeUY+c 8hcSe4QcuJQWn2ze+iPoL7A0CUWWd2JYIkcCpAF51oT6JKb5r6h+y6VVojUnUoZKmTny IpThje5JM8w4HkNZJ+Y5/RdBdIpG7hZzNqBhjB6hr/XxQ3UanESyOxcIihM4Bn+a4gsq +/3js6Mw8MuJQcRDK82AB5q2CqI62eWNGZitSuAKoq5TEZOCI9WWFUPhGEl7fRQtFE0g pHvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RZ84F5mmwg2rUf6wTJBp8HVb/P0gcpV2OuvdSfGO8dI=; b=YQV2dnNT68RH/5VWOv6rhq1E9umzIZNWKzgXQJCrRtZAVOVhBAO2Wz7Zo9iIbi5u/V +vHLHMHua0hfLaTdYi2lJrqL6hMJxd7su1wWmy9PSyYDtVNE1YBBe3bygCn3Zo6lcfOx CEqWcfC5g6HahbfYo1HqTk6y/Pl3LveL+S/SAQCEBVHuvILz2wyw2Nq3kobjwvUJXKAe zA2AZG1SAub01JT9tahbxOBBN9lQdmR4GVC7wfX1I/xTFE9x/uAH0uES+jobm57J3rUx s8nTRsuhB5Qc1MIR7hJqHhjQaR/Qhjer4tYTRkbvYxSp8/RplzzB1oYD3B9iGHtYTqwu lnhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BzVDmw43; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020aa7d5d5000000b004acbebc9408si30560913eds.383.2023.03.28.10.17.59; Tue, 28 Mar 2023 10:18:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BzVDmw43; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbjC1RGo (ORCPT + 99 others); Tue, 28 Mar 2023 13:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjC1RGn (ORCPT ); Tue, 28 Mar 2023 13:06:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7A116E89; Tue, 28 Mar 2023 10:06:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 323B7B81DB3; Tue, 28 Mar 2023 17:06:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E436C433D2; Tue, 28 Mar 2023 17:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680023198; bh=mSJs5c0u+mvYERTVXLbz2yaNg7v/fMoz0d2LwP4Amgk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BzVDmw43m60lvH0Y3KjAIrZm6woD7+AuyL5jMqZObEtFgYW0wKZ620dZ4j9la6GKr VH8ZHy/40ROZYD+wpguyi+Hnrz60lue9UANRUfwDWT/XbZvuIjg+BtjmxcvuJFM0ua 1/dAgwGGnlprh119IPhnzAFOQwKOkEQBbBkalAwVG2eSKm3HK2LifA8O54SAtv0OrM Q2Imm1uVHmcTk5A4PFzt+qUwbo+dHHPbScXOewUOlstrb1u7MWsTKJsUqKlg2vlWQd YoFG0MgDzpeekikZ/MLrmC269nUqCEwWEpjubIXnIc3R2OyHsl3hwsR4CkmRyAcYF8 vzeSM9lwScGGA== Date: Tue, 28 Mar 2023 10:06:36 -0700 From: Nathan Chancellor To: Sui Jingfeng <15330273260@189.cn> Cc: kernel test robot , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sumit Semwal , Christian Koenig , llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Li Yi Subject: Re: [PATCH v8 2/2] drm: add kms driver for loongson display controller Message-ID: <20230328170636.GA1986005@dev-arch.thelio-3990X> References: <20230320100131.1277034-3-15330273260@189.cn> <202303281754.jWI20j2C-lkp@intel.com> <027cf6d5-6de2-3424-7a81-a43ab689c3d4@189.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <027cf6d5-6de2-3424-7a81-a43ab689c3d4@189.cn> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 28, 2023 at 11:22:50PM +0800, Sui Jingfeng wrote: > HI, > > On 2023/3/28 17:27, kernel test robot wrote: > > Hi Sui, > > > > Thank you for the patch! Perhaps something to improve: > > > > [auto build test WARNING on drm-misc/drm-misc-next] > > [also build test WARNING on linus/master v6.3-rc4 next-20230328] > > [If your patch is applied to the wrong git tree, kindly drop us a note. > > And when submitting patch, we suggest to use '--base' as documented in > > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > > > url: https://github.com/intel-lab-lkp/linux/commits/Sui-Jingfeng/MAINTAINERS-add-maintainers-for-DRM-LOONGSON-driver/20230320-180408 > > base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next > > patch link: https://lore.kernel.org/r/20230320100131.1277034-3-15330273260%40189.cn > > patch subject: [PATCH v8 2/2] drm: add kms driver for loongson display controller > > config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20230328/202303281754.jWI20j2C-lkp@intel.com/config) > > compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) > > reproduce (this is a W=1 build): > > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > > chmod +x ~/bin/make.cross > > # https://github.com/intel-lab-lkp/linux/commit/80b4115f44993f4ebf47b1cb9e8f02953575b977 > > git remote add linux-review https://github.com/intel-lab-lkp/linux > > git fetch --no-tags linux-review Sui-Jingfeng/MAINTAINERS-add-maintainers-for-DRM-LOONGSON-driver/20230320-180408 > > git checkout 80b4115f44993f4ebf47b1cb9e8f02953575b977 > > # save the config file > > mkdir build_dir && cp config build_dir/.config > > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig > > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/accel/ drivers/gpu/drm/loongson/ drivers/iio/light/ drivers/media/pci/intel/ > > > > If you fix the issue, kindly add following tag where applicable > > | Reported-by: kernel test robot > > | Link: https://lore.kernel.org/oe-kbuild-all/202303281754.jWI20j2C-lkp@intel.com/ > > > > All warnings (new ones prefixed by >>): > > > > > > drivers/gpu/drm/loongson/lsdc_drv.c:232:11: warning: variable 'gpu' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] > > else if (descp->chip == CHIP_LS7A2000) > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > drivers/gpu/drm/loongson/lsdc_drv.c:235:7: note: uninitialized use occurs here > > if (!gpu) { > > ^~~ > > drivers/gpu/drm/loongson/lsdc_drv.c:232:7: note: remove the 'if' if its condition is always true > > else if (descp->chip == CHIP_LS7A2000) > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > drivers/gpu/drm/loongson/lsdc_drv.c:217:21: note: initialize the variable 'gpu' to silence this warning > > struct pci_dev *gpu; > > ^ > > = NULL > > 1 warning generated. > > -- > > In practice,? either? descp->chip == CHIP_LS7A2000 or descp->chip == > CHIP_LS7A1000 will be happened at runtime. > > the variable 'gpu' is guaranteed to be initialized when code run at? > drivers/gpu/drm/loongson/lsdc_drv.c:235 > > This warnning is almost wrong here. Clang's semantic analysis happens before optimizations, meaning it does not perform interprocedural analysis, so it does not have enough information at this point to tell that. Either just initialize gpu to NULL and let the existing 'if (!gpu)' handle it or add a separate else branch that warns about an unhandled chip value so that it is obvious what needs to be done if someone forgets to update this statement when a new chip is supported by this driver. > > > > drivers/gpu/drm/loongson/lsdc_pll.c:188:14: warning: variable 'diff' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] > > else if (clock_khz < computed) > > ^~~~~~~~~~~~~~~~~~~~ > > drivers/gpu/drm/loongson/lsdc_pll.c:191:9: note: uninitialized use occurs here > > if (diff < min) { > > ^~~~ > > drivers/gpu/drm/loongson/lsdc_pll.c:188:10: note: remove the 'if' if its condition is always true > > else if (clock_khz < computed) > > ^~~~~~~~~~~~~~~~~~~~~~~~~ > > drivers/gpu/drm/loongson/lsdc_pll.c:177:22: note: initialize the variable 'diff' to silence this warning > > unsigned int diff; > > ^ > > = 0 > > 1 warning generated. > > Here the robot is also wrong here in practice, > > because either? if (clock_khz >= computed) or else if (clock_khz < computed) > will be happen. > > 'diff' variable is guaranteed to be initialized. Make that clearer by turning 'else if (clock_khz < computed)' into just 'else' as the warning suggests? I do not see why the condition is specified at all if it is just an 'else' in practice. Cheers, Nathan > > > > vim +232 drivers/gpu/drm/loongson/lsdc_drv.c > > > > 212 > > 213 static int lsdc_get_dedicated_vram(struct lsdc_device *ldev, > > 214 const struct lsdc_desc *descp) > > 215 { > > 216 struct drm_device *ddev = &ldev->base; > > 217 struct pci_dev *gpu; > > 218 resource_size_t base, size; > > 219 > > 220 /* > > 221 * The GPU and display controller in LS7A1000/LS7A2000 are separated > > 222 * PCIE devices, they are two devices not one. The DC does not has a > > 223 * dedicate VRAM bar, because the BIOS engineer choose to assign the > > 224 * VRAM to the GPU device. Sadly, after years application, this form > > 225 * as a convention for loongson integrated graphics. Bar 2 of the GPU > > 226 * device contain the base address and size of the VRAM, both the GPU > > 227 * and the DC can access the on-board VRAM as long as the DMA address > > 228 * emitted fall in [base, base + size). > > 229 */ > > 230 if (descp->chip == CHIP_LS7A1000) > > 231 gpu = pci_get_device(PCI_VENDOR_ID_LOONGSON, 0x7A15, NULL); > > > 232 else if (descp->chip == CHIP_LS7A2000) > > 233 gpu = pci_get_device(PCI_VENDOR_ID_LOONGSON, 0x7A25, NULL); > > 234 > > 235 if (!gpu) { > > 236 drm_warn(ddev, "No GPU device found\n"); > > 237 return -ENODEV; > > 238 } > > 239 > > 240 base = pci_resource_start(gpu, 2); > > 241 size = pci_resource_len(gpu, 2); > > 242 > > 243 ldev->vram_base = base; > > 244 ldev->vram_size = size; > > 245 > > 246 drm_info(ddev, "dedicated vram start: 0x%llx, size: %uMB\n", > > 247 (u64)base, (u32)(size >> 20)); > > 248 > > 249 return 0; > > 250 } > > 251 > > >