7dabb1bcd1
It's possible that the device firmware crashes and is able to recover due to some configuration and/or other issue. If a live migration is in progress while the firmware crashes, the live migration will fail. However, the VF PCI device should still be functional post crash recovery and subsequent migrations should go through as expected. When the pds_core device notices that firmware crashes it sends an event to all its client drivers. When the pds_vfio driver receives this event while migration is in progress it will request a deferred reset on the next migration state transition. This state transition will report failure as well as any subsequent state transition requests from the VMM/VFIO. Based on uapi/vfio.h the only way out of VFIO_DEVICE_STATE_ERROR is by issuing VFIO_DEVICE_RESET. Once this reset is done, the migration state will be reset to VFIO_DEVICE_STATE_RUNNING and migration can be performed. If the event is received while no migration is in progress (i.e. the VM is in normal operating mode), then no actions are taken and the migration state remains VFIO_DEVICE_STATE_RUNNING. Signed-off-by: Brett Creeley <brett.creeley@amd.com> Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20230807205755.29579-8-brett.creeley@amd.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright(c) 2023 Advanced Micro Devices, Inc. */
|
|
|
|
#ifndef _VFIO_DEV_H_
|
|
#define _VFIO_DEV_H_
|
|
|
|
#include <linux/pci.h>
|
|
#include <linux/vfio_pci_core.h>
|
|
|
|
#include "dirty.h"
|
|
#include "lm.h"
|
|
|
|
struct pds_vfio_pci_device {
|
|
struct vfio_pci_core_device vfio_coredev;
|
|
|
|
struct pds_vfio_lm_file *save_file;
|
|
struct pds_vfio_lm_file *restore_file;
|
|
struct pds_vfio_dirty dirty;
|
|
struct mutex state_mutex; /* protect migration state */
|
|
enum vfio_device_mig_state state;
|
|
spinlock_t reset_lock; /* protect reset_done flow */
|
|
u8 deferred_reset;
|
|
enum vfio_device_mig_state deferred_reset_state;
|
|
struct notifier_block nb;
|
|
|
|
int vf_id;
|
|
u16 client_id;
|
|
};
|
|
|
|
void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio);
|
|
|
|
const struct vfio_device_ops *pds_vfio_ops_info(void);
|
|
struct pds_vfio_pci_device *pds_vfio_pci_drvdata(struct pci_dev *pdev);
|
|
void pds_vfio_reset(struct pds_vfio_pci_device *pds_vfio);
|
|
|
|
struct pci_dev *pds_vfio_to_pci_dev(struct pds_vfio_pci_device *pds_vfio);
|
|
struct device *pds_vfio_to_dev(struct pds_vfio_pci_device *pds_vfio);
|
|
|
|
#endif /* _VFIO_DEV_H_ */
|