Skip to content

PCI: Allow non-prefetchable BARs in prefetchable windows

Ard Biesheuvel linux-pci lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 7 repliesIn review
  2. v22 patches 1 replySuperseded
  3. v1 RFC1 patch 7 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2PCI: Add __pci_bus_alloc_resource() to allocate with explicit flagsdrivers/pci/bus.c drivers/pci/pci.h+54 -220 replies
2/2PCI: Allow 64-bit non-prefetchable BARs in prefetchable windowsdrivers/pci/pci.c drivers/pci/pci.h drivers/pci/probe.c +3 more+115 -186 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

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

From: Ard Biesheuvel <[email protected]>

(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)

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(-)
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog