[PATCH 00/15] PCI: Resource release fixes and improvements
From: Ilpo Järvinen
Date: Tue Dec 01 2026 - 10:59:05 EST
Hi all,
Releasing a PCI resource does not care what resides underneath it. A
released bridge window takes its children along, including regions
requested by drivers, which can corrupt the resource tree once the
window and its resources are assigned elsewhere.
This series makes pci_release_resource() refuse resources with children
and adds pci_release_resource_tree() that releases only PCI resources.
The check and the release are done under resource_lock, which the
resource core now exposes. Exposing resource_lock is probably the most
debatable part; an alternative to this would be to pass check and
release callbacks to a new resource core function.
The first 5 patches are related fixes.
The most immediate effect of these changes is for driver initiated BAR
resize which could fail if there are any extra resources underneath
the one to be resized. My impression is that this is not the case with
any of the GPU drivers using BAR resize but it would be good still that
GPU people take a look and test as needed.
The series is a prerequisite for sizing already assigned bridge windows.
The resource fitting and assignment algorithm self-race conditions due
to insufficient locking are out-of-scope. They are fixed by this series:
https://lore.kernel.org/linux-pci/20261125230925.2441-1-ilpo.jarvinen@xxxxxxxxxxxxxxx/
... and another (unsubmitted) series on top of that to bring
pci_assign_resource() and pci_bus_alloc_resource() under the same lock.
Ilpo Järvinen (15):
PCI: Release all resources before restoring them in BAR resize
rollback
PCI: Set new BAR Size only after releasing the BARs for BAR resize
PCI: Abort BAR resize only if saving the resized BAR fails
PCI: Consistently use Header Type to detect bridge headers
resource: Check that the resource is in the tree when releasing it
resource: Add KUnit test for releasing a resource not in the tree
resource: Add release_leaf_resource()
resource: Add KUnit test for release_leaf_resource()
PCI: Do not release resources with children in pci_release_resource()
resource: Rename next_resource() and for_each_resource()
resource: Make resource_lock and resource tree traversal available
resource: Add release_resource_locked()
PCI: Split pci_resource_post_release() out of pci_release_resource()
PCI: Add iterators for devices and resources in bus windows
PCI: Release only PCI resources when releasing a resource tree
drivers/pci/bus.c | 33 +++++++++++
drivers/pci/pci.h | 23 ++++++++
drivers/pci/setup-bus.c | 66 ++++++++++++++-------
drivers/pci/setup-res.c | 124 +++++++++++++++++++++++++++++++++++++---
include/linux/ioport.h | 23 ++++++++
kernel/resource.c | 75 +++++++++++++++++-------
kernel/resource_kunit.c | 44 ++++++++++++++
7 files changed, 339 insertions(+), 49 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.47.3