From 79aba5e09246e52081935700b003167e9540ba63 Mon Sep 17 00:00:00 2001 From: Semih Baskan Date: Tue, 27 Oct 2026 03:15:41 +0000 Subject: [PATCH] bcm53xx: backport the mainline PCIe EROM window fix The fix carried as 351 since a36ed219f2 was reworked upstream and merged for Linux v7.4. Replace it with the two mainline commits: 39d1c645bb99 ("PCI: Expose devm_pci_alloc_host_bridge_release()") 9850907ee1dd ("PCI: iproc: Use the EROM outbound window on BCMA") The first one adds a helper the second one uses, so it goes in as 348. Like the old 351, the upstream version requests only the memory window the enumeration ROM reports. When the DT window differs from it, the driver now prints a warning, where the old 351 dropped it silently. The dts (349) carries the addresses of PCIe core revision 0x07, so boards with revision 0x01 now log "does not match EROM window" for controllers 1 and 2. The window in use is the same as before. Tested on an ASUS RT-N18U (BCM47081, core revision 0x01): the BCM4360 on bcma0:7 is found and its link comes up, and /proc/iomem and the PCI device list match the old 351. Signed-off-by: Semih Baskan Link: https://github.com/openwrt/openwrt/pull/26237 Signed-off-by: Robert Marko --- ...e-devm_pci_alloc_host_bridge_release.patch | 49 ++++++ ...Use-the-EROM-outbound-window-on-BCMA.patch | 74 --------- ...Use-the-EROM-outbound-window-on-BCMA.patch | 142 ++++++++++++++++++ 3 files changed, 191 insertions(+), 74 deletions(-) create mode 100644 target/linux/bcm53xx/patches-6.18/348-v7.4-PCI-Expose-devm_pci_alloc_host_bridge_release.patch delete mode 100644 target/linux/bcm53xx/patches-6.18/351-PCI-iproc-Use-the-EROM-outbound-window-on-BCMA.patch create mode 100644 target/linux/bcm53xx/patches-6.18/351-v7.4-PCI-iproc-Use-the-EROM-outbound-window-on-BCMA.patch diff --git a/target/linux/bcm53xx/patches-6.18/348-v7.4-PCI-Expose-devm_pci_alloc_host_bridge_release.patch b/target/linux/bcm53xx/patches-6.18/348-v7.4-PCI-Expose-devm_pci_alloc_host_bridge_release.patch new file mode 100644 index 00000000000..69142283335 --- /dev/null +++ b/target/linux/bcm53xx/patches-6.18/348-v7.4-PCI-Expose-devm_pci_alloc_host_bridge_release.patch @@ -0,0 +1,49 @@ +From 39d1c645bb99d8bd7e6f5b0183b192f30c88d917 Mon Sep 17 00:00:00 2001 +From: Bjorn Helgaas +Date: Tue, 13 Oct 2026 17:04:20 -0500 +Subject: [PATCH] PCI: Expose devm_pci_alloc_host_bridge_release() + +devm_pci_alloc_host_bridge() allocates a struct pci_host_bridge and also +parses device tree resources and claims them. There are drivers, e.g., +pcie-iproc-bcma.c, that need to allocate a pci_host_bridge but do not need +device tree resources. + +Expose devm_pci_alloc_host_bridge_release() so they can avoid the device +tree parts by calling pci_alloc_host_bridge() directly and adding the devm +release function manually. + +[bhelgaas: add EXPORT_SYMBOL] +Signed-off-by: Bjorn Helgaas +Signed-off-by: Manivannan Sadhasivam +Reviewed-by: Manivannan Sadhasivam +Link: https://patch.msgid.link/20261013220421.1588051-2-bhelgaas@google.com +--- + drivers/pci/pci.h | 1 + + drivers/pci/probe.c | 3 ++- + 2 files changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/pci/pci.h ++++ b/drivers/pci/pci.h +@@ -436,6 +436,7 @@ enum pci_bar_type { + pci_bar_mem64, /* A 64-bit memory BAR */ + }; + ++void devm_pci_alloc_host_bridge_release(void *data); + struct device *pci_get_host_bridge_device(struct pci_dev *dev); + void pci_put_host_bridge_device(struct device *dev); + +--- a/drivers/pci/probe.c ++++ b/drivers/pci/probe.c +@@ -689,10 +689,11 @@ struct pci_host_bridge *pci_alloc_host_b + } + EXPORT_SYMBOL(pci_alloc_host_bridge); + +-static void devm_pci_alloc_host_bridge_release(void *data) ++void devm_pci_alloc_host_bridge_release(void *data) + { + pci_free_host_bridge(data); + } ++EXPORT_SYMBOL(devm_pci_alloc_host_bridge_release); + + struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev, + size_t priv) diff --git a/target/linux/bcm53xx/patches-6.18/351-PCI-iproc-Use-the-EROM-outbound-window-on-BCMA.patch b/target/linux/bcm53xx/patches-6.18/351-PCI-iproc-Use-the-EROM-outbound-window-on-BCMA.patch deleted file mode 100644 index 9c45d7faaad..00000000000 --- a/target/linux/bcm53xx/patches-6.18/351-PCI-iproc-Use-the-EROM-outbound-window-on-BCMA.patch +++ /dev/null @@ -1,74 +0,0 @@ -From d48312ba459476b217bf3d11dd2c91e5c8121a06 Mon Sep 17 00:00:00 2001 -From: Semih Baskan -Date: Mon, 27 Jul 2026 08:30:00 +0300 -Subject: [PATCH] PCI: iproc: Use the EROM outbound window on BCMA - -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. -That commit is in neither 6.12 nor 6.18, so kernels without it are -unaffected. - -With that property present, two things go wrong with this driver: - -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. - -When the DT window is used, it 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]. Drop any memory -window that came from the device tree and use that instead, requesting -only the window this driver owns. This makes the driver correct whether -or not the DT describes a window. - -Tested on an ASUS RT-N18U (BCM47081) and a Linksys EA9200 (BCM4709), -both core revision 0x01. - -Fixes: 767012397976 ("ARM: dts: BCM5301X: Describe PCIe controllers fully") -Signed-off-by: Semih Baskan ---- - drivers/pci/controller/pcie-iproc-bcma.c | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - ---- a/drivers/pci/controller/pcie-iproc-bcma.c -+++ b/drivers/pci/controller/pcie-iproc-bcma.c -@@ -36,6 +36,7 @@ static int iproc_bcma_pcie_probe(struct - struct device *dev = &bdev->dev; - struct iproc_pcie *pcie; - struct pci_host_bridge *bridge; -+ struct resource_entry *win, *tmp; - int ret; - - bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); -@@ -55,12 +56,20 @@ static int iproc_bcma_pcie_probe(struct - - pcie->base_addr = bdev->addr; - -+ resource_list_for_each_entry_safe(win, tmp, &bridge->windows) { -+ if (resource_type(win->res) != IORESOURCE_MEM) -+ continue; -+ -+ devm_release_resource(dev, win->res); -+ resource_list_destroy_entry(win); -+ } -+ - pcie->mem.start = bdev->addr_s[0]; - pcie->mem.end = bdev->addr_s[0] + SZ_128M - 1; - pcie->mem.name = "PCIe MEM space"; - pcie->mem.flags = IORESOURCE_MEM; - pci_add_resource(&bridge->windows, &pcie->mem); -- ret = devm_request_pci_bus_resources(dev, &bridge->windows); -+ ret = devm_request_resource(dev, &iomem_resource, &pcie->mem); - if (ret) - return ret; - diff --git a/target/linux/bcm53xx/patches-6.18/351-v7.4-PCI-iproc-Use-the-EROM-outbound-window-on-BCMA.patch b/target/linux/bcm53xx/patches-6.18/351-v7.4-PCI-iproc-Use-the-EROM-outbound-window-on-BCMA.patch new file mode 100644 index 00000000000..76cc47b717a --- /dev/null +++ b/target/linux/bcm53xx/patches-6.18/351-v7.4-PCI-iproc-Use-the-EROM-outbound-window-on-BCMA.patch @@ -0,0 +1,142 @@ +From 9850907ee1dd4376c09c4129e0adbe3b39d191b7 Mon Sep 17 00:00:00 2001 +From: Semih Baskan +Date: Tue, 13 Oct 2026 17:04:21 -0500 +Subject: [PATCH] PCI: iproc: Use the EROM outbound window on BCMA + +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. + +Based on: + https://patch.msgid.link/20260807160526.379-1-strst.gs@gmail.com + https://patch.msgid.link/20260912043626.437-1-strst.gs@gmail.com + +Fixes: 767012397976 ("ARM: dts: BCM5301X: Describe PCIe controllers fully") +Signed-off-by: Semih Baskan +Signed-off-by: Manivannan Sadhasivam +Signed-off-by: Bjorn Helgaas +Tested-by: Semih Baskan +Link: https://patch.msgid.link/20261013220421.1588051-3-bhelgaas@google.com +--- + drivers/pci/controller/pcie-iproc-bcma.c | 40 ++++++++++++++++++++++-- + 1 file changed, 37 insertions(+), 3 deletions(-) + +--- a/drivers/pci/controller/pcie-iproc-bcma.c ++++ b/drivers/pci/controller/pcie-iproc-bcma.c +@@ -11,7 +11,9 @@ + #include + #include + #include ++#include + ++#include "../pci.h" + #include "pcie-iproc.h" + + +@@ -31,6 +33,29 @@ static int iproc_bcma_pcie_map_irq(const + 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 + 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 + 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);