Re: [PATCH v2 10/22] vfio/pci: Skip reset of preserved device after Live Update

David Matlack
2026-02-27T00:51:24Z

On 2026-02-26 05:00 PM, Alex Williamson wrote:
> On Thu, 29 Jan 2026 21:24:57 +0000
> David Matlack <dmatlack@google.com> wrote:

> > - /* If reset fails because of the device lock, fail this path entirely */
> > - ret = pci_try_reset_function(pdev);
> > - if (ret == -EAGAIN)
> > - goto out_disable_device;
> > + if (vdev->liveupdate_incoming_state) {
> > + /*
> > + * This device was preserved by the previous kernel across a
> > + * Live Update, so it does not need to be reset.
> > + */
> > + vdev->reset_works = vdev->liveupdate_incoming_state->reset_works;
> > + } else {
> > + /*
> > + * If reset fails because of the device lock, fail this path
> > + * entirely.
> > + */
> > + ret = pci_try_reset_function(pdev);
> > + if (ret == -EAGAIN)
> > + goto out_disable_device;
> > +
> > + vdev->reset_works = !ret;
> > + }
>
> This could maybe be incrementally cleaner in a
> int vfio_pci_core_probe_reset(struct vfio_pci_core_device *vdev)
> helper.

Will do.

> >
> > - vdev->reset_works = !ret;
> > pci_save_state(pdev);
> > vdev->pci_saved_state = pci_store_saved_state(pdev);
>
> Isn't this a problem too? In the first kernel we store the initial,
> post reset state of the device, now we're storing some arbitrary state.
> This is the state we're restore when the device is closed.

The previous kernel resets the device and restores it back to its
post reset state in vfio_pci_liveupdate_freeze() before handing off
control to the next kernel. So my intention here is that VFIO will
receive the device in that state, allowing it to call
pci_store_saved_state() here to capture the post reset state of the
device again.

Eventually we want to drop the reset in vfio_pci_liveupdate_freeze() and
preserve vdev->pci_saved_state across the Live Update. But I was hoping
to add that in a follow up series to avoid this one getting too long.

> > diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h
> > index 350c30f84a13..95835298e29e 100644
> > --- a/include/linux/vfio_pci_core.h
> > +++ b/include/linux/vfio_pci_core.h
> > @@ -16,6 +16,7 @@
> > #include <linux/types.h>
> > #include <linux/uuid.h>
> > #include <linux/notifier.h>
> > +#include <linux/kho/abi/vfio_pci.h>
> >
> > #ifndef VFIO_PCI_CORE_H
> > #define VFIO_PCI_CORE_H
>
> Wouldn't a forward declaration do, and the kho/abi include can be kept
> out of the public header? Also should be in the previous patch?

Will do.