On Tue, Jul 28, 2026 at 10:09:59PM +0000, David Matlack wrote:
> During a Live Update, preserved devices must be allowed to continue
> performing memory transactions so the kernel cannot change the fabric
> topology, including bus numbers, since that would require disabling and
> flushing any memory transactions first.
> 
> To keep bus numbers constant, always preserve the secondary and
> subordinate bus numbers assigned to bridges during scanning, instead of
> assigning new ones, if any PCI devices were preserved. Note that the
> kernel preserves bus numbers even on bridges without any downstream
> endpoints that were preserved. This avoids accidentally assigning a
> bridge a new window that overlaps with a preserved device that is
> downstream of a different bridge.

> +bool pci_liveupdate_preserve_bus_numbers(struct pci_bus *bus, struct pci_dev 
> *dev)
> +{
> +     struct pci_dev *parent = bus->self;
> +
> +     if (dev->liveupdate.preserve_bus_numbers)
> +             return true;
> +
> +     if (parent && parent->liveupdate.preserve_bus_numbers) {
> +             /*
> +              * Preserve bus numbers if the parent bridge is required to
> +              * preserve bus numbers. Otherwise the PCI core could expand
> +              * this bridge's reservation beyond its parent (which cannot
> +              * expand).
> +              */
> +             dev->liveupdate.preserve_bus_numbers = true;
> +     } else {
> +             /*
> +              * Otherwise preserve bus numbers if there are any incoming
> +              * preserved devices. This ensures that the PCI core does not
> +              * allocate a bus number to a non-preserved device that
> +              * conflicts with the bus number already assigned to a preserved
> +              * device.
> +              *
> +              * This is slightly more restrictive than it needs to be. For
> +              * example, each host bridges have their own range of bus
> +              * numbers that won't conflict with other host bridges. But the
> +              * previous kernel should have assigned a sane bus topology and
> +              * it is simpler to just adopt that entire topology.

s/each ... bridges have their/each ... bridge has its/

It's true there should be no bus number conflicts between host
bridges, but it does require the domain as well.

> +              */
> +             dev->liveupdate.preserve_bus_numbers =
> +                     pci_has_incoming_preserved_devices();
> +     }
> +
> +     return dev->liveupdate.preserve_bus_numbers;

I'm not sure why you don't just return
pci_has_incoming_preserved_devices() in all cases, which is what the
commit log suggests this patch does.  What's gained by all the logic
here?  It's not like devices will be hot-added during the kexec.

Reply via email to