From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9BE5C282EC for ; Tue, 18 Mar 2025 15:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=mNNVF6OfOmCtzM6pDA7GbuoZ63UlwDjC1hwrVMplgLI=; b=qgy/jtMhcK/vMO z8dWa7KrJUEhSor8RXMIzaOMgpJrK8kngEIilncrGLjteBSF4G42aIUPwkDYwfU7rfgfCD5qabcFT TchrrCxAie4FSa54zaNbgElyShcMDgM1jokyoDsA+P+hIMggq2YSgw8IGWyzn/+brMG6kT+w+CFVk 5R0zRgIxainD4Pm5mRmBs5snz+ORnS9Ibbe7+kbQg4kCLELGXmgfEP8RwIOaSpegXoNtUncVnsKXr GZbLGZ7nLDyD59pjDUu1AbzplRysilIm0KV8VPYCS0h/DZDvKx3eM7LgtoUu3rzKRNxWXO2zXYR27 mawEmrd4ak6VJACpXSJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tuZ3u-00000006O2J-2yZt; Tue, 18 Mar 2025 15:41:02 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tuZ1L-00000006NeX-00TZ for linux-arm-kernel@lists.infradead.org; Tue, 18 Mar 2025 15:38:24 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 707165C424B; Tue, 18 Mar 2025 15:36:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFF5CC4CEDD; Tue, 18 Mar 2025 15:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742312302; bh=6vRe1xGHKinnOHibJbE9BRfIfB0P0VJZl7MqbD8QsEY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=bXfwIEJS6+zd+bIaOwENgY7nfrSmKdgrBe2vvcpdJKbJrb5Jqaf2uWbOkRjUHuWdF D4tvgE0rYDylQTxTJEYGj1hZJi7olHZJa53jvDS3hpLFZwMJAYn2RsA3VxwDV2vap0 H4ch1ym4qQw1E2Tj+VivqRg9OE7TbeR6RDCT5lKjXHqgG+u1otXcTSX3h0sNcvp6E7 jGwxT2q8nX8H/d5k89z1REfl/AOMKY1e8eCT+OZ2IWok3EFV20IspXV5/AIVqX9vrZ qBuv3xKvbQx1LJdpgbol0l4+isOkbxRnPsYKHydgj7XpEB4GTKE1tiVvTZVA0yKdUw 9zr0WU38KpOGg== Date: Tue, 18 Mar 2025 10:38:20 -0500 From: Bjorn Helgaas To: Frank Li Cc: Rob Herring , Saravana Kannan , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Fabio Estevam , Niklas Cassel , Pengutronix Kernel Team , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, Bjorn Helgaas Subject: Re: [PATCH v12 06/13] PCI: dwc: Add dw_pcie_parent_bus_offset() checking and debug Message-ID: <20250318153820.GA1001146@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250315201548.858189-7-helgaas@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250318_083823_126587_F405E1EA X-CRM114-Status: GOOD ( 22.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Mar 15, 2025 at 03:15:41PM -0500, Bjorn Helgaas wrote: > From: Frank Li > > dw_pcie_parent_bus_offset() looks up the parent bus address of a PCI > controller 'reg' property in devicetree. If implemented, .cpu_addr_fixup() > is a hard-coded way to get the parent bus address corresponding to a CPU > physical address. > > Add debug code to compare the address from .cpu_addr_fixup() with the > address from devicetree. If they match, warn that .cpu_addr_fixup() is > redundant and should be removed; if they differ, warn that something is > wrong with the devicetree. > > If .cpu_addr_fixup() is not implemented, the parent bus address should be > identical to the CPU physical address because we previously ignored the > parent bus address from devicetree. If the devicetree has a different > parent bus address, warn about it being broken. > +++ b/drivers/pci/controller/dwc/pcie-designware.c > @@ -1114,7 +1114,8 @@ resource_size_t dw_pcie_parent_bus_offset(struct dw_pcie *pci, > struct device *dev = pci->dev; > struct device_node *np = dev->of_node; > int index; > - u64 reg_addr; > + u64 reg_addr, fixup_addr; > + u64 (*fixup)(struct dw_pcie *pcie, u64 cpu_addr); > > /* Look up reg_name address on parent bus */ > index = of_property_match_string(np, "reg-names", reg_name); > @@ -1126,5 +1127,28 @@ resource_size_t dw_pcie_parent_bus_offset(struct dw_pcie *pci, > > of_property_read_reg(np, index, ®_addr, NULL); > > + fixup = pci->ops->cpu_addr_fixup; > + if (fixup) { > + fixup_addr = fixup(pci, cpu_phy_addr); > + if (reg_addr == fixup_addr) { > + dev_warn(dev, "%#010llx %s reg[%d] == %#010llx; %ps is redundant\n", On second thought, I think this one should be a dev_info(), not a dev_warn(). We know the *current* devicetree describes the offset correctly, but there may be other devicetrees that do not describe it, and we need to keep .cpu_addr_fixup() for those other devicetrees. So there's nothing the current user can or should do about this. > + cpu_phy_addr, reg_name, index, > + fixup_addr, fixup); > + } else { > + dev_warn(dev, "%#010llx %s reg[%d] != %#010llx fixed up addr; devicetree is broken\n", > + cpu_phy_addr, reg_name, > + index, fixup_addr); > + reg_addr = fixup_addr; > + } > + } else if (!pci->use_parent_dt_ranges) { > + if (reg_addr != cpu_phy_addr) { > + dev_warn(dev, "devicetree has incorrect translation; please check parent \"ranges\" property. CPU physical addr %#010llx, parent bus addr %#010llx\n", > + cpu_phy_addr, reg_addr); > + return 0; > + } > + } > + > + dev_info(dev, "%s parent bus offset is %#010llx\n", > + reg_name, cpu_phy_addr - reg_addr); > return cpu_phy_addr - reg_addr; > }