PCI: Reserve resources for a delayed hotplug subtree
Subsystems (2)
v2 cover PCI: Reserve resources for a delayed hotplug subtree
From: Maciej Grochowski <[email protected]>
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.
V2 extends the existing pci=hpmmiosize, hpmmioprefsize and hpbussize parameters, as Ilpo suggested, instead of adding hpreserve. Patch 1 requests a required memory window size and size-derived head alignment; patch 2 reserves bus numbers before the remainder is shared among sibling hotplug ports. The path form tolerates downstream bus renumbering. Bare values retain their existing global meaning.
The v2 setting for the same port is:
pci=hpmmioprefsize=1032M@0000:80:01.1/00.0/03.0,hpbussize=11@0000:80:01.1/00.0/03.0
A 1032 MiB minimum requests 1 GiB head alignment without a separate alignment option. Placement and parent resources still limit allocation; assigned firmware windows are kept.
With v1 on a v7.3-rc2 based kernel and the hpreserve setting from the original post, we tested a cold boot, two top-switch hard resets and one nested-switch hard reset. 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. These are the previously reported v1 results; this rebased v2 tree has not been boot-tested.
The failure affects our PCIe hotplug infrastructure. The two-level test shows that a per-bridge reservation can preserve one delayed subtree. With three or more switch layers returning at different times, this approach appears to need a reservation at each port sized while empty. Each ancestor must retain enough bus numbers and aligned memory for the eventual subtree. We have not tested that case.
Consider three top-level switches, each feeding six second-level switches with eight NTB functions apiece. If the child links return late, that gives 18 selected bridge paths, plus any delayed ancestors. With separate memory-size and bus-count options, those paths normally appear in both lists: 36 value@path entries. The NTB BARs affect resources per bridge, not the entry count. Device-ID matching could shorten a homogeneous case, but risks reserving space on same-ID ports without delayed children.
One possible extension, not implemented here, would let several explicit paths with identical requirements share a value in each option. 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 and the underlying allocation problem, including required versus optional per-device memory sizes.
Changes since v1:
- Reuse hpmmiosize, hpmmioprefsize and hpbussize, following Ilpo's feedback.
- Derive head alignment from the requested size instead of mmioprefalign.
- Apply the scoped bus minimum on the plain child-bus scan path too.
- Include small sizing/sharing safety corrections; keep the two-patch design.
- Drop self Tested-by trailers and rebase on PCI next.
This revision passed W=1 PCI object builds at both patch boundaries on ARM64 and i386 PAE/64-bit resources, plus focused userspace source checks. The PCI sources emitted no warnings; one Darwin host-tool macro warning was recorded. These checks do not replace hardware or concurrency testing.
Plain-rescan minima are now handled, but existing firmware ranges and retained-child optional spare remain limitations. The sibling-window allocator retry issue reported with v1 is outside this series. The separate bus-number overflow fixes overlap a scan guard and will require rebasing if both series are taken.
v1: https://lore.kernel.org/linux-pci/[email protected]/
Maciej Grochowski (2):
PCI: Allow hpmmiosize and hpmmioprefsize for specific hotplug bridges
PCI: Allow hpbussize for specific hotplug bridges
Documentation/admin-guide/kernel-parameters.txt | 41 +++++++++++ drivers/pci/pci.c | 91 ++++++++++++++++++++++++- drivers/pci/pci.h | 3 + drivers/pci/probe.c | 87 ++++++++++++++++++++++- drivers/pci/setup-bus.c | 25 +++++++ 5 files changed, 243 insertions(+), 4 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
RFC PATCH v2 1/2 PCI: Allow hpmmiosize and hpmmioprefsize for specific hotplug bridges
From: Maciej Grochowski <[email protected]>
A hotplug bridge can be sized before devices expected behind it appear. After a reset of a two-level PM50052 hierarchy, the nested switch's link returns after its downstream port has received an equal share of the parent's window. Its 1 GiB prefetchable NTB BAR then fails assignment:
pci 0000:8c:00.1: BAR 2 [mem size 0x40000000 64bit pref]: can't assign; no space
The global hotplug memory sizes are optional targets for every hotplug bridge. They cannot reserve the required space and head alignment on one specific port when the parent aperture cannot satisfy all its siblings.
Allow hpmmiosize and hpmmioprefsize to take "<size>@<pci_dev>" entries, separated by semicolons, using the existing PCI device selectors. For example:
pci=hpmmioprefsize=1032M@0000:80:01.1/00.0/03.0
Use the selected size as a required total window minimum in pbus_size_mem() and request head alignment of the largest power of two not above that size. Apply size and alignment independently, preserving stronger existing requirements. A 1032 MiB minimum therefore requests 1 GiB head alignment.
Reject scoped values that exceed the existing unsigned long size interface before narrowing them. Also guard window adjustment when there is no optional realloc entry: a required minimum equal to the global size can leave no entry to trim.
Retain the existing global optional-space policy. Assigned firmware windows are kept; the minimum applies when the kernel sizes a window, such as after hot-add or resource reallocation. Allocation remains subject to the parent aperture and normal placement rules. A bare option keeps its existing global meaning.
--- .../admin-guide/kernel-parameters.txt | 25 +++++++ drivers/pci/pci.c | 75 ++++++++++++++++++- drivers/pci/pci.h | 3 + drivers/pci/setup-bus.c | 25 +++++++ 4 files changed, 126 insertions(+), 2 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +25 -0
@@ -5218,9 +5218,34 @@ Kernel parameters hpmmiosize=nn[KMG] The fixed amount of bus space which is reserved for hotplug bridge's MMIO window. Default size is 2 megabytes. + hpmmiosize=nn[KMG]@<pci_dev>[; ...] + Reserve at least nn bytes of MMIO window for + the hotplug bridges specified (in the format + described above), e.g. for a switch that is + expected behind the bridge but whose link + comes up only after the bridge windows have + been sized. Unlike the default amount, which + is optional space that is dropped if it does + not fit, this is required space: the window + is sized like it would be for devices already + present below the bridge, with head alignment + from the largest power of two not above nn. + The size must fit unsigned long. Only hotplug bridges + are affected, and only windows the kernel + sizes, e.g. after a hot-add or with + pci=realloc; windows set up by firmware are + kept. hpmmioprefsize=nn[KMG] The fixed amount of bus space which is reserved for hotplug bridge's MMIO_PREF window. Default size is 2 megabytes. + hpmmioprefsize=nn[KMG]@<pci_dev>[; ...] + Like hpmmiosize=nn[KMG]@<pci_dev>, for the + MMIO_PREF window. For example, + pci=hpmmioprefsize=1032M@0000:80:01.1/00.0/03.0 + requests a 1032 MiB prefetchable window with + 1 GiB head alignment below the downstream + port at devfn 03.0 of the switch behind root + port 0000:80:01.1. hpmemsize=nn[KMG] The fixed amount of bus space which is reserved for hotplug bridge's MMIO and MMIO_PREF window.
drivers/pci/pci.c +73 -2
94 lines not on this page · raw message
drivers/pci/pci.h +3 -0
@@ -419,6 +419,9 @@ extern unsigned long pci_hotplug_mmio_size;extern unsigned long pci_hotplug_mmio_pref_size;extern unsigned long pci_hotplug_bus_size; +bool pci_hotplug_dev_size (struct pci_dev *bridge,unsigned long type, +unsigned long *size); +static inline bool pci_is_cardbus_bridge (struct pci_dev *dev) {return dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS ;
drivers/pci/setup-bus.c +25 -0
@@ -26,6 +26,7 @@#include <linux/ioport.h> #include <linux/cache.h> #include <linux/limits.h> +#include <linux/log2.h> #include <linux/sizes.h> #include <linux/slab.h> #include <linux/acpi.h>
@@ -1285,6 +1286,7 @@ static void pbus_size_mem(struct pci_bus *bus, struct resource *b_res,int order, max_order;resource_size_t children_add_size =0 ;resource_size_t add_align =0 ; +unsigned long hp_size;if (!b_res)return ;
@@ -1349,6 +1351,27 @@ static void pbus_size_mem(struct pci_bus *bus, struct resource *b_res, win_align =pci_min_window_alignment (bus, b_res->flags); min_align =calculate_head_align (aligns, max_order); min_align =max (min_align, win_align); + +/* +* A hotplug size given for this bridge is a required minimum, not +* optional space like the global size: aligned for the largest BAR +* that fits in it, so it is in place before the devices that need +* it appear below the bridge. +*/ +if (bus->self && +pci_hotplug_dev_size (bus->self, b_res->flags, &hp_size)) { +if (hp_size) { + size =max (size, hp_size); + min_align =max_t (resource_size_t, min_align, +rounddown_pow_of_two (hp_size)); +pci_info (bus->self,"bridge window to %pR: reserving %s size %#lx align %#llx\n" , + &bus->busn_res, + b_res->flags &IORESOURCE_PREFETCH ? +"prefetchable" :"non-prefetchable" , + hp_size, (unsigned long long )min_align); + } + } + size0 =calculate_memsize (size, realloc_head ?0 : add_size,0 , win_align);
@@ -1897,6 +1920,8 @@ static void adjust_bridge_window(struct pci_dev *bridge, struct resource *res, } dev_res =res_to_dev_res (add_list, res); +if (!dev_res) +return ; add_size = size - new_size;if (add_size < dev_res->add_size) { dev_res->add_size -= add_size;
[email protected]
AI reviewRe: [RFC PATCH v2 1/2] PCI: Allow hpmmiosize and hpmmioprefsize for specific hotplug bridges
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] PCI: pbus_size_mem() adds children_add_size on top of scoped hp_size --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] PCI: pbus_size_mem() adds children_add_size on top of scoped hp_size --
commit 926f817ace771cfa772ae856e4b49cefab5e63e8
Author: Maciej Grochowski <[email protected]>
PCI: Allow hpmmiosize and hpmmioprefsize for specific hotplug bridges
This commit extends the pci=hpmmiosize= and pci=hpmmioprefsize= boot parameters to accept per-bridge <size>@<pci_dev> entries, applying the specified size as a required minimum window size and head alignment in pbus_size_mem().
Quoted 4 lines
drivers/pci/setup-bus.c +0
-0
[ ... ]
Quoted 17 lines
drivers/pci/setup-bus.c +13
-0@@ -1349,6 +1351,27 @@ static void pbus_size_mem(struct pci_bus *bus, struct resource *b_res, win_align =pci_min_window_alignment (bus, b_res->flags); min_align =calculate_head_align (aligns, max_order); min_align =max (min_align, win_align); + +/* +* A hotplug size given for this bridge is a required minimum, not +* optional space like the global size: aligned for the largest BAR +* that fits in it, so it is in place before the devices that need +* it appear below the bridge. +*/ +if (bus->self && +pci_hotplug_dev_size (bus->self, b_res->flags, &hp_size)) { +if (hp_size) { + size =max (size, hp_size); + min_align =max_t (resource_size_t, min_align, +rounddown_pow_of_two (hp_size));
drivers/pci/setup-bus.c static void pbus_size_mem(struct pci_bus *bus, struct resource *b_res, · line 1376
Quoted 10 lines
drivers/pci/setup-bus.c +8
-0+pci_info (bus->self,"bridge window to %pR: reserving %s size %#lx align %#llx\n" , + &bus->busn_res, + b_res->flags &IORESOURCE_PREFETCH ? +"prefetchable" :"non-prefetchable" , + hp_size, (unsigned long long )min_align); + } + } + size0 =calculate_memsize (size, realloc_head ?0 : add_size,0 , win_align);
[Severity: Medium]
In pbus_size_mem(), when realloc_head is non-NULL, required child resources are summed into size while optional child resources (such as child hotplug bridges, SR-IOV BARs, or disabled ROMs) are accumulated into children_add_size via pbus_size_mem_optional().
Subsequently, size1 is calculated as:
if (realloc_head && (add_size > 0 || children_add_size > 0)) {
add_align = max(min_align, add_align);
size1 = calculate_memsize(size, add_size, children_add_size,
win_align);
}where calculate_memsize() computes max(size + children_add_size, min_size).
Because size is overwritten with max(size, hp_size) before size1 is calculated, doesn't calculate_memsize() add children_add_size on top of hp_size rather than fitting those optional child resources within the hp_size minimum window? When hp_size > size and children_add_size > 0, size1 becomes ALIGN(hp_size + children_add_size, win_align) even when size + children_add_size <= hp_size, queueing an extra add_size = size1 - size0 on realloc_head.
By contrast, when realloc_head is NULL (such as in earlier passes of pci_assign_unassigned_root_bus_resources() with pci=realloc), pbus_size_mem_optional() returns false and optional child resources are summed into size before size = max(size, hp_size), so they fit within hp_size.
Would it make sense to keep size as the sum of required child resources and apply hp_size as a minimum to size0 and size1 instead (for example, passing max(add_size, hp_size) as min_size when computing size1)?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
RFC PATCH v2 2/2 PCI: Allow hpbussize for specific hotplug bridges
In reply to Maciej GrochowskiFrom: Maciej Grochowski <[email protected]>
Spare bus numbers below a switch are divided between its hotplug ports. A nested switch that appears later can need more than its port's share. After a top-switch reset on our PM50052 hierarchy, five downstream ports split 15 bus numbers equally, leaving the nested switch's port three buses although its hierarchy needs 11.
A global hpbussize of 11 asks for the same minimum on all five ports, so earlier siblings consume the range before the selected port is reached.
Allow hpbussize to take "<count>@<pci_dev>" entries, separated by semicolons, using the lookup added by the memory-window patch:
pci=hpbussize=11@0000:80:01.1/00.0/03.0
Recompute each unconfigured hotplug bridge's share from the bus numbers still free and the remaining minima. The selected bridge's count replaces its global minimum; the other bridges share the remainder. In this case, the split becomes 1/1/1/11/1 instead of 3/3/3/3/3.
Include the global minimum for unselected bridges in that calculation. Clamp scoped counts to 255 and stop before looking up a secondary bus number above 255, so a large request cannot wrap the lookup to bus zero.
Apply the selected minimum when scanning the bridge's own child bus too. Parent capacity still limits the reservation, and configured firmware ranges are kept. A bare option keeps its existing global meaning.
--- .../admin-guide/kernel-parameters.txt | 16 ++++ drivers/pci/pci.c | 34 ++++++-- drivers/pci/probe.c | 87 ++++++++++++++++++- 3 files changed, 126 insertions(+), 11 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +16 -0
@@ -5253,6 +5253,22 @@ Kernel parameters hpbussize=nn The minimum amount of additional bus numbers reserved for buses below a hotplug bridge. Default is 1. + hpbussize=nn@<pci_dev>[; ...] + The minimum amount of bus numbers for the + hotplug bridges specified (in the format + described above) instead of the default + amount above. When the kernel numbers the + buses below the hotplug bridges on a bus, + e.g. after a switch is hot-added, these + bridges request at least nn bus numbers where + space permits; other hotplug bridges share + what is left. + Bridges numbered by firmware are kept. For + example, + pci=hpbussize=11@0000:80:01.1/00.0/03.0 + gives 11 bus numbers to the downstream port + at devfn 03.0 of the switch behind root port + 0000:80:01.1. realloc= Enable/disable reallocating PCI bridge resources if allocations done by BIOS are too small to accommodate resources required by all child
drivers/pci/pci.c +25 -9
@@ -413,11 +413,13 @@ static int pci_dev_str_match(struct pci_dev *dev, const char *p, }/* -* "<size>@<pci_dev>" entries of "pci=hpmmiosize=" and "pci=hpmmioprefsize=", -* set in pci_setup() and copied in pci_realloc_setup_params(). +* "<size>@<pci_dev>" entries of "pci=hpmmiosize=", "pci=hpmmioprefsize=" and +* "pci=hpbussize=", set in pci_setup() and copied in +* pci_realloc_setup_params(). */ static const char *hotplug_mmio_size_param;static const char *hotplug_mmio_pref_size_param; +static const char *hotplug_bus_size_param;/* Match @bridge against a "<size>@<pci_dev>[;...]" list; first match wins */ static bool pci_hotplug_size_match(struct pci_dev *bridge, const char *p,
@@ -455,23 +457,33 @@ static bool pci_hotplug_size_match(struct pci_dev *bridge, const char *p,/** * pci_hotplug_dev_size - get a hotplug size given for a specific bridge * @bridge: the bridge -* @type: IORESOURCE_MEM, optionally with IORESOURCE_PREFETCH +* @type: IORESOURCE_MEM, optionally with IORESOURCE_PREFETCH, or IORESOURCE_BUS * @size: set to the size given for @bridge * -* Look up @bridge in the "<size>@<pci_dev>" entries of "pci=hpmmiosize=" or -* "pci=hpmmioprefsize=". Only hotplug bridges are considered. +* Look up @bridge in the "<size>@<pci_dev>" entries of "pci=hpmmiosize=", +* "pci=hpmmioprefsize=" or "pci=hpbussize=". Only hotplug bridges are +* considered. * * Return: true if a size was given for @bridge. */ bool pci_hotplug_dev_size (struct pci_dev *bridge,unsigned long type,unsigned long *size) { -if (!bridge->is_hotplug_bridge || !(type &IORESOURCE_MEM )) +const char *p; + +if (!bridge->is_hotplug_bridge) +return false; + +if (type &IORESOURCE_BUS ) + p = hotplug_bus_size_param; +else if (type &IORESOURCE_PREFETCH ) + p = hotplug_mmio_pref_size_param; +else if (type &IORESOURCE_MEM ) + p = hotplug_mmio_size_param; +else return false; -return pci_hotplug_size_match (bridge, type &IORESOURCE_PREFETCH ? - hotplug_mmio_pref_size_param : - hotplug_mmio_size_param, size); +return pci_hotplug_size_match (bridge, p, size); } static u8 __pci_find_next_cap(struct pci_bus *bus, unsigned int devfn,
@@ -6966,6 +6978,9 @@ static int __init pci_setup(char *str) }else if (!strncmp (str,"hpmemsize=" ,10 )) { pci_hotplug_mmio_size =memparse (str +10 , &str); pci_hotplug_mmio_pref_size = pci_hotplug_mmio_size; + }else if (!strncmp (str,"hpbussize=" ,10 ) && +strchr (str +10 ,'@' )) { + hotplug_bus_size_param = str +10 ; }else if (!strncmp (str,"hpbussize=" ,10 )) { pci_hotplug_bus_size =simple_strtoul (str +10 , &str,0 );
@@ -7013,6 +7028,7 @@ static int __init pci_realloc_setup_params(void) hotplug_mmio_size_param =kstrdup (hotplug_mmio_size_param,GFP_KERNEL ); hotplug_mmio_pref_size_param =kstrdup (hotplug_mmio_pref_size_param,GFP_KERNEL ); + hotplug_bus_size_param =kstrdup (hotplug_bus_size_param,GFP_KERNEL );return 0 ; }
drivers/pci/probe.c +85 -2
135 lines not on this page · raw message
[email protected]
AI reviewRe: [RFC PATCH v2 2/2] PCI: Allow hpbussize for specific hotplug bridges
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] PCI: child bus extension in pci_scan_child_bus_extend() steals sibling buses - [Medium] PCI…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] PCI: child bus extension in pci_scan_child_bus_extend() steals sibling buses
- [Medium] PCI: unsigned underflow clamping buses in pci_scan_child_bus_extend() --
commit be51a5abd9a8e4940755184950c4647a492d014d
Author: Maciej Grochowski <[email protected]>
PCI: Allow hpbussize for specific hotplug bridges
This commit extends the pci=hpbussize= boot parameter to accept per-bridge bus count reservations in the form <count>@<pci_dev>, recomputing the share of spare bus numbers for unconfigured hotplug bridges on a bus and applying the scoped minimum when scanning the bridge's child bus.
Quoted 4 lines
drivers/pci/probe.c +0
-0
[ ... ]
Quoted 7 lines
drivers/pci/probe.c +2
-1@@ -3163,7 +3228,16 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,* Distribute the extra buses between hotplug * bridges if any. */ - buses = available_buses / hotplug_bridges; +if (hotplug_reserve && available_buses) { +if (!dev->subordinate) {
drivers/pci/probe.c static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, · line 3242
Quoted 10 lines
drivers/pci/probe.c +8
-0+ reserve =pci_hotplug_bus_reserve (dev); + buses = available_buses +1 > used_buses ? + available_buses +1 - used_buses :0 ; + buses =pci_hotplug_bus_share (bus, dev, buses); + } + }else { + buses = available_buses / hotplug_bridges; + } buses =min (buses, available_buses - used_buses +1 ); }
[Severity: Medium]
Can available_buses - used_buses + 1 underflow in unsigned arithmetic here?
Before calling pci_hotplug_bus_share(), this checks whether available_buses + 1 > used_buses and passes 0 when used_buses is larger (for example, when SR-IOV buses plus the one-bus-per-bridge count from the first pass exceed available_buses + 1, or after earlier bridges consumed more buses than available_buses).
However, pci_hotplug_bus_share() unconditionally returns at least reserve:
reserve = pci_hotplug_bus_reserve(bridge) ?: pci_hotplug_bus_size;
return max(reserve, share);When min(buses, available_buses - used_buses + 1) then runs without that guard, available_buses - used_buses + 1 wraps around to a large unsigned value, leaving the non-zero buses count from pci_hotplug_bus_share() unclamped instead of clamping it to 0.
Quoted 16 lines
drivers/pci/probe.c +0
-0cmax = max;drivers/pci/probe.c +6
-0max =pci_scan_bridge_extend (bus, dev, cmax, buses,1 );/* One bus is already accounted so don't add it again */ if (max - cmax >1 ) used_buses += max - cmax -1 ; + +if (reserve > max - cmax) +pci_warn (dev,"only %u of %u bus numbers available\n" , + max - cmax, reserve); +else if (reserve) +pci_info (dev,"reserving %u bus numbers\n" , max - cmax); }/*
drivers/pci/probe.c static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, · line 3266
Quoted 8 lines
drivers/pci/probe.c +4
-1@@ -3180,7 +3260,10 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,* bus number if there is room. */ if (bus->self && bus->self->is_hotplug_bridge) { - used_buses =max (available_buses, pci_hotplug_bus_size -1 ); +unsigned long bus_size =pci_hotplug_bus_reserve (bus->self) ?: + pci_hotplug_bus_size; + + used_buses =max (available_buses, bus_size -1 );
[Severity: High]
When a hotplug bridge's scoped reservation is clamped by the parent bus in pci_scan_child_bus_extend() so that 1 bus number remains per subsequent sibling bridge, won't taking max(available_buses, bus_size - 1) on the child bus override that clamp and consume the sibling bridges' buses?
On the parent bus, pci_scan_child_bus_extend() clamps the bridge's share via:
buses = min(buses, available_buses - used_buses + 1);
and passes that clamped count to pci_scan_bridge_extend(). In pass 1, pci_scan_bridge_extend() creates the child bus with its temporary end set to the parent's busn_res.end before recursing:
pci_bus_insert_busn_res(child, next_busnr,
bus->busn_res.end);
...
if (available_buses)
available_buses--;
...
max = pci_scan_child_bus_extend(child, available_buses);Inside the recursive pci_scan_child_bus_extend(child, available_buses) call, bus->self is that hotplug bridge. Using max(available_buses, bus_size - 1) replaces the parent-clamped available_buses with the unclamped bus_size - 1, and only bounds max = start + used_buses against child->busn_res.end (which is still the parent bus's busn_res.end).
For example, if 5 hotplug downstream ports share 15 buses and port 3 requests hpbussize=12 after ports 0..2 take 1 bus each, the parent clamps port 3 to 11 buses so 1 bus remains for port 4. In the child scan for port 3, available_buses is 10 while bus_size - 1 is 11, so max(10, 11) extends port 3 all the way to the parent's busn_res.end, leaving no bus number for port 4 and suppressing the "only %u of %u bus numbers available" warning.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2