Linux PCI subsystem development
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] PCI: Reserve resources for a delayed hotplug subtree
@ 2026-10-02 19:31 Maciej Grochowski
  2026-10-02 19:31 ` [RFC PATCH 1/2] PCI: Add pci=hpreserve= to reserve memory windows for a hotplug bridge Maciej Grochowski
  2026-10-02 19:31 ` [RFC PATCH 2/2] PCI: Allow pci=hpreserve= to reserve bus numbers " Maciej Grochowski
  0 siblings, 2 replies; 7+ messages in thread
From: Maciej Grochowski @ 2026-10-02 19:31 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci; +Cc: Ilpo Järvinen, Jonathan Corbet

On a two-level Microchip PM50052 (Switchtec PFX) hierarchy, a hard reset
of the top switch removes both switches from the PCI tree.  The top
switch returns before the nested switch, so pciehp enumerates its five
hotplug downstream ports while they are empty.  The port leading to the
nested switch receives three bus numbers and a roughly 206 MiB
prefetchable window.  When the nested switch appears, it needs eleven
bus numbers and a 1 GiB-aligned 1032 MiB window for its NTB BARs.  The
missing resources leave part of the hierarchy unusable and the nested
switchtec function cannot bind.

Switches from other vendors can encounter the same resource shortfall
when a child appears after its parent hotplug port is numbered and
sized, if the child's requirements exceed that allocation.

These patches explore pci=hpreserve= to specify minimum resources for a
selected hotplug bridge while its child is absent.  Patch 1 reserves
memory window size and alignment; patch 2 reserves bus numbers before
the remaining bus numbers are divided among sibling hotplug ports.  The
path form tolerates downstream bus renumbering.  With no parameter, the
existing allocation policy is unchanged.

On a v7.3-rc2 based kernel with both patches and
  pci=hpreserve=bus=11:mmiopref=1032M:mmioprefalign=1G@0000:80:01.1/00.0/03.0
we tested a cold boot, two top-switch hard resets, and one nested-switch
hard reset on the two-level system.  After each reset, the nested port
retained its eleven bus numbers and aligned 1032 MiB window, the 1 GiB
NTB BAR was assigned, and both switchtec devices responded to MRPC.

We are posting this RFC now because the failure affects our PCIe hotplug
infrastructure.  The two-level pciehp test shows that a per-bridge
reservation can preserve one delayed subtree.  With three or more
switch layers that return at different times, this implementation
appears to require a reservation at each port sized while empty, and
each ancestor must retain enough bus numbers and aligned memory space
for the eventual subtree.  We have not tested that case.

Consider a larger layout with three top-level switches, each feeding
six second-level switches with eight NTB functions apiece.  If their
child links return late, the current syntax could need 18 full
path-specific entries, plus entries for delayed ancestors.  The NTB
BARs affect the resources required per bridge, not the entry count.
Matching by device ID could shorten a homogeneous case, but risks
reserving resources on same-ID ports without delayed children.

One possible extension, not implemented here, would let several
explicit paths with the same requirements share one reservation, e.g.
<reservation>@<path1>;@<path2>.  Would that make a kernel command-line
interface practical, or should firmware, platform data, or a PCI core
policy describe the expected resources?  We welcome feedback on the
interface as well as on the underlying hotplug allocation problem.

Bus-number reservation is not yet honored on a plain pci_rescan_bus()
path; the hardware test above exercises pciehp.  A separate allocator
retry releases a sibling bridge window on this system.  This series
does not address that issue.

Maciej Grochowski (2):
  PCI: Add pci=hpreserve= to reserve memory windows for a hotplug bridge
  PCI: Allow pci=hpreserve= to reserve bus numbers for a hotplug bridge

 .../admin-guide/kernel-parameters.txt         |  42 +++++++
 drivers/pci/pci.c                             | 108 ++++++++++++++++++
 drivers/pci/pci.h                             |  22 ++++
 drivers/pci/probe.c                           |  58 +++++++++-
 drivers/pci/setup-bus.c                       |  33 ++++++
 5 files changed, 259 insertions(+), 4 deletions(-)


base-commit: 5225b8eec4c9bb21aecff6295fab6346a3c3738e
-- 
2.47.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-07 13:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 19:31 [RFC PATCH 0/2] PCI: Reserve resources for a delayed hotplug subtree Maciej Grochowski
2026-10-02 19:31 ` [RFC PATCH 1/2] PCI: Add pci=hpreserve= to reserve memory windows for a hotplug bridge Maciej Grochowski
2026-10-03  1:33   ` sashiko-bot
2026-10-05  8:39   ` Ilpo Järvinen
2026-10-07 13:35     ` Maciej Grochowski
2026-10-02 19:31 ` [RFC PATCH 2/2] PCI: Allow pci=hpreserve= to reserve bus numbers " Maciej Grochowski
2026-10-03  1:33   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox