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

From: Ard Biesheuvel

Date: Wed Sep 30 2026 - 06:32:58 EST


From: Ard Biesheuvel <ardb@xxxxxxxxxx>

(v2 never made it to linux-pci@ - please disregard it if you did get it)

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.

So add a new bus flag PCI_BUS_FLAGS_NO_NP_BARS_IN_P_WINDOWS, and wire it
up so that it is only set on buses where this relaxed placement is not
permitted. Then, use the flag to to decide whether to treat 64-bit NP
BARs as prefetchable only for the purpose of resource allocation (but
not for mapping the MMIO region or other reporting its properties)

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

(based on v7.3-rc4)

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 64-bit non-prefetchable BARs in prefetchable windows

drivers/pci/bus.c | 70 ++++++++++++++------
drivers/pci/pci.c | 43 +++++++++++-
drivers/pci/pci.h | 7 ++
drivers/pci/probe.c | 35 ++++++++++
drivers/pci/setup-bus.c | 23 +++++--
drivers/pci/setup-res.c | 30 ++++++---
include/linux/pci.h | 1 +
7 files changed, 169 insertions(+), 40 deletions(-)

--
2.56.0.rc1.315.gc6ed9934b7-goog