From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Michał Winiarski" <michal.winiarski@intel.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
"Anthony Pighin" <anthony.pighin@nokia.com>
Cc: linux-kernel@vger.kernel.org,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH v2 00/16] PCI: Resource release fixes and improvements
Date: Sat, 5 Dec 2026 02:39:35 +0200 [thread overview]
Message-ID: <20261205003957.3304-1-ilpo.jarvinen@linux.intel.com> (raw)
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@linux.intel.com/
... and another (unsubmitted) series on top of that to bring
pci_assign_resource() and pci_bus_alloc_resource() under the same lock.
v2:
- Add a patch to prevent destruction of IORESOURCE_PCI_FIXED resources
- Do not restore old BAR size if it wasn't changed
- In release_leaf_resource() pass release_child=false instead of true
because it's more logical (no functional impact)
- Tweaks to changelog text + one more Fixes tag
Ilpo Järvinen (16):
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, kunit: Add test for releasing a resource not in the tree
resource: Add release_leaf_resource()
resource, kunit: Add 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: Keep the range of fixed resources when releasing them
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 | 73 +++++++++++++--------
drivers/pci/setup-res.c | 138 ++++++++++++++++++++++++++++++++++++++--
include/linux/ioport.h | 23 +++++++
kernel/resource.c | 75 ++++++++++++++++------
kernel/resource_kunit.c | 44 +++++++++++++
7 files changed, 357 insertions(+), 52 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.47.3
next reply other threads:[~2026-12-05 0:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 0:39 Ilpo Järvinen [this message]
2026-12-05 0:39 ` [PATCH v2 01/16] PCI: Release all resources before restoring them in BAR resize rollback Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 02/16] PCI: Set new BAR Size only after releasing the BARs for BAR resize Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 03/16] PCI: Abort BAR resize only if saving the resized BAR fails Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 04/16] PCI: Consistently use Header Type to detect bridge headers Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 05/16] resource: Check that the resource is in the tree when releasing it Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 06/16] resource, kunit: Add test for releasing a resource not in the tree Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 07/16] resource: Add release_leaf_resource() Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 08/16] resource, kunit: Add test for release_leaf_resource() Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 09/16] PCI: Do not release resources with children in pci_release_resource() Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 10/16] resource: Rename next_resource() and for_each_resource() Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 11/16] resource: Make resource_lock and resource tree traversal available Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 12/16] resource: Add release_resource_locked() Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 13/16] PCI: Split pci_resource_post_release() out of pci_release_resource() Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 14/16] PCI: Add iterators for devices and resources in bus windows Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 15/16] PCI: Keep the range of fixed resources when releasing them Ilpo Järvinen
2026-12-05 0:39 ` [PATCH v2 16/16] PCI: Release only PCI resources when releasing a resource tree Ilpo Järvinen
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=20261205003957.3304-1-ilpo.jarvinen@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=anthony.pighin@nokia.com \
--cc=bhelgaas@google.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=matthew.brost@intel.com \
--cc=michal.winiarski@intel.com \
--cc=robh@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tursulin@ursulin.net \
--cc=ville.syrjala@linux.intel.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
all inboxes | Powered by JetHome®