@@ -57,7 +57,7 @@ static void pds_vfio_recovery(struct pds_vfio_pci_device *pds_vfio)
if (deferred_reset_needed) {
mutex_lock(&pds_vfio->reset_mutex);
pds_vfio->deferred_reset = true;
- pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_ERROR;
+ pds_vfio->deferred_reset_type = PDS_VFIO_DEVICE_RESET;
mutex_unlock(&pds_vfio->reset_mutex);
}
}
@@ -34,11 +34,12 @@ void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio)
pds_vfio->deferred_reset = false;
pds_vfio_put_restore_file(pds_vfio);
pds_vfio_put_save_file(pds_vfio);
- if (pds_vfio->state == VFIO_DEVICE_STATE_ERROR) {
+ if (pds_vfio->deferred_reset_type == PDS_VFIO_DEVICE_RESET) {
pds_vfio_dirty_disable(pds_vfio, false);
+ pds_vfio->state = VFIO_DEVICE_STATE_ERROR;
+ } else {
+ pds_vfio->state = VFIO_DEVICE_STATE_RUNNING;
}
- pds_vfio->state = pds_vfio->deferred_reset_state;
- pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING;
mutex_unlock(&pds_vfio->reset_mutex);
goto again;
}
@@ -50,7 +51,7 @@ void pds_vfio_reset(struct pds_vfio_pci_device *pds_vfio)
{
mutex_lock(&pds_vfio->reset_mutex);
pds_vfio->deferred_reset = true;
- pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING;
+ pds_vfio->deferred_reset_type = PDS_VFIO_HOST_RESET;
if (!mutex_trylock(&pds_vfio->state_mutex)) {
mutex_unlock(&pds_vfio->reset_mutex);
return;
@@ -194,7 +195,6 @@ static int pds_vfio_open_device(struct vfio_device *vdev)
return err;
pds_vfio->state = VFIO_DEVICE_STATE_RUNNING;
- pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING;
vfio_pci_core_finish_enable(&pds_vfio->vfio_coredev);
@@ -10,6 +10,11 @@
#include "dirty.h"
#include "lm.h"
+enum pds_vfio_reset_type {
+ PDS_VFIO_HOST_RESET = 0,
+ PDS_VFIO_DEVICE_RESET = 1,
+};
+
struct pds_vfio_pci_device {
struct vfio_pci_core_device vfio_coredev;
@@ -20,7 +25,7 @@ struct pds_vfio_pci_device {
enum vfio_device_mig_state state;
struct mutex reset_mutex; /* protect reset_done flow */
u8 deferred_reset;
- enum vfio_device_mig_state deferred_reset_state;
+ enum pds_vfio_reset_type deferred_reset_type;
struct notifier_block nb;
int vf_id;