From: Bjorn Helgaas <helgaas@kernel.org>
To: Semih Baskan <strst.gs@gmail.com>
Cc: "Manivannan Sadhasivam" <mani@kernel.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Rob Herring" <robh@kernel.org>, "Ray Jui" <rjui@broadcom.com>,
"Scott Branden" <sbranden@broadcom.com>,
"Rafał Miłecki" <rafal@milecki.pl>,
"Rafał Miłecki" <zajec5@gmail.com>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Arnd Bergmann" <arnd@arndb.de>, "Rosen Penev" <rosenp@gmail.com>,
"Rani Hod" <rani.hod@gmail.com>,
bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Bjorn Helgaas" <bhelgaas@google.com>
Subject: [PATCH v4 2/2] PCI: iproc: Use the EROM outbound window on BCMA
Date: Tue, 13 Oct 2026 17:04:21 -0500 [thread overview]
Message-ID: <20261013220421.1588051-3-bhelgaas@google.com> (raw)
In-Reply-To: <20261013220421.1588051-1-bhelgaas@google.com>
The PCIe outbound window base on Northstar depends on the PCIe Gen2 core
revision. Revision 0x01 uses 0x08000000, 0x40000000 and 0x48000000 for
controllers 0 to 2, while revision 0x07 (NS-B0) uses 0x08000000,
0x20000000 and 0x28000000. Broadcom's own driver branches on the core
revision for exactly this reason.
bcm-ns.dtsi is shared by every Northstar SoC, so it cannot carry a value
that is correct on both. Commit 767012397976 ("ARM: dts: BCM5301X:
Describe PCIe controllers fully") gave the controllers a ranges property.
The commit shipped in v7.1.
With that property present, two things go wrong with this driver:
1) devm_pci_alloc_host_bridge() parses those ranges and requests them,
then this driver adds its own window and requests the whole list a
second time, so every controller fails to probe with -EBUSY.
2) The DT window itself is only correct on core revision 0x07. On
revision 0x01 it points at an address the hardware does not decode,
and the first MMIO access to a BAR takes an imprecise external abort.
The enumeration ROM reports the correct base for the revision actually
present, and bcma already provides it as addr_s[0].
To solve 1), use pci_alloc_host_bridge() directly to avoid the request of
all the DT resources done in pci_parse_request_of_pci_ranges(). Instead,
request the memory window from the EROM.
To solve 2), parse the memory resources from DT and emit a warning if it
describes a window that doesn't match the window from the EROM. The
mismatch means the devicetree describes a window the hardware does not
decode, and that should be fixed in the dts rather than ignored silently.
The driver is correct whether or not the DT describes a window.
The same commit also added compatible = "brcm,iproc-pcie", so these
nodes now match pcie-iproc-platform. With CONFIG_PCIE_IPROC_PLATFORM
enabled, which is the default on ARCH_BCM_IPROC, that driver binds them
first and this driver's probe fails inside devm_pci_alloc_host_bridge().
This commit fixes the configurations where the BCMA driver is the one in
use; OpenWrt builds that way, with PCIE_IPROC_PLATFORM disabled. The
platform path takes the DT window as-is and has the same wrong address
on core revision 0x01, so that side needs a devicetree fix either way.
Fixes: 767012397976 ("ARM: dts: BCM5301X: Describe PCIe controllers fully")
Based on:
https://patch.msgid.link/20260807160526.379-1-strst.gs@gmail.com
https://patch.msgid.link/20260912043626.437-1-strst.gs@gmail.com
---
drivers/pci/controller/pcie-iproc-bcma.c | 40 ++++++++++++++++++++++--
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/controller/pcie-iproc-bcma.c b/drivers/pci/controller/pcie-iproc-bcma.c
index 593418c2bc3a..1e258cd8fed4 100644
--- a/drivers/pci/controller/pcie-iproc-bcma.c
+++ b/drivers/pci/controller/pcie-iproc-bcma.c
@@ -11,7 +11,9 @@
#include <linux/phy/phy.h>
#include <linux/bcma/bcma.h>
#include <linux/ioport.h>
+#include <linux/of_address.h>
+#include "../pci.h"
#include "pcie-iproc.h"
@@ -31,6 +33,29 @@ static int iproc_bcma_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
return bcma_core_irq(bdev, 5);
}
+static void iproc_bcma_pcie_check_dt_window(struct iproc_pcie *pcie)
+{
+ struct device_node *np = pcie->dev->of_node;
+ struct of_pci_range_parser parser;
+ struct of_pci_range range;
+ struct resource res;
+
+ if (!np || of_pci_range_parser_init(&parser, np))
+ return;
+
+ for_each_of_pci_range(&parser, &range) {
+ if ((range.flags & IORESOURCE_TYPE_BITS) != IORESOURCE_MEM)
+ continue;
+
+ if (of_pci_range_to_resource(&range, np, &res))
+ continue;
+
+ if (res.start != pcie->mem.start || res.end != pcie->mem.end)
+ dev_warn(pcie->dev, "DT window %pR does not match EROM window %pR, using EROM\n",
+ &res, &pcie->mem);
+ }
+}
+
static int iproc_bcma_pcie_probe(struct bcma_device *bdev)
{
struct device *dev = &bdev->dev;
@@ -38,10 +63,20 @@ static int iproc_bcma_pcie_probe(struct bcma_device *bdev)
struct pci_host_bridge *bridge;
int ret;
- bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
+ bridge = pci_alloc_host_bridge(sizeof(*pcie));
if (!bridge)
return -ENOMEM;
+ bridge->dev.parent = dev;
+
+ ret = devm_add_action_or_reset(dev, devm_pci_alloc_host_bridge_release,
+ bridge);
+ if (ret)
+ return -ENOMEM;
+
+ bridge->swizzle_irq = pci_common_swizzle;
+ bridge->map_irq = iproc_bcma_pcie_map_irq;
+
pcie = pci_host_bridge_priv(bridge);
pcie->dev = dev;
@@ -59,13 +94,12 @@ static int iproc_bcma_pcie_probe(struct bcma_device *bdev)
pcie->mem.end = bdev->addr_s[0] + SZ_128M - 1;
pcie->mem.name = "PCIe MEM space";
pcie->mem.flags = IORESOURCE_MEM;
+ iproc_bcma_pcie_check_dt_window(pcie);
pci_add_resource(&bridge->windows, &pcie->mem);
ret = devm_request_pci_bus_resources(dev, &bridge->windows);
if (ret)
return ret;
- bridge->map_irq = iproc_bcma_pcie_map_irq;
-
bcma_set_drvdata(bdev, pcie);
return iproc_pcie_setup(pcie, &bridge->windows);
--
2.53.0
next prev parent reply other threads:[~2026-10-13 22:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 22:04 [PATCH v4 0/2] PCI: iproc-bcma: Use EROM instead of devicetree Bjorn Helgaas
2026-10-13 22:04 ` [PATCH v4 1/2] PCI: Expose devm_pci_alloc_host_bridge_release() Bjorn Helgaas
2026-10-14 11:00 ` Manivannan Sadhasivam
2026-10-13 22:04 ` Bjorn Helgaas [this message]
2026-10-14 1:17 ` [PATCH v4 2/2] PCI: iproc: Use the EROM outbound window on BCMA Semih Baskan
2026-10-14 13:34 ` [PATCH v4 0/2] PCI: iproc-bcma: Use EROM instead of devicetree Manivannan Sadhasivam
2026-10-14 13:34 ` Manivannan Sadhasivam
2026-10-15 17:31 ` Florian Fainelli
2026-10-15 18:51 ` Semih Baskan
2026-10-15 19:10 ` Florian Fainelli
2026-10-15 20:45 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261013220421.1588051-3-bhelgaas@google.com \
--to=helgaas@kernel.org \
--cc=arnd@arndb.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhelgaas@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=rafal@milecki.pl \
--cc=rani.hod@gmail.com \
--cc=rjui@broadcom.com \
--cc=robh@kernel.org \
--cc=rosenp@gmail.com \
--cc=sbranden@broadcom.com \
--cc=strst.gs@gmail.com \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox