* [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment
@ 2026-11-16 15:23 Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 01/13] PCI: Add pci_bus_size_and_assign_resources() Ilpo Järvinen
` (12 more replies)
0 siblings, 13 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński
Cc: linux-kernel, Ilpo Järvinen
Hi all,
Bridge window sizing and resource assignment can be started from
multiple entry points: rescan and hotplug under pci_rescan_remove_lock,
and BAR resize from sysfs or driver probe under device_lock() only. As
the entry points hold pci_bus_sem at most for read, nothing prevents two
sizing and assignment passes from running concurrently on the same
bridge windows and BARs.
Multiple issues due to these races could be reproduced some on a real
host and more in QEMU with a synthetic PCI host bridge (not part of
this series) by looping BAR resize against a rescan through sysfs. The
failures include spurious BAR resize failures, a WARN in
pci_dev_res_restore(), a NULL pointer dereference in
__release_resource(), and a bridge window programmed over RAM. None of
them occurred with this series applied.
The series first adds pci_bus_size_and_assign_resources() so that PCI
core can hold the locks across both phases and converting 1:1 callers
(alpha nautilus retains extra sizing call to avoid complex
refactoring). Secondly, convert setup-bus entrypoints to guard() and
pci_res_setup_lock to serialize the sizing and assignment passes.
Last, convert the remaining pci_bus_assign_resources() users and
remove it.
Drivers that call pci_assign_resource() or pci_release_resource()
directly are not covered by this series.
I've another series coming up which will add struct pci_setup_data that
is to be held across the entire sizing and assignment algorithm, which
is another reason why those actions have to be kept together going
forward. The goal of that upcoming series is to size also assigned
bridge windows properly and we need a place to keep the alignment
because STARTALIGN is lost when a resource gets assigned.
Ilpo Järvinen (13):
PCI: Add pci_bus_size_and_assign_resources()
alpha/PCI: Convert to pci_bus_size_and_assign_resources()
PCI: Use guard(&pci_bus_sem) in pci_do_resource_release_and_resize()
PCI: Hold pci_bus_sem across sizing and assignment entrypoints
PCI: Serialize bridge window sizing and resource assignment
i82875p_edac: Convert to pci_assign_unassigned_bus_resources()
platform/x86: asus-wmi: Convert to
pci_assign_unassigned_bus_resources()
platform/x86: eeepc-laptop: Convert to
pci_assign_unassigned_bus_resources()
parisc/PCI: Convert to pci_assign_unassigned_bus_resources()
PCI: hotplug: octep: Convert to pci_assign_unassigned_bus_resources()
PCI: ftpci100: Convert to pci_assign_unassigned_bus_resources()
PCI: hv: Convert to pci_assign_unassigned_bus_resources()
PCI: Remove pci_bus_assign_resources()
arch/alpha/kernel/sys_nautilus.c | 2 +-
arch/arm/kernel/bios32.c | 5 +-
arch/m68k/coldfire/pci.c | 3 +-
arch/mips/pci/pci-legacy.c | 5 +-
arch/sh/drivers/pci/pci.c | 3 +-
drivers/edac/i82875p_edac.c | 2 +-
drivers/parisc/dino.c | 2 +-
drivers/parisc/lba_pci.c | 7 +--
drivers/pci/controller/pci-ftpci100.c | 2 +-
drivers/pci/controller/pci-hyperv.c | 2 +-
drivers/pci/hotplug/acpiphp_glue.c | 4 +-
drivers/pci/hotplug/octep_hp.c | 2 +-
drivers/pci/pci.h | 1 +
drivers/pci/setup-bus.c | 78 ++++++++++++++++++++++-----
drivers/pci/setup-cardbus.c | 3 ++
drivers/pcmcia/cardbus.c | 3 +-
drivers/platform/x86/asus-wmi.c | 2 +-
drivers/platform/x86/eeepc-laptop.c | 2 +-
include/linux/pci.h | 2 +-
19 files changed, 88 insertions(+), 42 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 01/13] PCI: Add pci_bus_size_and_assign_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 02/13] alpha/PCI: Convert to pci_bus_size_and_assign_resources() Ilpo Järvinen
` (11 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Russell King, Greg Ungerer,
Geert Uytterhoeven, Thomas Bogendoerfer, Yoshinori Sato,
Rich Felker, John Paul Adrian Glaubitz, James E.J. Bottomley,
Helge Deller, Rafael J. Wysocki, Len Brown, Dominik Brodowski,
linux-arm-kernel, linux-kernel, linux-m68k, linux-mips, linux-sh,
linux-parisc, linux-acpi
Cc: Ilpo Järvinen
Bridge window sizing and resource assignment must not run concurrently
with another sizing and assignment pass or with device removal.
Preventing that requires holding locks across both phases. Many callers
outside of PCI core call pci_bus_size_bridges() immediately followed by
pci_bus_assign_resources() and cannot hold the PCI core internal locks
across the two calls.
Add pci_bus_size_and_assign_resources() into PCI core which combines
these two operations and convert the callers that call them back to
back.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
arch/arm/kernel/bios32.c | 5 ++---
arch/m68k/coldfire/pci.c | 3 +--
arch/mips/pci/pci-legacy.c | 5 ++---
arch/sh/drivers/pci/pci.c | 3 +--
drivers/parisc/lba_pci.c | 7 ++-----
drivers/pci/hotplug/acpiphp_glue.c | 3 +--
drivers/pci/setup-bus.c | 7 +++++++
drivers/pcmcia/cardbus.c | 3 +--
include/linux/pci.h | 1 +
9 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index ac0e890510da..555bfb091d30 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -510,15 +510,14 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
/*
* We insert PCI resources into the iomem_resource and
* ioport_resource trees in either pci_bus_claim_resources()
- * or pci_bus_assign_resources().
+ * or pci_bus_size_and_assign_resources().
*/
if (pci_has_flag(PCI_PROBE_ONLY)) {
pci_bus_claim_resources(bus);
} else {
struct pci_bus *child;
- pci_bus_size_bridges(bus);
- pci_bus_assign_resources(bus);
+ pci_bus_size_and_assign_resources(bus);
list_for_each_entry(child, &bus->children, node)
pcie_bus_configure_settings(child);
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index 5afb207ccc51..dd21c77c43a6 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -250,8 +250,7 @@ static int __init mcf_pci_init(void)
rootbus->resource[0] = &mcf_pci_io;
rootbus->resource[1] = &mcf_pci_mem;
- pci_bus_size_bridges(rootbus);
- pci_bus_assign_resources(rootbus);
+ pci_bus_size_and_assign_resources(rootbus);
pci_bus_add_devices(rootbus);
return 0;
}
diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c
index dae6dafdd6e0..ec0e42d9a895 100644
--- a/arch/mips/pci/pci-legacy.c
+++ b/arch/mips/pci/pci-legacy.c
@@ -129,15 +129,14 @@ static void pcibios_scanbus(struct pci_controller *hose)
/*
* We insert PCI resources into the iomem_resource and
* ioport_resource trees in either pci_bus_claim_resources()
- * or pci_bus_assign_resources().
+ * or pci_bus_size_and_assign_resources().
*/
if (pci_has_flag(PCI_PROBE_ONLY)) {
pci_bus_claim_resources(bus);
} else {
struct pci_bus *child;
- pci_bus_size_bridges(bus);
- pci_bus_assign_resources(bus);
+ pci_bus_size_and_assign_resources(bus);
list_for_each_entry(child, &bus->children, node)
pcie_bus_configure_settings(child);
}
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 878a27a1acfb..c91ca8f4cb1c 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -81,8 +81,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
need_domain_info = 1;
}
- pci_bus_size_bridges(hose->bus);
- pci_bus_assign_resources(hose->bus);
+ pci_bus_size_and_assign_resources(hose->bus);
pci_bus_add_devices(hose->bus);
}
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 5197a3c93c70..39ab93ba458b 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1639,11 +1639,8 @@ lba_driver_probe(struct parisc_device *dev)
if (is_pdc_pat()) {
/* assign resources to un-initialized devices */
- DBG_PAT("LBA pci_bus_size_bridges()\n");
- pci_bus_size_bridges(lba_bus);
-
- DBG_PAT("LBA pci_bus_assign_resources()\n");
- pci_bus_assign_resources(lba_bus);
+ DBG_PAT("LBA pci_bus_size_and_assign_resources()\n");
+ pci_bus_size_and_assign_resources(lba_bus);
#ifdef DEBUG_LBA_PAT
DBG_PAT("\nLBA PIOP resource tree\n");
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 78e3effbb32d..632344f34cae 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -465,8 +465,7 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)
max = pci_scan_bridge(bus, dev, max, 1);
if (dev->subordinate) {
pcibios_resource_survey_bus(dev->subordinate);
- pci_bus_size_bridges(dev->subordinate);
- pci_bus_assign_resources(dev->subordinate);
+ pci_bus_size_and_assign_resources(dev->subordinate);
}
}
}
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index ed16ef7c26fa..29ec9ba59d92 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -2492,3 +2492,10 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
__pci_bus_assign_resources(bus, &add_list, NULL);
}
EXPORT_SYMBOL_GPL(pci_assign_unassigned_bus_resources);
+
+void pci_bus_size_and_assign_resources(struct pci_bus *bus)
+{
+ pci_bus_size_bridges(bus);
+ __pci_bus_assign_resources(bus, NULL, NULL);
+}
+EXPORT_SYMBOL_GPL(pci_bus_size_and_assign_resources);
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 5e5cf2c3e2c8..19df3f9228a7 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -81,8 +81,7 @@ int __ref cb_alloc(struct pcmcia_socket *s)
/*
* Size all resources below the CardBus controller.
*/
- pci_bus_size_bridges(bus);
- pci_bus_assign_resources(bus);
+ pci_bus_size_and_assign_resources(bus);
cardbus_config_irq_and_cls(bus, s->pci_irq);
/* socket specific tune function */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index aa3765a20a96..d89aeb7c9ff7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1569,6 +1569,7 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);
void pci_bus_assign_resources(const struct pci_bus *bus);
void pci_bus_claim_resources(struct pci_bus *bus);
void pci_bus_size_bridges(struct pci_bus *bus);
+void pci_bus_size_and_assign_resources(struct pci_bus *bus);
int pci_claim_resource(struct pci_dev *, int);
int pci_claim_bridge_resource(struct pci_dev *bridge, int i);
void pci_assign_unassigned_resources(void);
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/13] alpha/PCI: Convert to pci_bus_size_and_assign_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 01/13] PCI: Add pci_bus_size_and_assign_resources() Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 03/13] PCI: Use guard(&pci_bus_sem) in pci_do_resource_release_and_resize() Ilpo Järvinen
` (10 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Richard Henderson, Matt Turner,
Magnus Lindholm, linux-alpha, linux-kernel
Cc: Ilpo Järvinen
To serialize bridge window sizing and resource assignment, PCI core
needs to hold locks across both phases. Alpha nautilus PCI code calls
pci_bus_size_bridges() and pci_bus_assign_resources() separately
because it needs to do special resource alignment and setup after the
window sizes have been calculated. At least the former would seem to
belong to some existing __weak pcibios_*() hook but the latter might
need yet another pcibios_*() hook just for this single use.
The nautilus code runs during init, so nothing is likely to race with
it. Converting it is mainly about consolidating the sizing and
assignment entry points of PCI core, which eventually allows removing
pci_bus_assign_resources().
Instead of trying to do a complex rework of the code, which is risky
without the ability to test on the hardware, simply convert
pci_bus_assign_resources() to pci_bus_size_and_assign_resources(). This
adds a small bit of extra work by performing the sizing step again, but
the calculations should yield the same sizes, so it seems safe.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
arch/alpha/kernel/sys_nautilus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 13b79960b4b9..23a74fd4a83f 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -263,7 +263,7 @@ nautilus_init_pci(void)
if ((IRONGATE0->dev_vendor >> 16) > 0x7006) /* Albacore? */
IRONGATE0->pci_mem = pci_mem;
- pci_bus_assign_resources(bus);
+ pci_bus_size_and_assign_resources(bus);
pci_bus_add_devices(bus);
}
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 03/13] PCI: Use guard(&pci_bus_sem) in pci_do_resource_release_and_resize()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 01/13] PCI: Add pci_bus_size_and_assign_resources() Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 02/13] alpha/PCI: Convert to pci_bus_size_and_assign_resources() Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 04/13] PCI: Hold pci_bus_sem across sizing and assignment entrypoints Ilpo Järvinen
` (9 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, linux-kernel
Cc: Ilpo Järvinen
pci_do_resource_release_and_resize() releases pci_bus_sem on its common
exit path. Use guard() instead to make adding more locking simpler.
The saved resource list is now freed while pci_bus_sem is held, which
is harmless as the list is local to the function.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/setup-bus.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 29ec9ba59d92..f95f217f94e6 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -2398,7 +2398,7 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
if (ret)
return ret;
- down_read(&pci_bus_sem);
+ guard(rwsem_read)(&pci_bus_sem);
pci_dev_for_each_resource(pdev, r, i) {
if (i >= PCI_BRIDGE_RESOURCES)
@@ -2435,7 +2435,6 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
}
out:
- up_read(&pci_bus_sem);
pci_dev_res_free_list(&saved);
return ret;
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 04/13] PCI: Hold pci_bus_sem across sizing and assignment entrypoints
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (2 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 03/13] PCI: Use guard(&pci_bus_sem) in pci_do_resource_release_and_resize() Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 05/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (8 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, linux-kernel
Cc: Ilpo Järvinen
Bridge window sizing and resource assignment algorithm walks
bus->devices and insert resources of the found devices into the resource
tree in many places. In addition, its internal datastructures hold
references to devices and resource it encountered while walking.
Most entrypoints to the algorithm do not hold pci_bus_sem, and
pci_assign_unassigned_bus_resources() drops it before the assignment
phase.
pci_rescan_remove_lock is not held by all callers and cannot be taken
by callers running under device_lock().
Protect the walks by holding pci_bus_sem for read across the entire
sizing and assignment operation right at the entrypoints.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/setup-bus.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index f95f217f94e6..5b2d870ca13d 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1457,6 +1457,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
void pci_bus_size_bridges(struct pci_bus *bus)
{
+ guard(rwsem_read)(&pci_bus_sem);
__pci_bus_size_bridges(bus, NULL);
}
EXPORT_SYMBOL(pci_bus_size_bridges);
@@ -1549,6 +1550,7 @@ void __pci_bus_assign_resources(const struct pci_bus *bus,
void pci_bus_assign_resources(const struct pci_bus *bus)
{
+ guard(rwsem_read)(&pci_bus_sem);
__pci_bus_assign_resources(bus, NULL, NULL);
}
EXPORT_SYMBOL(pci_bus_assign_resources);
@@ -1837,7 +1839,7 @@ static enum enable_type pci_realloc_detect(struct pci_bus *bus,
if (host->preserve_config)
return auto_disabled;
- pci_walk_bus(bus, iov_resources_unassigned, &unassigned);
+ pci_walk_bus_locked(bus, iov_resources_unassigned, &unassigned);
if (unassigned)
return auto_enabled;
@@ -2190,6 +2192,8 @@ void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus)
int pci_try_num = 1;
enum enable_type enable_local;
+ guard(rwsem_read)(&pci_bus_sem);
+
/* Don't realloc if asked to do so */
enable_local = pci_realloc_detect(bus, pci_realloc_enable);
if (pci_realloc_enabled(enable_local)) {
@@ -2258,14 +2262,15 @@ void pci_assign_unassigned_resources(void)
}
}
-void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
+static void pci_bridge_size_and_assign_resources(struct pci_dev *bridge)
{
struct pci_bus *parent = bridge->subordinate;
/* List of resources that want additional resources */
LIST_HEAD(add_list);
int tried_times = 0;
LIST_HEAD(fail_head);
- int ret;
+
+ guard(rwsem_read)(&pci_bus_sem);
while (1) {
__pci_bus_size_bridges(parent, &add_list);
@@ -2292,6 +2297,13 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
pci_prepare_next_assign_round(&fail_head, tried_times,
whole_subtree);
}
+}
+
+void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
+{
+ int ret;
+
+ pci_bridge_size_and_assign_resources(bridge);
ret = pci_reenable_device(bridge);
if (ret)
@@ -2424,7 +2436,7 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
goto restore;
} else {
/* No bridge window to adjust; let the core reassign the bus. */
- pci_bus_assign_resources(bus);
+ __pci_bus_assign_resources(bus, NULL, NULL);
list_for_each_entry(dev_res, &saved, list) {
if (!resource_assigned(dev_res->res)) {
@@ -2483,18 +2495,18 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
/* List of resources that want additional resources */
LIST_HEAD(add_list);
- down_read(&pci_bus_sem);
+ guard(rwsem_read)(&pci_bus_sem);
for_each_pci_bridge(dev, bus)
if (pci_has_subordinate(dev))
__pci_bus_size_bridges(dev->subordinate, &add_list);
- up_read(&pci_bus_sem);
__pci_bus_assign_resources(bus, &add_list, NULL);
}
EXPORT_SYMBOL_GPL(pci_assign_unassigned_bus_resources);
void pci_bus_size_and_assign_resources(struct pci_bus *bus)
{
- pci_bus_size_bridges(bus);
+ guard(rwsem_read)(&pci_bus_sem);
+ __pci_bus_size_bridges(bus, NULL);
__pci_bus_assign_resources(bus, NULL, NULL);
}
EXPORT_SYMBOL_GPL(pci_bus_size_and_assign_resources);
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 05/13] PCI: Serialize bridge window sizing and resource assignment
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (3 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 04/13] PCI: Hold pci_bus_sem across sizing and assignment entrypoints Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 06/13] i82875p_edac: Convert to pci_assign_unassigned_bus_resources() Ilpo Järvinen
` (7 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Rafael J. Wysocki, Len Brown,
Christian König, Alex Williamson, linux-acpi, linux-kernel
Cc: Ilpo Järvinen, stable
Bridge window sizing and resource assignment are started from multiple
entry points: rescan and hotplug under pci_rescan_remove_lock, and BAR
resize from sysfs or driver probe under device_lock() only. The entry
points hold pci_bus_sem only for read, so nothing prevents two sizing
and assignment passes from running concurrently on the same bridge
windows and BARs. E.g., a rescan may assign a BAR that a concurrent BAR
resize has released, or restore a resource the resize has already
assigned.
Looping BAR resize through sysfs against a rescan of the parent bus on a
system with a BMG GPU triggers the add_list sanity check. The rescan
sizes the Downstream Port's prefetchable window while the resize assigns
it, and the sizing values overwrite the assigned window. The resize then
programs these values into the Downstream Port, outside the root bus
resources and overlapping System RAM [mem 0x100000000-0x4075ffffff]. The
rescan skips assigning the window as it looks assigned, which leaves its
add_list entry unused:
pci_bus 0000:b7: root bus resource [mem 0xd6000000-0xddfbffff window]
pci_bus 0000:b7: root bus resource [mem 0x2e0000000000-0x2effffffffff window]
pcieport 0000:b9:01.0: bridge window [mem 0x800000000-0x1000ffffff 64bit pref] to [bus ba] add_size 4000000 add_align 800000000
pcieport 0000:b9:01.0: PCI bridge to [bus ba]
pcieport 0000:b9:01.0: bridge window [mem 0xdda00000-0xddbfffff]
pcieport 0000:b9:01.0: bridge window [mem 0x800000000-0x1000ffffff 64bit pref]
add_list && !list_empty(add_list)
WARNING: drivers/pci/setup-bus.c:1546 at pci_assign_unassigned_bus_resources+0x9e/0x130, CPU#58: srf8-resize-rac/2861
CPU: 58 UID: 0 PID: 2861 Comm: srf8-resize-rac Tainted: G S 7.4.0-rc1-g6628e7d4c6b2 #59 PREEMPT(full)
RIP: 0010:pci_assign_unassigned_bus_resources+0x9e/0x130
Call Trace:
pci_rescan_bus+0x20/0x40
dev_rescan_store+0x6e/0x90
Other trigger vectors are possible as well. Hotplug takes the same locks
as the sysfs rescan. BAR resize walks the bridge windows up to the Root
Port to make room for the resized BAR, and then sizes and assigns the
whole hierarchy below the Root Port. Thus, hotplug anywhere below the
same Root Port can race with the resize, e.g., when connecting a
Thunderbolt device. Instead of the sysfs resize, a driver can resize a
BAR during probe, e.g., after unbind and bind.
pci_rescan_remove_lock cannot be taken under device_lock() because the
device removal path takes them in the opposite order.
Add pci_res_setup_lock and hold it across sizing and assignment in all
entry points, including acpiphp which calls the internal sizing and
assignment functions directly. Assert the lock is held in the
functions that modify resources deeper in the call chains. In
pci_do_resource_release_and_resize(), take the lock before selecting the
bridge window and setting the BAR size as both depend on or change
resource state.
The race was also reproduced in QEMU, which found more symptoms.
Looping BAR resize through sysfs against a rescan of the parent bus on
a guest with 512M of RAM, using a synthetic host bridge with a Root Port
and an Endpoint with a Resizable BAR, triggers the following failures:
1) Both the rescan and the resize release the Root Port's prefetchable
window. Both find it assigned, but the rescan releases it first, and
the resize then dereferences the NULL parent in __release_resource():
pcieport 10000:00:00.0: bridge window [mem 0x940000000-0x97fffffff 64bit pref]: releasing
pcieport 10000:00:00.0: bridge window [mem size 0x40000000 64bit pref]: releasing
BUG: kernel NULL pointer dereference, address: 0000000000000038
Oops: Oops: 0000 [#1] SMP
CPU: 0 UID: 0 PID: 49 Comm: init Not tainted 7.4.0-rc1-00001-g4aa3acaaeb08 #1 PREEMPTLAZY
RIP: 0010:__release_resource+0x8/0x70
Call Trace:
release_resource+0x22/0x40
pci_release_resource+0x54/0x90
pci_do_resource_release_and_resize+0x1f3/0x3d0
__resource_resize_store+0xf0/0x180
2) The rescan restores a resource that has already been assigned:
WARNING: drivers/pci/setup-bus.c:136 at pci_dev_res_restore+0x32/0x90, CPU#0: init/1
CPU: 0 UID: 0 PID: 1 Comm: init Not tainted 7.4.0-rc1-dirty #6 PREEMPTLAZY
RIP: 0010:pci_dev_res_restore+0x32/0x90
Call Trace:
__assign_resources_sorted+0x2db/0x570
__pci_bus_assign_resources_one+0x57/0x190
__pci_bus_assign_resources_one+0x12d/0x190
__pci_bus_assign_resources+0xd/0x30
pci_assign_unassigned_bus_resources+0x6f/0x80
pci_rescan_bus+0x1a/0x30
dev_rescan_store+0x46/0x60
3) The rescan assigns the BAR while the resize is assigning it, failing
the resize:
pci 10000:01:00.0: BAR 0 [mem 0x900000000-0x90fffffff 64bit pref]: releasing
pcieport 10000:00:00.0: bridge window [mem 0x900000000-0x90fffffff 64bit pref]: releasing
pci 10000:01:00.0: BAR 0 [mem size 0x40000000 64bit pref]: can't assign; no space
pcieport 10000:00:00.0: bridge window [mem 0x900000000-0x93fffffff 64bit pref]: assigned
pci 10000:01:00.0: BAR 0 [mem size 0x40000000 64bit pref]: failed to assign
pci 10000:01:00.0: BAR 0 [mem 0x900000000-0x93fffffff 64bit pref]: releasing
pci 10000:01:00.0: BAR 0 [mem 0x900000000-0x93fffffff 64bit pref]: assigned
pci 10000:01:00.0: BAR 0 [mem size 0x40000000 64bit pref]: resource restored
pci 10000:01:00.0: BAR 0 [mem 0x900000000-0x90fffffff 64bit pref]: old value restored
pci 10000:01:00.0: Failed to resize BAR 0: -28
4) While one pass is sorting a released bridge window for assignment,
the other pass assigns it, which clears IORESOURCE_STARTALIGN. The
window then has zero alignment:
pci 10000:01:00.0: BAR 0 [mem 0x900000000-0x93fffffff 64bit pref]: releasing
pcieport 10000:00:00.0: bridge window [mem 0x900000000-0x93fffffff 64bit pref]: releasing
pcieport 10000:00:00.0: bridge window [mem 0x900000000-0x90fffffff 64bit pref]: assigned
pcieport 10000:00:00.0: bridge window [mem 0x900000000-0x90fffffff 64bit pref]: alignment must not be zero
pci 10000:01:00.0: BAR 0 [mem 0x900000000-0x90fffffff 64bit pref]: assigned
5) BAR 0 loses its flags and the Root Port's prefetchable window gets
programmed over RAM, after which every BAR resize fails with -EINVAL:
pci 10000:01:00.0: BAR 0 [mem size 0x10000000 64bit pref]: can't assign; no space
resource: remaining [mem 0x000000001ffdf000-0x000000001fffffff] available
resource: avoiding allocation from e820 entry [mem 0x1ffdf000-0x1fffffff]
pci 10000:01:00.0: BAR 0 [mem size 0x10000000 64bit pref]: failed to assign
pci 10000:01:00.0: BAR 0 [mem size 0x10000000 64bit pref]: can't assign; no space
pci 10000:01:00.0: BAR 0 [mem size 0x10000000 64bit pref]: resetting resource
pci 10000:01:00.0: BAR 0 [??? 0x00000000 flags 0x0]: failed to assign
pci 10000:01:00.0: BAR 0 [??? 0x00000000 flags 0x0]: resetting resource
pcieport 10000:00:00.0: PCI bridge to [bus 01]
pcieport 10000:00:00.0: bridge window [mem 0x20000000-0x200fffff]
pcieport 10000:00:00.0: bridge window [mem 0x10000000-0x1fffffff 64bit pref]
pci 10000:01:00.0: Failed to resize BAR 0: -22
Fixes: 8bb705e3e79d ("PCI: Add pci_resize_resource() for resizing BARs")
Fixes: 91fa127794ac ("PCI: Expose PCIe Resizable BAR support via sysfs")
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: stable@vger.kernel.org
---
Bjorn,
It's up to you if you want to keep all those qemu reproduced cases in the
changelog. You usually seem to prefer the log messages for easier googling
in case somebody happens to hit the issue so I added them all.
I couldn't get the rest to trigger on a real host but that could be due to
serial output that was too slow to keep up with the test loops which might
have affected timing.
drivers/pci/hotplug/acpiphp_glue.c | 1 +
drivers/pci/pci.h | 1 +
drivers/pci/setup-bus.c | 40 ++++++++++++++++++++++++++++++
drivers/pci/setup-cardbus.c | 3 +++
4 files changed, 45 insertions(+)
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 632344f34cae..d3987be044e3 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -502,6 +502,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
acpiphp_rescan_slot(slot);
max = acpiphp_max_busnr(bus);
+ guard(mutex)(&pci_res_setup_lock);
for (pass = 0; pass < 2; pass++) {
for_each_pci_bridge(dev, bus) {
if (PCI_SLOT(dev->devfn) != slot->device)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 77efa4c5c960..660a83b0045a 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -124,6 +124,7 @@ unsigned char pcie_get_link_speed(unsigned int speed);
extern bool pci_early_dump;
extern struct mutex pci_rescan_remove_lock;
+extern struct mutex pci_res_setup_lock;
bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
bool pcie_cap_has_lnkctl2(const struct pci_dev *dev);
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 5b2d870ca13d..314c649c648f 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -26,6 +26,7 @@
#include <linux/ioport.h>
#include <linux/cache.h>
#include <linux/limits.h>
+#include <linux/lockdep.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/acpi.h>
@@ -38,6 +39,17 @@
unsigned int pci_flags;
EXPORT_SYMBOL_GPL(pci_flags);
+/*
+ * Serializes bridge window sizing, resource fitting, and assignment.
+ * pci_rescan_remove_lock cannot be used for this because BAR resize and
+ * some drivers run these operations under device_lock() during probe.
+ *
+ * Context:
+ * - Nests inside pci_rescan_remove_lock and device_lock().
+ * - Nests outside pci_bus_sem.
+ */
+DEFINE_MUTEX(pci_res_setup_lock);
+
struct pci_dev_resource {
struct list_head list;
struct resource *res;
@@ -133,6 +145,8 @@ static void pci_dev_res_restore(struct pci_dev_resource *dev_res)
int idx = pci_resource_num(dev, res);
const char *res_name = pci_resource_name(dev, idx);
+ lockdep_assert_held(&pci_res_setup_lock);
+
if (WARN_ON_ONCE(resource_assigned(res)))
return;
@@ -611,6 +625,8 @@ static void __assign_resources_sorted(struct list_head *head,
unsigned long fail_type;
resource_size_t align;
+ lockdep_assert_held(&pci_res_setup_lock);
+
if (!realloc_head)
realloc_head = &dummy_head;
@@ -893,6 +909,8 @@ static void __pci_setup_bridge(struct pci_bus *bus, unsigned long type)
{
struct pci_dev *bridge = bus->self;
+ lockdep_assert_held(&pci_res_setup_lock);
+
pci_info(bridge, "PCI bridge to %pR\n", &bus->busn_res);
if (type & IORESOURCE_IO)
@@ -973,6 +991,8 @@ static void pci_bridge_check_ranges(struct pci_bus *bus)
struct pci_dev *bridge = bus->self;
struct resource *b_res;
+ lockdep_assert_held(&pci_res_setup_lock);
+
b_res = &bridge->resource[PCI_BRIDGE_MEM_WINDOW];
b_res->flags |= IORESOURCE_MEM;
@@ -1077,6 +1097,8 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t add_size,
resource_size_t children_add_size = 0;
resource_size_t min_align, align;
+ lockdep_assert_held(&pci_res_setup_lock);
+
if (!b_res)
return;
@@ -1286,6 +1308,8 @@ static void pbus_size_mem(struct pci_bus *bus, struct resource *b_res,
resource_size_t children_add_size = 0;
resource_size_t add_align = 0;
+ lockdep_assert_held(&pci_res_setup_lock);
+
if (!b_res)
return;
@@ -1457,6 +1481,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
void pci_bus_size_bridges(struct pci_bus *bus)
{
+ guard(mutex)(&pci_res_setup_lock);
guard(rwsem_read)(&pci_bus_sem);
__pci_bus_size_bridges(bus, NULL);
}
@@ -1486,6 +1511,8 @@ static void pdev_assign_fixed_resources(struct pci_dev *dev)
{
struct resource *r;
+ lockdep_assert_held(&pci_res_setup_lock);
+
pci_dev_for_each_resource(dev, r) {
struct pci_bus *b;
@@ -1550,6 +1577,7 @@ void __pci_bus_assign_resources(const struct pci_bus *bus,
void pci_bus_assign_resources(const struct pci_bus *bus)
{
+ guard(mutex)(&pci_res_setup_lock);
guard(rwsem_read)(&pci_bus_sem);
__pci_bus_assign_resources(bus, NULL, NULL);
}
@@ -1663,6 +1691,8 @@ static void pci_bridge_release_resources(struct pci_bus *bus,
struct pci_dev *dev = bus->self;
int idx, ret;
+ lockdep_assert_held(&pci_res_setup_lock);
+
if (!resource_assigned(b_win))
return;
@@ -1860,6 +1890,8 @@ static void adjust_bridge_window(struct pci_dev *bridge, struct resource *res,
resource_size_t add_size, size = resource_size(res);
struct pci_dev_resource *dev_res;
+ lockdep_assert_held(&pci_res_setup_lock);
+
if (resource_assigned(res))
return;
@@ -2192,6 +2224,7 @@ void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus)
int pci_try_num = 1;
enum enable_type enable_local;
+ guard(mutex)(&pci_res_setup_lock);
guard(rwsem_read)(&pci_bus_sem);
/* Don't realloc if asked to do so */
@@ -2270,6 +2303,7 @@ static void pci_bridge_size_and_assign_resources(struct pci_dev *bridge)
int tried_times = 0;
LIST_HEAD(fail_head);
+ guard(mutex)(&pci_res_setup_lock);
guard(rwsem_read)(&pci_bus_sem);
while (1) {
@@ -2328,6 +2362,8 @@ static int pbus_reassign_bridge_resources(struct pci_bus *bus, struct resource *
unsigned int i;
int ret = 0;
+ lockdep_assert_held(&pci_res_setup_lock);
+
while (!pci_is_root_bus(bus)) {
bridge = bus->self;
res = pbus_select_window(bus, res);
@@ -2398,6 +2434,8 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
unsigned int i;
int old, ret;
+ guard(mutex)(&pci_res_setup_lock);
+
b_win = pbus_select_window(bus, res);
if (!b_win)
return -EINVAL;
@@ -2495,6 +2533,7 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
/* List of resources that want additional resources */
LIST_HEAD(add_list);
+ guard(mutex)(&pci_res_setup_lock);
guard(rwsem_read)(&pci_bus_sem);
for_each_pci_bridge(dev, bus)
if (pci_has_subordinate(dev))
@@ -2505,6 +2544,7 @@ EXPORT_SYMBOL_GPL(pci_assign_unassigned_bus_resources);
void pci_bus_size_and_assign_resources(struct pci_bus *bus)
{
+ guard(mutex)(&pci_res_setup_lock);
guard(rwsem_read)(&pci_bus_sem);
__pci_bus_size_bridges(bus, NULL);
__pci_bus_assign_resources(bus, NULL, NULL);
diff --git a/drivers/pci/setup-cardbus.c b/drivers/pci/setup-cardbus.c
index dcb8e2b3f73b..6a473a1694b9 100644
--- a/drivers/pci/setup-cardbus.c
+++ b/drivers/pci/setup-cardbus.c
@@ -6,6 +6,7 @@
#include <linux/bitfield.h>
#include <linux/errno.h>
#include <linux/ioport.h>
+#include <linux/lockdep.h>
#include <linux/pci.h>
#include <linux/sizes.h>
#include <linux/sprintf.h>
@@ -39,6 +40,8 @@ int pci_bus_size_cardbus_bridge(struct pci_bus *bus,
resource_size_t b_res_3_size = pci_cardbus_mem_size * 2;
u16 ctrl;
+ lockdep_assert_held(&pci_res_setup_lock);
+
b_res = &bridge->resource[PCI_CB_BRIDGE_IO_0_WINDOW];
if (resource_assigned(b_res))
goto handle_b_res_1;
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 06/13] i82875p_edac: Convert to pci_assign_unassigned_bus_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (4 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 05/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:40 ` Borislav Petkov
2026-11-16 15:23 ` [PATCH 07/13] platform/x86: asus-wmi: " Ilpo Järvinen
` (6 subsequent siblings)
12 siblings, 1 reply; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Borislav Petkov, Tony Luck,
linux-edac, linux-kernel
Cc: Ilpo Järvinen
The i82875p_edac driver scans single device and then attempts to assign
its resource using pci_bus_assign_resources(). That function makes
bridge window sizing disjoint from the assignment phase and is going to
be removed.
Convert pci_bus_assign_resources() to
pci_assign_unassigned_bus_resources() which is likely no-op in this case
as it looks like bridges are not involved here.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/edac/i82875p_edac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
index 869de8e372b3..59a92a209dea 100644
--- a/drivers/edac/i82875p_edac.c
+++ b/drivers/edac/i82875p_edac.c
@@ -290,7 +290,7 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
if (dev == NULL)
return 1;
- pci_bus_assign_resources(dev->bus);
+ pci_assign_unassigned_bus_resources(dev->bus);
pci_bus_add_device(dev);
}
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 07/13] platform/x86: asus-wmi: Convert to pci_assign_unassigned_bus_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (5 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 06/13] i82875p_edac: Convert to pci_assign_unassigned_bus_resources() Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 08/13] platform/x86: eeepc-laptop: " Ilpo Järvinen
` (5 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Corentin Chary, Luke D. Jones,
Denis Benato, Hans de Goede, Ilpo Järvinen,
platform-driver-x86, linux-kernel
The asus-wmi driver scans single device and then attempts to assign its
resource using pci_bus_assign_resources(). That function makes bridge
window sizing disjoint from the assignment phase and is going to be
removed.
Convert pci_bus_assign_resources() to
pci_assign_unassigned_bus_resources() which is likely no-op in this case
as it looks like bridges are not involved here.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/platform/x86/asus-wmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index b33ebdb21aa2..9eb783eb53c6 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -2325,7 +2325,7 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus)
}
dev = pci_scan_single_device(bus, 0);
if (dev) {
- pci_bus_assign_resources(bus);
+ pci_assign_unassigned_bus_resources(bus);
pci_bus_add_device(dev);
}
} else {
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 08/13] platform/x86: eeepc-laptop: Convert to pci_assign_unassigned_bus_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (6 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 07/13] platform/x86: asus-wmi: " Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 09/13] parisc/PCI: " Ilpo Järvinen
` (4 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Corentin Chary, Luke D. Jones,
Denis Benato, Hans de Goede, Ilpo Järvinen,
platform-driver-x86, linux-kernel
The eeepc-laptop driver scans single device and then attempts to assign
its resource using pci_bus_assign_resources(). That function makes
bridge window sizing disjoint from the assignment phase and is going to
be removed.
Convert pci_bus_assign_resources() to
pci_assign_unassigned_bus_resources() which is likely no-op in this case
as it looks like bridges are not involved here.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/platform/x86/eeepc-laptop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 8a640c25830a..7394221cbad1 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -609,7 +609,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
}
dev = pci_scan_single_device(bus, 0);
if (dev) {
- pci_bus_assign_resources(bus);
+ pci_assign_unassigned_bus_resources(bus);
pci_bus_add_device(dev);
}
} else {
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 09/13] parisc/PCI: Convert to pci_assign_unassigned_bus_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (7 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 08/13] platform/x86: eeepc-laptop: " Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 10/13] PCI: hotplug: octep: " Ilpo Järvinen
` (3 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, James E.J. Bottomley, Helge Deller,
linux-parisc, linux-kernel
Cc: Ilpo Järvinen
The Dino PCI bus driver performs assignment of resource using
pci_bus_assign_resources(). That function makes bridge window sizing
disjoint from the assignment phase and is going to be removed.
Convert pci_bus_assign_resources() to
pci_assign_unassigned_bus_resources(). If no other bridges are involved,
the extra sizing should be no-op.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/parisc/dino.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 286f4f75dba7..da75ba15faf4 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -1050,7 +1050,7 @@ static int __init dino_probe(struct parisc_device *dev)
* if it isn't, this global bus number count will fail
*/
dino_current_bus = max + 1;
- pci_bus_assign_resources(bus);
+ pci_assign_unassigned_bus_resources(bus);
pci_bus_add_devices(bus);
return 0;
}
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 10/13] PCI: hotplug: octep: Convert to pci_assign_unassigned_bus_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (8 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 09/13] parisc/PCI: " Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 11/13] PCI: ftpci100: " Ilpo Järvinen
` (2 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Shijith Thotton, Vamsi Attunuru,
linux-kernel
Cc: Ilpo Järvinen
The Octeon hotplug driver scans single device and then attempts to
assign its resource using pci_bus_assign_resources(). That function
makes bridge window sizing disjoint from the assignment phase and is
going to be removed.
Convert pci_bus_assign_resources() to
pci_assign_unassigned_bus_resources(). If no other bridges are involved,
the extra sizing should be no-op.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/hotplug/octep_hp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/hotplug/octep_hp.c b/drivers/pci/hotplug/octep_hp.c
index a0a7f9ccb8fa..e793fc3012fd 100644
--- a/drivers/pci/hotplug/octep_hp.c
+++ b/drivers/pci/hotplug/octep_hp.c
@@ -79,7 +79,7 @@ static void octep_hp_enable_pdev(struct octep_hp_controller *hp_ctrl,
/* Scan the device and add it to the bus */
hp_slot->hp_pdev = pci_scan_single_device(hp_ctrl->pdev->bus,
hp_slot->hp_devfn);
- pci_bus_assign_resources(hp_ctrl->pdev->bus);
+ pci_assign_unassigned_bus_resources(hp_ctrl->pdev->bus);
pci_bus_add_device(hp_slot->hp_pdev);
dev_dbg(&hp_slot->hp_pdev->dev, "Enabled slot %s\n",
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 11/13] PCI: ftpci100: Convert to pci_assign_unassigned_bus_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (9 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 10/13] PCI: hotplug: octep: " Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 12/13] PCI: hv: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 13/13] PCI: Remove pci_bus_assign_resources() Ilpo Järvinen
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, linux-kernel
Cc: Ilpo Järvinen
The ftpci100 driver attempts to assign bus resource using
pci_bus_assign_resources(). That function makes bridge window sizing
disjoint from the assignment phase and is going to be removed.
Convert pci_bus_assign_resources() to
pci_assign_unassigned_bus_resources(). If no other bridges are involved,
the extra sizing should be no-op.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/controller/pci-ftpci100.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c
index 28e43831c0f1..96b3deb70f57 100644
--- a/drivers/pci/controller/pci-ftpci100.c
+++ b/drivers/pci/controller/pci-ftpci100.c
@@ -509,7 +509,7 @@ static int faraday_pci_probe(struct platform_device *pdev)
p->bus->max_bus_speed = max_bus_speed;
p->bus->cur_bus_speed = cur_bus_speed;
- pci_bus_assign_resources(p->bus);
+ pci_assign_unassigned_bus_resources(p->bus);
pci_bus_add_devices(p->bus);
return 0;
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 12/13] PCI: hv: Convert to pci_assign_unassigned_bus_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (10 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 11/13] PCI: ftpci100: " Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 13/13] PCI: Remove pci_bus_assign_resources() Ilpo Järvinen
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, Haiyang Zhang, Wei Liu, Dexuan Cui,
Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, linux-hyperv, linux-kernel
Cc: Ilpo Järvinen
The pci-hyperv driver scans the bus and assigns resources using
pci_bus_assign_resources(). That function makes bridge window sizing
disjoint from the assignment phase and is going to be removed.
Convert pci_bus_assign_resources() to
pci_assign_unassigned_bus_resources(). If no other bridges are involved,
the extra sizing should be no-op.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/controller/pci-hyperv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 824cf27e85e6..8eff3e9b325f 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -2549,7 +2549,7 @@ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus)
pci_lock_rescan_remove();
hv_pci_assign_numa_node(hbus);
- pci_bus_assign_resources(bridge->bus);
+ pci_assign_unassigned_bus_resources(bridge->bus);
hv_pci_assign_slots(hbus);
pci_bus_add_devices(bridge->bus);
pci_unlock_rescan_remove();
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 13/13] PCI: Remove pci_bus_assign_resources()
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
` (11 preceding siblings ...)
2026-11-16 15:23 ` [PATCH 12/13] PCI: hv: " Ilpo Järvinen
@ 2026-11-16 15:23 ` Ilpo Järvinen
12 siblings, 0 replies; 15+ messages in thread
From: Ilpo Järvinen @ 2026-11-16 15:23 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
Krzysztof Wilczyński, linux-kernel
Cc: Ilpo Järvinen
The pci_bus_assign_resources() interface is problematic because it
makes bridge window sizing disjoint from assignment phase.
pci_bus_assign_resources() is now unused so remove it.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/setup-bus.c | 8 --------
include/linux/pci.h | 1 -
2 files changed, 9 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 314c649c648f..547d0f920360 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1575,14 +1575,6 @@ void __pci_bus_assign_resources(const struct pci_bus *bus,
pci_dev_res_free_list(add_list);
}
-void pci_bus_assign_resources(const struct pci_bus *bus)
-{
- guard(mutex)(&pci_res_setup_lock);
- guard(rwsem_read)(&pci_bus_sem);
- __pci_bus_assign_resources(bus, NULL, NULL);
-}
-EXPORT_SYMBOL(pci_bus_assign_resources);
-
static void pci_claim_device_resources(struct pci_dev *dev)
{
int i;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d89aeb7c9ff7..7d71ad6d89af 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1566,7 +1566,6 @@ ssize_t pci_write_vpd_any(struct pci_dev *dev, loff_t pos, size_t count, const v
/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);
-void pci_bus_assign_resources(const struct pci_bus *bus);
void pci_bus_claim_resources(struct pci_bus *bus);
void pci_bus_size_bridges(struct pci_bus *bus);
void pci_bus_size_and_assign_resources(struct pci_bus *bus);
--
2.47.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 06/13] i82875p_edac: Convert to pci_assign_unassigned_bus_resources()
2026-11-16 15:23 ` [PATCH 06/13] i82875p_edac: Convert to pci_assign_unassigned_bus_resources() Ilpo Järvinen
@ 2026-11-16 15:40 ` Borislav Petkov
0 siblings, 0 replies; 15+ messages in thread
From: Borislav Petkov @ 2026-11-16 15:40 UTC (permalink / raw)
To: Tony Luck
Cc: Ilpo Järvinen, linux-pci, Bjorn Helgaas, Lorenzo Pieralisi,
Rob Herring, Krzysztof Wilczyński, linux-edac, linux-kernel
In addition to this, Tony, should we orphan this one too?
It is a P4-something-chipset...
On Mon, Nov 16, 2026 at 05:23:51PM +0200, Ilpo Järvinen wrote:
> The i82875p_edac driver scans single device and then attempts to assign
> its resource using pci_bus_assign_resources(). That function makes
> bridge window sizing disjoint from the assignment phase and is going to
> be removed.
>
> Convert pci_bus_assign_resources() to
> pci_assign_unassigned_bus_resources() which is likely no-op in this case
> as it looks like bridges are not involved here.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
> drivers/edac/i82875p_edac.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
> index 869de8e372b3..59a92a209dea 100644
> --- a/drivers/edac/i82875p_edac.c
> +++ b/drivers/edac/i82875p_edac.c
> @@ -290,7 +290,7 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
> if (dev == NULL)
> return 1;
>
> - pci_bus_assign_resources(dev->bus);
> + pci_assign_unassigned_bus_resources(dev->bus);
> pci_bus_add_device(dev);
> }
>
> --
> 2.47.3
>
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-11-16 15:40 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 01/13] PCI: Add pci_bus_size_and_assign_resources() Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 02/13] alpha/PCI: Convert to pci_bus_size_and_assign_resources() Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 03/13] PCI: Use guard(&pci_bus_sem) in pci_do_resource_release_and_resize() Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 04/13] PCI: Hold pci_bus_sem across sizing and assignment entrypoints Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 05/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 06/13] i82875p_edac: Convert to pci_assign_unassigned_bus_resources() Ilpo Järvinen
2026-11-16 15:40 ` Borislav Petkov
2026-11-16 15:23 ` [PATCH 07/13] platform/x86: asus-wmi: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 08/13] platform/x86: eeepc-laptop: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 09/13] parisc/PCI: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 10/13] PCI: hotplug: octep: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 11/13] PCI: ftpci100: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 12/13] PCI: hv: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 13/13] PCI: Remove pci_bus_assign_resources() Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®