| @@ -29,7 +29,7 @@ struct pds_vfio_pci_device *pds_vfio_pci_drvdata(struct pci_dev *pdev) · 28 unmodified lines |
| 29 | void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio) | 29 | void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio) |
| 30 | { | 30 | { |
| 31 | again: | 31 | again: |
| 32 | spin_lock(&pds_vfio->reset_lock); | 32 | mutex_lock(&pds_vfio->reset_mutex); |
| 33 | if (pds_vfio->deferred_reset) { | 33 | if (pds_vfio->deferred_reset) { |
| 34 | pds_vfio->deferred_reset = false; | 34 | pds_vfio->deferred_reset = false; |
| 35 | if (pds_vfio->state == VFIO_DEVICE_STATE_ERROR) { | 35 | if (pds_vfio->state == VFIO_DEVICE_STATE_ERROR) { |
| @@ -39,23 +39,23 @@ again: · 3 unmodified lines |
| 39 | } | 39 | } |
| 40 | pds_vfio->state = pds_vfio->deferred_reset_state; | 40 | pds_vfio->state = pds_vfio->deferred_reset_state; |
| 41 | pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING; | 41 | pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING; |
| 42 | spin_unlock(&pds_vfio->reset_lock); | 42 | mutex_unlock(&pds_vfio->reset_mutex); |
| 43 | goto again; | 43 | goto again; |
| 44 | } | 44 | } |
| 45 | mutex_unlock(&pds_vfio->state_mutex); | 45 | mutex_unlock(&pds_vfio->state_mutex); |
| 46 | spin_unlock(&pds_vfio->reset_lock); | 46 | mutex_unlock(&pds_vfio->reset_mutex); |
| 47 | } | 47 | } |
| 48 | | 48 | |
| 49 | void pds_vfio_reset(struct pds_vfio_pci_device *pds_vfio) | 49 | void pds_vfio_reset(struct pds_vfio_pci_device *pds_vfio) |
| 50 | { | 50 | { |
| 51 | spin_lock(&pds_vfio->reset_lock); | 51 | mutex_lock(&pds_vfio->reset_mutex); |
| 52 | pds_vfio->deferred_reset = true; | 52 | pds_vfio->deferred_reset = true; |
| 53 | pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING; | 53 | pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING; |
| 54 | if (!mutex_trylock(&pds_vfio->state_mutex)) { | 54 | if (!mutex_trylock(&pds_vfio->state_mutex)) { |
| 55 | spin_unlock(&pds_vfio->reset_lock); | 55 | mutex_unlock(&pds_vfio->reset_mutex); |
| 56 | return; | 56 | return; |
| 57 | } | 57 | } |
| 58 | spin_unlock(&pds_vfio->reset_lock); | 58 | mutex_unlock(&pds_vfio->reset_mutex); |
| 59 | pds_vfio_state_mutex_unlock(pds_vfio); | 59 | pds_vfio_state_mutex_unlock(pds_vfio); |
| 60 | } | 60 | } |
| 61 | | 61 | |
| @@ -156,6 +156,7 @@ static int pds_vfio_init_device(struct vfio_device *vdev) · 94 unmodified lines |
| 156 | pds_vfio->vf_id = vf_id; | 156 | pds_vfio->vf_id = vf_id; |
| 157 | | 157 | |
| 158 | mutex_init(&pds_vfio->state_mutex); | 158 | mutex_init(&pds_vfio->state_mutex); |
| | 159 | mutex_init(&pds_vfio->reset_mutex); |
| 159 | | 160 | |
| 160 | vdev->migration_flags = VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P; | 161 | vdev->migration_flags = VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P; |
| 161 | vdev->mig_ops = &pds_vfio_lm_ops; | 162 | vdev->mig_ops = &pds_vfio_lm_ops; |
| @@ -177,6 +178,7 @@ static void pds_vfio_release_device(struct vfio_device *vdev) · 15 unmodified lines |
| 177 | vfio_coredev.vdev); | 178 | vfio_coredev.vdev); |
| 178 | | 179 | |
| 179 | mutex_destroy(&pds_vfio->state_mutex); | 180 | mutex_destroy(&pds_vfio->state_mutex); |
| | 181 | mutex_destroy(&pds_vfio->reset_mutex); |
| 180 | vfio_pci_core_release_dev(vdev); | 182 | vfio_pci_core_release_dev(vdev); |
| 181 | } | 183 | } |
| 182 | | 184 | |