Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6618820imu; Wed, 30 Jan 2019 19:04:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN5aCyht+rm0jr876DBrnNhAp/YJFp6HnlctSxXu7mG2/SxQnDXv4qWNjmzj52gncEuV2dD0 X-Received: by 2002:a62:546:: with SMTP id 67mr32431183pff.99.1548903899322; Wed, 30 Jan 2019 19:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548903899; cv=none; d=google.com; s=arc-20160816; b=fUJHBvtjj7lb/maAlie/qGK+rJDGaFPdy/RcAdZkurxTK8+U7aNPICrCYL3qNfiAlN oIOFsXhv19ccjVTdUZR8Q1jUO9XapBqjT5MsADxhJ0xR5nxYG1GZVQfGSxxsv3eYjuzr pAbQbCkeChtEc6fccgYHwo5q1YkTsiMi5FeU+O4ePuiv33qLYPM460/5xv4BknHn8DBV WHU0L1TJMp+rD/N+n5+OjYDCSGYP6cVqe2LOCWDXJwNLhDZakBVvVqs68setdxNm2V6D Ve0HjA07QG32mUS4OzAlEWD4iwsPIXvknVNbpyNtYZqOZmxA2+bXM9s/jpHS31uc99Zd aCLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=Uhw8IqnuVrFy+JOUAf/u9IbSkswI+DUQjqhVpFQjIr8=; b=V0SdzQaEJwMKXuN0xGoVKZYx7CIfe1C9+BdnW/cqGXKf5qkOkgae+r5n7J415JsMe9 MkbEZqv7/hyhMj/K3bPsFpSVfI4YVWpohqUB7CqyoeWyrHmN/GTHu3zWe3wlYx+alg6w 5miw2EVywssJKf3nknipSJZS9sq53mXdH1ZGTEg88FGiNpYDdqGRQclwJat2e89c7utq IZ7QZsEtllhDuF/uWwPWSTECyRQbR7jG7Mohn7PmnBeT5QKljVO8iJ35oTe/Zk+56FYd O28bfxFO5ux57x303x37cHGo2jHk/O0TP9KHZfKpofCau0OK7L8r5S1T+KTZ0yUqRFCm QeNQ== 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 b6si3261196pls.367.2019.01.30.19.04.43; Wed, 30 Jan 2019 19:04:59 -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 S1729038AbfAaDEF (ORCPT + 99 others); Wed, 30 Jan 2019 22:04:05 -0500 Received: from Mailgw01.mediatek.com ([1.203.163.78]:59877 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725771AbfAaDEE (ORCPT ); Wed, 30 Jan 2019 22:04:04 -0500 X-UUID: b7899a23e4d04701b4a4e31183bd13b0-20190131 X-UUID: b7899a23e4d04701b4a4e31183bd13b0-20190131 Received: from mtkcas34.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 498669996; Thu, 31 Jan 2019 11:03:55 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 31 Jan 2019 11:03:53 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 31 Jan 2019 11:03:53 +0800 Message-ID: <1548903833.22019.26.camel@mhfsdcap03> Subject: Re: [PATCH] PCI: Mediatek: Use resource_size function on resource object From: Honghui Zhang To: Bjorn Helgaas CC: , , , , , , , Date: Thu, 31 Jan 2019 11:03:53 +0800 In-Reply-To: <20190130154950.GD229773@google.com> References: <1546409033-20412-1-git-send-email-honghui.zhang@mediatek.com> <20190130154950.GD229773@google.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-01-30 at 09:49 -0600, Bjorn Helgaas 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))); > > 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); This size will set the MMIO size, which means that the RC will translate the MMIO access from mem->start to mem->end. The real MMIO size is specified in devicetree, which is 0x1000_0000 for both mt2712 and mt7622. This change make the size from fls(0x1000_0000) to fls(0x1000_0001), not really change the values. I will update the commit message and add the information mentioned above. Thanks for your kindly review. > > -- > > 2.6.4 > >