Re: [PATCH v4 05/11] PCI: liveupdate: Inherit bus numbers during Live Update

David Matlack
2026-04-27T20:41:07Z

On 2026-04-27 11:47 AM, Jacob Pan wrote:
> On Thu, 23 Apr 2026 21:23:09 +0000
> David Matlack <dmatlack@google.com> wrote:

> > To keep things simple, inherit the secondary and subordinate bus
> > numbers on all bridges if any PCI devices were preserved (i.e. even
> > 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.
> >
> > If a bridge is enumerated with a broken topology or has no bus numbers
> > set during a Live Update, refuse to assign it new bus numbers and
> > refuse to enumerate devices below it. This is a safety measure to
> > prevent topology conflicts.
> >
> > Require that CONFIG_CARDBUS is not enabled to enable
> > CONFIG_PCI_LIVEUPDATE since inheriting bus numbers on PCI-to-CardBus
> > bridges requires additional work but is not a priority at the moment.
> >
> > Signed-off-by: David Matlack <dmatlack@google.com>

> > + /*
> > + * During a Live Update, preserved devices are allowed to
> > continue
> > + * performing memory transactions. The kernel must not
> > change the fabric
> > + * topology, including bus numbers, since that would require
> > disabling
> > + * and flushing any memory transactions first.
> > + *
> > + * To keep things simple, inherit the secondary and
> > subordinate bus
> > + * numbers on _all_ bridges if _any_ PCI devices were
> > preserved (i.e.
> > + * even 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.
> > + */
> > + dev->liveupdate_inherit_buses = true;
> > +
> This flag never gets cleared after the incoming kernel boot up, what if
> the user does a manual rescan via sysfs? i.e.
> # echo 1 > /sys/bus/pci/rescan
> pcibios_assign_all_busses() will never gets called for this device, and
> may hit this
> if (dev->liveupdate_inherit_buses) {
> pci_err(dev, "Cannot reconfigure bridge during
> Live Update!\n");
>
> So, maybe clear it in pci_liveupdate_finish()?

I think we can allo wa rescan to assign new bus numbers once all devices
go through pci_liveupdate_finish() by clearing
dev->liveupdate_inherit_buses on all devices in pci_flb_finish(). We
would need to hold pci_rescan_remove_lock to avoid this racing with such
a rescan.

Now that you bring up /sys/bus/pci/rescan... I think we also need to
set dev->liveupdate_inherit_buses in the outgoing kernel, to avoid bus
numbers changing on outgoing preserved devices. pci_flb_preserve()
should take pci_rescan_remove_lock and set dev->liveupdate_inherit_buses
on all devices, and pci_flb_unpreserve() should do the opposite.

If we did all then then /sys/bus/pci/rescan can work like normal as long
as no devices are preserved (incoming or outgoing). If any devices are
preserved then dev->liveupdate_inherit_buses gets set to prevent bus
numbers from changing during a possible rescan.