[PATCH v2 0/2] PCI: Allow non-prefetchable BARs in prefetchable windows

From: Ard Biesheuvel

Date: Fri Sep 25 2026 - 13:07:01 EST


From: Ard Biesheuvel <ardb@xxxxxxxxxx>

The non-prefetchable window of a PCI-to-PCI bridge can only decode
32-bit addresses, and so even 64-bit non-prefetchable BARs of devices
below a bridge compete for the scarce MMIO space below 4 GB.

The PCIe spec notes that marking such a BAR prefetchable still permits
correct operation as long as the entire path from the host to the device
is PCIe (PCIe r7.0, sec 7.5.1.2.1). The same applies when the OS places
a non-prefetchable BAR in a prefetchable bridge window, and so this
series permits that unless there is a bridge on the path to the root bus
that is not a PCIe Root Port or Switch Port, allowing 64-bit
non-prefetchable BARs to be placed above 4 GB.

How a host bridge treats the windows that firmware describes as
prefetchable is platform specific, however, and so this is only done if
the host bridge has no prefetchable windows at all, in which case all
prefetchable bridge windows are carved out of non-prefetchable host
bridge windows. This also means that devices on a root bus are never
affected.

Patch #1 is a preparatory refactor of pci_bus_alloc_resource() with no
functional change, and patch #2 implements the relaxation.

The series is based on pci/for-linus, as patch #2 touches the same
lines in pci_do_resource_release_and_resize() as commit d58384c22739
("PCI: Fix BAR resize for devices on a root bus") queued there for
v7.3.

Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@xxxxxxxxxxxxxxx>
Cc: Lorenzo Pieralisi <lpieralisi@xxxxxxxxxx>
Link: https://lore.kernel.org/linux-pci/20260910143440.3865663-2-ardb+git@xxxxxxxxxx/

Ard Biesheuvel (2):
PCI: Add __pci_bus_alloc_resource() to allocate with explicit flags
PCI: Allow non-prefetchable BARs in prefetchable windows

drivers/pci/bus.c | 70 ++++++++++++++++--------
drivers/pci/pci.c | 115 +++++++++++++++++++++++++++++++++++++++-
drivers/pci/pci.h | 11 +++-
drivers/pci/setup-bus.c | 58 +++++++++++++-------
drivers/pci/setup-res.c | 29 ++++++----
5 files changed, 228 insertions(+), 55 deletions(-)


base-commit: 9a8daf68b9b30c536b0991d9f098ed0db80abc1c
--
2.56.0.rc1.315.gc6ed9934b7-goog