Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6042240imu; Wed, 30 Jan 2019 07:51:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN5jaIZ2haQpfWj+RhwnsPKwILj76dOLLpL7T8VEVyh2k4kP4jU7wUnKLEHzZa9alHwUbmQS X-Received: by 2002:a65:4784:: with SMTP id e4mr27483832pgs.12.1548863486179; Wed, 30 Jan 2019 07:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548863486; cv=none; d=google.com; s=arc-20160816; b=MdHM1Cvs9Qxq6lBgvSabbUMS03nJJ025fGA6ztSxj4cZ0vOC7nlPAAekw1wwz0dehw rZGN8g7uKLxZeFMDIQfblftyuYEJi9AnVdP2wJjAeZeWUPudXjbhAW5xrckPdLqDvrod aYqlV4K8NSzfQ6LMvWquYB3EB47mSRCgEXqM3FqAYTvV4fGq69KOUn/sD4Sda4U1WwId XC1+MUWQj37CyRLGwFeUikSZdx8Gda7jecyfFOn3YgbzV3/sMWl2dtf4O6b5aeiD/nZJ a038ad+14GdLEP61Bo1wfxEvfGK+CKq8JC1LPAhCWcvcsXcpRgCKnZnTVy1WlM16MkRm aTYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nIqgBdSnhUfgpNWo0rEdWcWAtC5A4I5G91315hfcAo4=; b=ur3iJ2/1KxbbyGv0x3C5pKxR2E73kJpC3eyUuLPBEd1JR4Gsc3MOA3DhVLklOWVzok /MmVEN+z/kZEUezBRiYmPofjY43q1TF0gYFgdnIZAskwh62+Kpw6gaYphgIjwpMquyTL BFETQnC4wUlir5KjJm8CiEDYiJGxcmVKvnkqa1bpcrHlfZO9ts1ndeL0u7uNKxAqpYJg EUmLlvWkNlpKkLjP4WkIwT7Vi6i8AIDCXM/SJugjSdreRG/zIZAbqWnGukI0x2WcyMum m1cRl/UuIhDTBo32yZ6NpZDU+1KF2ho1VqqZueSz+cvNviqcUKme99JdnUejaTWp5j0E j1iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f0Gi6IUe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 193si1869570pfa.256.2019.01.30.07.51.10; Wed, 30 Jan 2019 07:51:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f0Gi6IUe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1731593AbfA3Pt4 (ORCPT + 99 others); Wed, 30 Jan 2019 10:49:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:44034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728943AbfA3Pt4 (ORCPT ); Wed, 30 Jan 2019 10:49:56 -0500 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4063121473; Wed, 30 Jan 2019 15:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548863395; bh=+INOyHZAeZt27HReDRQNgCdW/5pwXbyqrHJoIGYAwHA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f0Gi6IUeLtioxqatr7i0DNPhfTdOzXHsjtPn06LuC5R5Pu9LvHwaiF6cORC215d2O b+pzwQbSR2yn4fc54wZNHqpkt2JyDlmSNYCyv6lGcUF9YjrjthrDD7vcnkDqKIQZ3h SKqtLWr8NnftuEyaPR+kyDo/zw9U2bw9D17VvJJU= Date: Wed, 30 Jan 2019 09:49:50 -0600 From: Bjorn Helgaas To: honghui.zhang@mediatek.com Cc: lorenzo.pieralisi@arm.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ryder.lee@mediatek.com, youlin.pei@mediatek.com, jianjun.wang@mediatek.com Subject: Re: [PATCH] PCI: Mediatek: Use resource_size function on resource object Message-ID: <20190130154950.GD229773@google.com> References: <1546409033-20412-1-git-send-email-honghui.zhang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1546409033-20412-1-git-send-email-honghui.zhang@mediatek.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 02, 2019 at 02:03:53PM +0800, honghui.zhang@mediatek.com wrote: > From: Honghui Zhang > > drivers/pci/pcie-mediatek.c:720:13-16: WARNING: Suspicious code. resource_size is maybe missing with mem > > Generated by: scripts/coccinelle/api/resource_size.cocci > > Signed-off-by: Honghui Zhang > --- > drivers/pci/controller/pcie-mediatek.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c > index e307166..0168376 100644 > --- a/drivers/pci/controller/pcie-mediatek.c > +++ b/drivers/pci/controller/pcie-mediatek.c > @@ -654,7 +654,6 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) > struct resource *mem = &pcie->mem; > const struct mtk_pcie_soc *soc = port->pcie->soc; > u32 val; > - size_t size; > int err; > > /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */ > @@ -706,8 +705,7 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) > mtk_pcie_enable_msi(port); > > /* Set AHB to PCIe translation windows */ > - size = mem->end - mem->start; > - val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(size)); > + val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(resource_size(mem))); This is actually a fairly interesting change because it effectively changes this: fls(mem->end - mem->start) to this: fls(mem->end - mem->start + 1) And mem->end is the last valid address, so it changes something like this: fls(0xffff) # == 15 to this: fls(0x10000) # == 16 So while this *looks* like a trivial warning fix, it likely fixes an important bug, and it's worth pointing out what that bug is in the changelog. > writel(val, port->base + PCIE_AHB_TRANS_BASE0_L); > > val = upper_32_bits(mem->start); > -- > 2.6.4 >