[PATCH v2 05/10] PCI/LUO: Forward finish callbacks to drivers

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

When PCI receives the LUO finish callback. The PCI subsystem forwards the
finish callback to the driver with restored dev->lu.dev_state->data.

Tested: In qemu, request a virtio net device as requested.
Perform luo prepare then kexec. Verify the new kernel boot up
dmesg shows the requested device has per device live update state
restored. Perform liveupdate finish and see the device finish
callback gets invoked.

Signed-off-by: Chris Li <chrisl@kernel.org>
---
drivers/pci/liveupdate.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c
index 305c5e85aba6bac9d02f97c83e7b3250298d2eff..41606df346f751c78f6c69caa275b4a76be72510 100644
--- a/drivers/pci/liveupdate.c
+++ b/drivers/pci/liveupdate.c
@@ -264,6 +264,29 @@ static int pci_call_freeze(struct pci_ser *pci_state, struct list_head *devlist)
return 0;
}

+static void pci_call_finish(struct list_head *devlist)
+{
+ struct device *dev;
+
+ pci_lock_rescan_remove();
+ down_write(&pci_bus_sem);
+
+ list_for_each_entry(dev, devlist, lu.lu_next) {
+ struct pci_dev_ser *s = dev->lu.dev_state;
+
+ if (!dev->driver)
+ panic("PCI luo finish: dev %s does not have driver", dev_name(dev));
+ if (!dev->driver->lu)
+ panic("PCI luo finish: dev %s does not support liveupdate",
+ dev_name(dev));
+ if (!dev->driver->lu->finish)
+ continue;
+ dev->driver->lu->finish(dev, s->driver_data);
+ }
+ up_write(&pci_bus_sem);
+ pci_unlock_rescan_remove();
+}
+
static int pci_liveupdate_freeze(void *arg, u64 *data)
{
struct pci_ser *pci_state = phys_to_virt(*data);
@@ -297,7 +320,12 @@ static void pci_liveupdate_cancel(void *arg, u64 data)

static void pci_liveupdate_finish(void *arg, u64 data)
{
+ struct pci_ser *pci_state = phys_to_virt(data);
+
pr_info("finish data[%llx]\n", data);
+ pci_call_finish(&probe_devices);
+ cleanup_liveupdate_devices(&probe_devices);
+ cleanup_liveupdate_state(pci_state);
}

struct liveupdate_subsystem pci_liveupdate_ops = {

--
2.51.0.384.g4c02a37b29-goog