Lines Matching refs:mvdev
392 struct mlx5vf_pci_core_device *mvdev = migf->mvdev; in mlx5vf_precopy_ioctl() local
412 mutex_lock(&mvdev->state_mutex); in mlx5vf_precopy_ioctl()
413 if (mvdev->mig_state != VFIO_DEVICE_STATE_PRE_COPY && in mlx5vf_precopy_ioctl()
414 mvdev->mig_state != VFIO_DEVICE_STATE_PRE_COPY_P2P) { in mlx5vf_precopy_ioctl()
424 if (mvdev->mig_state == VFIO_DEVICE_STATE_PRE_COPY) { in mlx5vf_precopy_ioctl()
430 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, &inc_length, in mlx5vf_precopy_ioctl()
468 ret = mlx5vf_cmd_save_vhca_state(mvdev, migf, buf, true, true); in mlx5vf_precopy_ioctl()
476 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_precopy_ioctl()
484 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_precopy_ioctl()
498 static int mlx5vf_pci_save_device_inc_data(struct mlx5vf_pci_core_device *mvdev) in mlx5vf_pci_save_device_inc_data() argument
500 struct mlx5_vf_migration_file *migf = mvdev->saving_migf; in mlx5vf_pci_save_device_inc_data()
508 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, &length, in mlx5vf_pci_save_device_inc_data()
525 ret = mlx5vf_cmd_save_vhca_state(mvdev, migf, buf, true, false); in mlx5vf_pci_save_device_inc_data()
539 mlx5vf_pci_save_device_data(struct mlx5vf_pci_core_device *mvdev, bool track) in mlx5vf_pci_save_device_data() argument
557 migf->mvdev = mvdev; in mlx5vf_pci_save_device_data()
572 mlx5_cmd_init_async_ctx(mvdev->mdev, &migf->async_ctx); in mlx5vf_pci_save_device_data()
577 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, &length, 0); in mlx5vf_pci_save_device_data()
593 ret = mlx5vf_cmd_save_vhca_state(mvdev, migf, buf, false, track); in mlx5vf_pci_save_device_data()
838 mutex_lock(&migf->mvdev->state_mutex); in mlx5vf_resume_write()
917 ret = mlx5vf_cmd_load_vhca_state(migf->mvdev, migf, vhca_buf); in mlx5vf_resume_write()
937 mlx5vf_state_mutex_unlock(migf->mvdev); in mlx5vf_resume_write()
949 mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev) in mlx5vf_pci_resume_device_data() argument
966 migf->mvdev = mvdev; in mlx5vf_pci_resume_device_data()
978 if (MLX5VF_PRE_COPY_SUPP(mvdev)) { in mlx5vf_pci_resume_device_data()
1010 void mlx5vf_disable_fds(struct mlx5vf_pci_core_device *mvdev) in mlx5vf_disable_fds() argument
1012 if (mvdev->resuming_migf) { in mlx5vf_disable_fds()
1013 mlx5vf_disable_fd(mvdev->resuming_migf); in mlx5vf_disable_fds()
1014 mlx5fv_cmd_clean_migf_resources(mvdev->resuming_migf); in mlx5vf_disable_fds()
1015 fput(mvdev->resuming_migf->filp); in mlx5vf_disable_fds()
1016 mvdev->resuming_migf = NULL; in mlx5vf_disable_fds()
1018 if (mvdev->saving_migf) { in mlx5vf_disable_fds()
1019 mlx5_cmd_cleanup_async_ctx(&mvdev->saving_migf->async_ctx); in mlx5vf_disable_fds()
1020 cancel_work_sync(&mvdev->saving_migf->async_data.work); in mlx5vf_disable_fds()
1021 mlx5vf_disable_fd(mvdev->saving_migf); in mlx5vf_disable_fds()
1022 mlx5fv_cmd_clean_migf_resources(mvdev->saving_migf); in mlx5vf_disable_fds()
1023 fput(mvdev->saving_migf->filp); in mlx5vf_disable_fds()
1024 mvdev->saving_migf = NULL; in mlx5vf_disable_fds()
1029 mlx5vf_pci_step_device_state_locked(struct mlx5vf_pci_core_device *mvdev, in mlx5vf_pci_step_device_state_locked() argument
1032 u32 cur = mvdev->mig_state; in mlx5vf_pci_step_device_state_locked()
1036 ret = mlx5vf_cmd_suspend_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1044 ret = mlx5vf_cmd_resume_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1053 ret = mlx5vf_cmd_suspend_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1062 ret = mlx5vf_cmd_resume_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1072 migf = mlx5vf_pci_save_device_data(mvdev, false); in mlx5vf_pci_step_device_state_locked()
1076 mvdev->saving_migf = migf; in mlx5vf_pci_step_device_state_locked()
1084 mlx5vf_disable_fds(mvdev); in mlx5vf_pci_step_device_state_locked()
1091 migf = mlx5vf_pci_resume_device_data(mvdev); in mlx5vf_pci_step_device_state_locked()
1095 mvdev->resuming_migf = migf; in mlx5vf_pci_step_device_state_locked()
1100 if (!MLX5VF_PRE_COPY_SUPP(mvdev)) { in mlx5vf_pci_step_device_state_locked()
1101 ret = mlx5vf_cmd_load_vhca_state(mvdev, in mlx5vf_pci_step_device_state_locked()
1102 mvdev->resuming_migf, in mlx5vf_pci_step_device_state_locked()
1103 mvdev->resuming_migf->buf); in mlx5vf_pci_step_device_state_locked()
1107 mlx5vf_disable_fds(mvdev); in mlx5vf_pci_step_device_state_locked()
1116 migf = mlx5vf_pci_save_device_data(mvdev, true); in mlx5vf_pci_step_device_state_locked()
1120 mvdev->saving_migf = migf; in mlx5vf_pci_step_device_state_locked()
1125 ret = mlx5vf_cmd_suspend_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1129 ret = mlx5vf_pci_save_device_inc_data(mvdev); in mlx5vf_pci_step_device_state_locked()
1144 void mlx5vf_state_mutex_unlock(struct mlx5vf_pci_core_device *mvdev) in mlx5vf_state_mutex_unlock() argument
1147 spin_lock(&mvdev->reset_lock); in mlx5vf_state_mutex_unlock()
1148 if (mvdev->deferred_reset) { in mlx5vf_state_mutex_unlock()
1149 mvdev->deferred_reset = false; in mlx5vf_state_mutex_unlock()
1150 spin_unlock(&mvdev->reset_lock); in mlx5vf_state_mutex_unlock()
1151 mvdev->mig_state = VFIO_DEVICE_STATE_RUNNING; in mlx5vf_state_mutex_unlock()
1152 mlx5vf_disable_fds(mvdev); in mlx5vf_state_mutex_unlock()
1155 mutex_unlock(&mvdev->state_mutex); in mlx5vf_state_mutex_unlock()
1156 spin_unlock(&mvdev->reset_lock); in mlx5vf_state_mutex_unlock()
1163 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_set_device_state() local
1169 mutex_lock(&mvdev->state_mutex); in mlx5vf_pci_set_device_state()
1170 while (new_state != mvdev->mig_state) { in mlx5vf_pci_set_device_state()
1171 ret = vfio_mig_get_next_state(vdev, mvdev->mig_state, in mlx5vf_pci_set_device_state()
1177 res = mlx5vf_pci_step_device_state_locked(mvdev, next_state); in mlx5vf_pci_set_device_state()
1180 mvdev->mig_state = next_state; in mlx5vf_pci_set_device_state()
1181 if (WARN_ON(res && new_state != mvdev->mig_state)) { in mlx5vf_pci_set_device_state()
1187 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_pci_set_device_state()
1194 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_get_data_size() local
1199 mutex_lock(&mvdev->state_mutex); in mlx5vf_pci_get_data_size()
1200 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, in mlx5vf_pci_get_data_size()
1204 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_pci_get_data_size()
1211 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_get_device_state() local
1214 mutex_lock(&mvdev->state_mutex); in mlx5vf_pci_get_device_state()
1215 *curr_state = mvdev->mig_state; in mlx5vf_pci_get_device_state()
1216 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_pci_get_device_state()
1222 struct mlx5vf_pci_core_device *mvdev = mlx5vf_drvdata(pdev); in mlx5vf_pci_aer_reset_done() local
1224 if (!mvdev->migrate_cap) in mlx5vf_pci_aer_reset_done()
1234 spin_lock(&mvdev->reset_lock); in mlx5vf_pci_aer_reset_done()
1235 mvdev->deferred_reset = true; in mlx5vf_pci_aer_reset_done()
1236 if (!mutex_trylock(&mvdev->state_mutex)) { in mlx5vf_pci_aer_reset_done()
1237 spin_unlock(&mvdev->reset_lock); in mlx5vf_pci_aer_reset_done()
1240 spin_unlock(&mvdev->reset_lock); in mlx5vf_pci_aer_reset_done()
1241 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_pci_aer_reset_done()
1246 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_open_device() local
1248 struct vfio_pci_core_device *vdev = &mvdev->core_device; in mlx5vf_pci_open_device()
1255 if (mvdev->migrate_cap) in mlx5vf_pci_open_device()
1256 mvdev->mig_state = VFIO_DEVICE_STATE_RUNNING; in mlx5vf_pci_open_device()
1263 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_close_device() local
1266 mlx5vf_cmd_close_migratable(mvdev); in mlx5vf_pci_close_device()
1284 struct mlx5vf_pci_core_device *mvdev = container_of(core_vdev, in mlx5vf_pci_init_dev() local
1292 mlx5vf_cmd_set_migratable(mvdev, &mlx5vf_pci_mig_ops, in mlx5vf_pci_init_dev()
1300 struct mlx5vf_pci_core_device *mvdev = container_of(core_vdev, in mlx5vf_pci_release_dev() local
1303 mlx5vf_cmd_remove_migratable(mvdev); in mlx5vf_pci_release_dev()
1329 struct mlx5vf_pci_core_device *mvdev; in mlx5vf_pci_probe() local
1332 mvdev = vfio_alloc_device(mlx5vf_pci_core_device, core_device.vdev, in mlx5vf_pci_probe()
1334 if (IS_ERR(mvdev)) in mlx5vf_pci_probe()
1335 return PTR_ERR(mvdev); in mlx5vf_pci_probe()
1337 dev_set_drvdata(&pdev->dev, &mvdev->core_device); in mlx5vf_pci_probe()
1338 ret = vfio_pci_core_register_device(&mvdev->core_device); in mlx5vf_pci_probe()
1344 vfio_put_device(&mvdev->core_device.vdev); in mlx5vf_pci_probe()
1350 struct mlx5vf_pci_core_device *mvdev = mlx5vf_drvdata(pdev); in mlx5vf_pci_remove() local
1352 vfio_pci_core_unregister_device(&mvdev->core_device); in mlx5vf_pci_remove()
1353 vfio_put_device(&mvdev->core_device.vdev); in mlx5vf_pci_remove()