[PATCH v2 00/10] LUO: PCI subsystem (phase I)

Chris Li
2025-09-16T07:45:14Z

This is phase I of the LUO PCI series. It does the minimal set of PCI
device liveupdate which is preserving a bus master bit in the PCI command
register.

The LUO PCI subsystem is based on the LUO V2 series.
https://lore.kernel.org/lkml/20250515182322.117840-1-pasha.tatashin@soleen.com/

It registers the PCI as a LUO subsystem and forwards the liveupdate
callback to the device. The struct dev_liveupdate has been add to struct
device to keep track of the liveupdate related context.

A device can be marked as requested for liveupdate during the normal
state.

In the prepare() callback. The PCI core will build a list of the PCI device
for liveupdate based on the PCI device dependency:
1) The requested device is dependent on the PCI bridge it is on to preserve
the bridge bus master. All the way to the root bridge. If the bus master
has been disabled on the bridge, the DMA on the children devices will
get impacted.

The list of liveupdate devices is used for prepare(), cancel(), freeze()
and finalized() callback.

The PCI subsystem will preserve the driver name for each liveupdate PCI
device and only probe that driver after kexec boot up.

Disclaimer:
The data preservation format is not final. It currently uses C struct
directly. It does not deal with version change on the data format yet. I
do have some idea how to address the versioning of data layout. Those
will be outside the scope of this series.

Testing:
Testing was done with Intel diorite NVMe VF device 8086:1457. Bind the
test device with pci-lu-stub driver.

0000:05:00.1 current driver is
0000:05:00.1 bind new driver pci-lu-stub
[ 557.006998] pci-lu-stub 0000:05:00.1: Marking device liveupdate busmaster

Now perform luo prepare, the PCI subsystem builds the liveupdate device
list from the PCI root bridge. The test device will have LU_BUSMASTER
and the PCI bridge will have LU_BUSMASTER_BRIDGE.

[ 701.573423] pci-lu-stub 0000:05:00.1: PCI liveupdate: collect liveupdate device: flags 1
[ 701.582430] pcieport 0000:04:01.0: PCI liveupdate: collect liveupdate device: flags 2
[ 701.590297] pci-lu-stub 0000:05:00.1: pci_lu_stub_prepare(): data: 0x1ac6f4000
[ 701.598916] PCI liveupdate: prepare data[1f1d28000]
[ 701.603832] luo_core: Switched from [normal] to [prepared] state

After kexec reboot. The liveupdate devices are probed and restores the live
update context.
[ 3.622083] pci 0000:04:01.0: PCI liveupdate: liveupdate restore flags 2 driver: pcieport data: [0]
[ 4.768060] pci 0000:05:00.1: PCI liveupdate: liveupdate restore flags 1 driver: pci-lu-stub data: [1ac6f4000]

Perform luo finish to convert from update state to normal state. The
reserved folio will be freed.

[ 310.359830] PCI liveupdate: finish data[1f1d28000]
[ 310.364664] pci-lu-stub 0000:05:00.1: pci_lu_stub_finish(): data: 0x1ac6f4000
[ 310.371824] luo_core: Switched from [updated] to [normal] state

Signed-off-by: Chris Li <chrisl@kernel.org>
---
Changes in v2:
- reduce the scope of the series to phase I. Only preserve the bus
master bit.
- Use finer grain flags to specify which liveupdate feature gets
preserved.
- Modify the pci-lu-stub driver to set the bus master bit before
requesting preserving the bus master.
- Add WARN_ON() for the PCI device has LU_BUSMASTER but the bus master
bit is not set.
- Link to v1: https://lore.kernel.org/r/20250728-luo-pci-v1-0-955b078dd653@kernel.org

---
Chris Li (10):
PCI/LUO: Register with Liveupdate Orchestrator
PCI/LUO: Create requested liveupdate device list
PCI/LUO: Forward prepare()/freeze()/cancel() callbacks to driver
PCI/LUO: Restore state at PCI enumeration
PCI/LUO: Forward finish callbacks to drivers
PCI/LUO: Save and restore driver name
PCI/LUO: Add liveupdate to pcieport driver
PCI/LUO: Add pci_liveupdate_get_driver_data()
PCI/LUO: Avoid write to bus master at boot
PCI: pci-lu-stub: Add a stub driver for Live Update testing

MAINTAINERS | 4 +
drivers/pci/Kconfig | 10 +
drivers/pci/Makefile | 2 +
drivers/pci/liveupdate.c | 450 +++++++++++++++++++++++++++++++++++++++++
drivers/pci/pci-lu-stub.c | 140 +++++++++++++
drivers/pci/pci.c | 7 +-
drivers/pci/pci.h | 8 +
drivers/pci/pcie/portdrv.c | 13 ++
drivers/pci/probe.c | 8 +-
include/linux/dev_liveupdate.h | 69 +++++++
include/linux/device.h | 15 ++
include/linux/device/driver.h | 6 +
include/linux/pci.h | 9 +
13 files changed, 738 insertions(+), 3 deletions(-)
---
base-commit: 9ab803064e3d1be9673d2829785a69fd0578b24e
change-id: 20250724-luo-pci-1291890b710f

Best regards,
--
Chris Li <chrisl@kernel.org>