Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6084812imu; Wed, 30 Jan 2019 08:32:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN4D2vexgoID/pPmwLcnzEmn0WbUDj8lW5dCuV1m08aCeGtI3sEWjPcyolAJRowuSmb/j+Id X-Received: by 2002:a65:6645:: with SMTP id z5mr28397924pgv.351.1548865966653; Wed, 30 Jan 2019 08:32:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548865966; cv=none; d=google.com; s=arc-20160816; b=nc0eVKkPUbzHfqI7FKAkK45k1kICZP4fnvqYKACXKuoOb/McFOTq504tJeS795kug7 9y+ZE0b9u7KyXXaQFSyZGDgnDZKtHMMIQ1zl7DJm89Ums+34/4jag67J3aYktqi8EXj3 3eR9gd5+7Vr/DlFRZy+6F/a54D2AC92H66wnzyU4zk9OFm6BMvtyiuTq2Mue+Hm7q643 ngnKu/2I6UaPxrTW3xfLTcbQkWOHRmE8fPHsLvxyv9fcg3GfYvdlMVISIJf87ty8llYN swTRPmDcVBaLgDDN5/g/J5EExcAAbfWYBSTMTW2Ul1A0a/PArv7LoLNkpsjW4nJFGmqh Vp7A== 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; bh=2Pnw27UxInDoouZOrxMBHmUGv48y3EGjw8UyaLuDSBE=; b=KeINwAXRttc3v6wgo85D8CGXaABwrSBGh0jCERYDrrfEt2peZc+CVf6+G7ocZjBC8Q sGuo3fOTEiIL3FCUCa5ujeyFDkbi4sVwc46ELw/QJKAiAr++d22AEoSe9XhkjJEvNIjW gSNnQnDB1RF33VZLl2mv+vRzN3p+w/cP+EmhwBrCJ7429F+FdVvK/OSZtP53pqgA29Cm rKX0/nlO153p6IMOF8imcEulhP90WGTZr3n1/AG6UB0c+czifr4aW7PYgWbsQY9Vn/Op 6uoE9sHhsqt4ql6/tWu/9ZmDz5Tqp6P4X/aKuA4f41SaTnCLWy9MI8W2JEXFxeKYKPZS GpUg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l123si1910850pfc.187.2019.01.30.08.32.28; Wed, 30 Jan 2019 08:32:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732010AbfA3QcG (ORCPT + 99 others); Wed, 30 Jan 2019 11:32:06 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57314 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730556AbfA3QcD (ORCPT ); Wed, 30 Jan 2019 11:32:03 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4EFA4EBD; Wed, 30 Jan 2019 08:32:02 -0800 (PST) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.197.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A45243F589; Wed, 30 Jan 2019 08:32:00 -0800 (PST) Date: Wed, 30 Jan 2019 16:31:55 +0000 From: Lorenzo Pieralisi To: Bjorn Helgaas Cc: honghui.zhang@mediatek.com, youlin.pei@mediatek.com, ryder.lee@mediatek.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, jianjun.wang@mediatek.com, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] PCI: Mediatek: Use resource_size function on resource object Message-ID: <20190130163155.GA5847@e107981-ln.cambridge.arm.com> References: <1546409033-20412-1-git-send-email-honghui.zhang@mediatek.com> <20190130123347.GB30991@e107981-ln.cambridge.arm.com> <20190130155853.GE229773@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190130155853.GE229773@google.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 30, 2019 at 09:58:53AM -0600, Bjorn Helgaas wrote: > On Wed, Jan 30, 2019 at 12:33:47PM +0000, Lorenzo Pieralisi wrote: > > 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))); > > > > checkpatch warns on this line, please make sure patches pass it before > > posting them. > > I didn't actually run checkpatch myself, so I don't know why it > complained. WARNING: line over 80 characters #35: FILE: drivers/pci/controller/pcie-mediatek.c:708: + val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(resource_size(mem))); I do run it as a sanity check. > The patch you merged moves "mem_size = resource_size(mem)" higher up, > away from the previous location and its use, which makes it a little > harder to read. That's because it was how the original code (which as you pointed out is likely buggy) was written. Anyway patch dropped waiting for a v2 consistent with your review - apologies for missing some key review points. Lorenzo