Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6055171imu; Wed, 30 Jan 2019 08:04:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN5prgts5VthU1harlHCvKkLeQ/ZVnQ/ZTP4MRFLkUyGvAz4kpFyPrU9rc5PBryCa3arz6VI X-Received: by 2002:a63:193:: with SMTP id 141mr28248956pgb.136.1548864263890; Wed, 30 Jan 2019 08:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548864263; cv=none; d=google.com; s=arc-20160816; b=pPBjx3i+m6ihgA3bAwV0gvC5ob1YwEFLaax2a98VW6/GDJhNEL7chAorjkDVjvTSu1 q5Krb7E2MHbiFUPYZcdrm915ASqd6uqRtZbcWInD3R1+RW6no2K9y/LzE+VKTM8biNYm Y6UQJyW1wYGaGn3vJbt6Yg528YRBMwyd6BbAn1RKO7Dh2pbODJuybUbNBQtLwdAz/lHV w5NAEexsYSd22rEoeKxiLU3BZfA45htXcaNEyQCUCrg7mgId5NUQaV17vEUpiLGngyCU uuojLrL+T3I7moG3ydea/flr+vTqMoFLgCrbyK3vQ7AO+H9C65Rv09BfmzoAsLCgt+Y4 23zg== 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=TB226JaxnpJO5Y68UaXIJQ/J4BGUGCpirz4HjJHZTWE=; b=Zv0yuYoxYZRJZoddB4t97twn0Cr4CTLa/W00FGkqOLjAsiO+0yZwSTBNOOBmzseB/V sz6fZG1nUwcHql39/5qgOZ3181Pxodl0BlZH6xSyUyGwzJcu3GsXvvNxnBiYQN3WGvCV BouSOeLQwFT2eZ/jHoKdobYuBssNzWBq5YymzTae0KbgDZTyLLqosDqp8H7++LvCZhRt sO+SVm4VJoU5i5tPC0Csmha57mcc1j7XCnc7C+Cs/SfR+NSODbpWzpVAzPa96uhyfY8I IDLfEm94wWlwFUWVyaM6T9pqPXmjxCYC5TRIglrozhd806AqT8no7Ymc2bZqBTrY/YMA DYfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a24js7aW; 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 b128si1825563pfa.283.2019.01.30.08.04.07; Wed, 30 Jan 2019 08:04:23 -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=a24js7aW; 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 S1731979AbfA3QDd (ORCPT + 99 others); Wed, 30 Jan 2019 11:03:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:48026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731461AbfA3QDc (ORCPT ); Wed, 30 Jan 2019 11:03:32 -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 90C8E207E0; Wed, 30 Jan 2019 16:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548864212; bh=uOJy6HHER2vHS2dUZM9kzGlmh4vosXagwnDxutC4v6k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a24js7aW/cYCaY/Vpk8cqJlVrlqw/euqCg+kBnqwwu6C+GiJbVNu858GbKi9ZYJ3f S99ZKo0pYcSJ1GoDoXc9fDZSgVEYWuQF9xlPXcT6unsQBNGluA6jq1pRpLdv16esjN 4bXPBig8vF40CgdMnkLqWFMjzWXtZBkjgBxgTxGk= Date: Wed, 30 Jan 2019 10:03:29 -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: <20190130160329.GF229773@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))); > writel(val, port->base + PCIE_AHB_TRANS_BASE0_L); > > val = upper_32_bits(mem->start); Unrelated to this patch, but just below this: /* Set PCIe to AXI translation memory space.*/ val = fls(0xffffffff) | WIN_ENABLE; writel(val, port->base + PCIE_AXI_WINDOW0); Can you double-check the use of "fls(0xffffffff)"? That expression is a constant and I think evaluates to 31 (0x1f), i.e., val = 0x1f | WIN_ENABLE; I don't know the hardware, so this might be correct, but "fls(0xffffffff)" looks funny because I think it's the same as "fls(0x80000000)". Bjorn