Lines Matching refs:mvdev

272 	queue_work(migf->mvdev->cb_wq,  in mlx5vf_mig_file_set_save_work()
305 struct mlx5vf_pci_core_device *mvdev = migf->mvdev; in mlx5vf_mig_file_save_work() local
308 mutex_lock(&mvdev->state_mutex); in mlx5vf_mig_file_save_work()
318 if (mlx5vf_cmd_save_vhca_state(mvdev, migf, buf, true, false)) in mlx5vf_mig_file_save_work()
328 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_mig_file_save_work()
378 static int mlx5vf_prep_stop_copy(struct mlx5vf_pci_core_device *mvdev, in mlx5vf_prep_stop_copy() argument
389 if (mvdev->chunk_mode) { in mlx5vf_prep_stop_copy()
408 num_chunks = mvdev->chunk_mode ? MAX_NUM_CHUNKS : 1; in mlx5vf_prep_stop_copy()
429 if (mvdev->chunk_mode) { in mlx5vf_prep_stop_copy()
462 struct mlx5vf_pci_core_device *mvdev = migf->mvdev; in mlx5vf_precopy_ioctl() local
482 mutex_lock(&mvdev->state_mutex); in mlx5vf_precopy_ioctl()
483 if (mvdev->mig_state != VFIO_DEVICE_STATE_PRE_COPY && in mlx5vf_precopy_ioctl()
484 mvdev->mig_state != VFIO_DEVICE_STATE_PRE_COPY_P2P) { in mlx5vf_precopy_ioctl()
494 if (mvdev->mig_state == VFIO_DEVICE_STATE_PRE_COPY) { in mlx5vf_precopy_ioctl()
500 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, &inc_length, in mlx5vf_precopy_ioctl()
539 ret = mlx5vf_cmd_save_vhca_state(mvdev, migf, buf, true, true); in mlx5vf_precopy_ioctl()
547 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_precopy_ioctl()
555 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_precopy_ioctl()
568 static int mlx5vf_pci_save_device_inc_data(struct mlx5vf_pci_core_device *mvdev) in mlx5vf_pci_save_device_inc_data() argument
570 struct mlx5_vf_migration_file *migf = mvdev->saving_migf; in mlx5vf_pci_save_device_inc_data()
578 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, &length, NULL, in mlx5vf_pci_save_device_inc_data()
589 ret = mlx5vf_cmd_save_vhca_state(mvdev, migf, buf, true, false); in mlx5vf_pci_save_device_inc_data()
603 mlx5vf_pci_save_device_data(struct mlx5vf_pci_core_device *mvdev, bool track) in mlx5vf_pci_save_device_data() argument
623 migf->mvdev = mvdev; in mlx5vf_pci_save_device_data()
634 mlx5_cmd_init_async_ctx(mvdev->mdev, &migf->async_ctx); in mlx5vf_pci_save_device_data()
644 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, &length, &full_size, 0); in mlx5vf_pci_save_device_data()
648 ret = mlx5vf_prep_stop_copy(mvdev, migf, length, full_size, track); in mlx5vf_pci_save_device_data()
665 ret = mlx5vf_cmd_save_vhca_state(mvdev, migf, buf, false, track); in mlx5vf_pci_save_device_data()
878 mutex_lock(&migf->mvdev->state_mutex); in mlx5vf_resume_write()
955 ret = mlx5vf_cmd_load_vhca_state(migf->mvdev, migf, vhca_buf); in mlx5vf_resume_write()
975 mlx5vf_state_mutex_unlock(migf->mvdev); in mlx5vf_resume_write()
986 mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev) in mlx5vf_pci_resume_device_data() argument
1009 migf->mvdev = mvdev; in mlx5vf_pci_resume_device_data()
1044 void mlx5vf_disable_fds(struct mlx5vf_pci_core_device *mvdev, in mlx5vf_disable_fds() argument
1047 if (mvdev->resuming_migf) { in mlx5vf_disable_fds()
1048 mlx5vf_disable_fd(mvdev->resuming_migf); in mlx5vf_disable_fds()
1049 mlx5fv_cmd_clean_migf_resources(mvdev->resuming_migf); in mlx5vf_disable_fds()
1050 fput(mvdev->resuming_migf->filp); in mlx5vf_disable_fds()
1051 mvdev->resuming_migf = NULL; in mlx5vf_disable_fds()
1053 if (mvdev->saving_migf) { in mlx5vf_disable_fds()
1054 mlx5_cmd_cleanup_async_ctx(&mvdev->saving_migf->async_ctx); in mlx5vf_disable_fds()
1055 cancel_work_sync(&mvdev->saving_migf->async_data.work); in mlx5vf_disable_fds()
1057 *last_save_state = mvdev->saving_migf->state; in mlx5vf_disable_fds()
1058 mlx5vf_disable_fd(mvdev->saving_migf); in mlx5vf_disable_fds()
1059 wake_up_interruptible(&mvdev->saving_migf->poll_wait); in mlx5vf_disable_fds()
1060 mlx5fv_cmd_clean_migf_resources(mvdev->saving_migf); in mlx5vf_disable_fds()
1061 fput(mvdev->saving_migf->filp); in mlx5vf_disable_fds()
1062 mvdev->saving_migf = NULL; in mlx5vf_disable_fds()
1067 mlx5vf_pci_step_device_state_locked(struct mlx5vf_pci_core_device *mvdev, in mlx5vf_pci_step_device_state_locked() argument
1070 u32 cur = mvdev->mig_state; in mlx5vf_pci_step_device_state_locked()
1074 ret = mlx5vf_cmd_suspend_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1082 ret = mlx5vf_cmd_resume_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1091 ret = mlx5vf_cmd_suspend_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1100 ret = mlx5vf_cmd_resume_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1110 migf = mlx5vf_pci_save_device_data(mvdev, false); in mlx5vf_pci_step_device_state_locked()
1114 mvdev->saving_migf = migf; in mlx5vf_pci_step_device_state_locked()
1119 mlx5vf_disable_fds(mvdev, NULL); in mlx5vf_pci_step_device_state_locked()
1126 struct mlx5_vf_migration_file *migf = mvdev->saving_migf; in mlx5vf_pci_step_device_state_locked()
1131 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, &size, NULL, in mlx5vf_pci_step_device_state_locked()
1140 ret = mlx5vf_cmd_save_vhca_state(mvdev, migf, buf, false, false); in mlx5vf_pci_step_device_state_locked()
1145 mlx5vf_disable_fds(mvdev, &state); in mlx5vf_pci_step_device_state_locked()
1152 migf = mlx5vf_pci_resume_device_data(mvdev); in mlx5vf_pci_step_device_state_locked()
1156 mvdev->resuming_migf = migf; in mlx5vf_pci_step_device_state_locked()
1161 mlx5vf_disable_fds(mvdev, NULL); in mlx5vf_pci_step_device_state_locked()
1170 migf = mlx5vf_pci_save_device_data(mvdev, true); in mlx5vf_pci_step_device_state_locked()
1174 mvdev->saving_migf = migf; in mlx5vf_pci_step_device_state_locked()
1179 ret = mlx5vf_cmd_suspend_vhca(mvdev, in mlx5vf_pci_step_device_state_locked()
1183 ret = mlx5vf_pci_save_device_inc_data(mvdev); in mlx5vf_pci_step_device_state_locked()
1198 void mlx5vf_state_mutex_unlock(struct mlx5vf_pci_core_device *mvdev) in mlx5vf_state_mutex_unlock() argument
1201 spin_lock(&mvdev->reset_lock); in mlx5vf_state_mutex_unlock()
1202 if (mvdev->deferred_reset) { in mlx5vf_state_mutex_unlock()
1203 mvdev->deferred_reset = false; in mlx5vf_state_mutex_unlock()
1204 spin_unlock(&mvdev->reset_lock); in mlx5vf_state_mutex_unlock()
1205 mvdev->mig_state = VFIO_DEVICE_STATE_RUNNING; in mlx5vf_state_mutex_unlock()
1206 mlx5vf_disable_fds(mvdev, NULL); in mlx5vf_state_mutex_unlock()
1209 mutex_unlock(&mvdev->state_mutex); in mlx5vf_state_mutex_unlock()
1210 spin_unlock(&mvdev->reset_lock); in mlx5vf_state_mutex_unlock()
1217 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_set_device_state() local
1223 mutex_lock(&mvdev->state_mutex); in mlx5vf_pci_set_device_state()
1224 while (new_state != mvdev->mig_state) { in mlx5vf_pci_set_device_state()
1225 ret = vfio_mig_get_next_state(vdev, mvdev->mig_state, in mlx5vf_pci_set_device_state()
1231 res = mlx5vf_pci_step_device_state_locked(mvdev, next_state); in mlx5vf_pci_set_device_state()
1234 mvdev->mig_state = next_state; in mlx5vf_pci_set_device_state()
1235 if (WARN_ON(res && new_state != mvdev->mig_state)) { in mlx5vf_pci_set_device_state()
1241 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_pci_set_device_state()
1248 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_get_data_size() local
1254 mutex_lock(&mvdev->state_mutex); in mlx5vf_pci_get_data_size()
1255 ret = mlx5vf_cmd_query_vhca_migration_state(mvdev, &state_size, in mlx5vf_pci_get_data_size()
1259 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_pci_get_data_size()
1266 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_get_device_state() local
1269 mutex_lock(&mvdev->state_mutex); in mlx5vf_pci_get_device_state()
1270 *curr_state = mvdev->mig_state; in mlx5vf_pci_get_device_state()
1271 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_pci_get_device_state()
1277 struct mlx5vf_pci_core_device *mvdev = mlx5vf_drvdata(pdev); in mlx5vf_pci_aer_reset_done() local
1279 if (!mvdev->migrate_cap) in mlx5vf_pci_aer_reset_done()
1289 spin_lock(&mvdev->reset_lock); in mlx5vf_pci_aer_reset_done()
1290 mvdev->deferred_reset = true; in mlx5vf_pci_aer_reset_done()
1291 if (!mutex_trylock(&mvdev->state_mutex)) { in mlx5vf_pci_aer_reset_done()
1292 spin_unlock(&mvdev->reset_lock); in mlx5vf_pci_aer_reset_done()
1295 spin_unlock(&mvdev->reset_lock); in mlx5vf_pci_aer_reset_done()
1296 mlx5vf_state_mutex_unlock(mvdev); in mlx5vf_pci_aer_reset_done()
1301 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_open_device() local
1303 struct vfio_pci_core_device *vdev = &mvdev->core_device; in mlx5vf_pci_open_device()
1310 if (mvdev->migrate_cap) in mlx5vf_pci_open_device()
1311 mvdev->mig_state = VFIO_DEVICE_STATE_RUNNING; in mlx5vf_pci_open_device()
1318 struct mlx5vf_pci_core_device *mvdev = container_of( in mlx5vf_pci_close_device() local
1321 mlx5vf_cmd_close_migratable(mvdev); in mlx5vf_pci_close_device()
1339 struct mlx5vf_pci_core_device *mvdev = container_of(core_vdev, in mlx5vf_pci_init_dev() local
1347 mlx5vf_cmd_set_migratable(mvdev, &mlx5vf_pci_mig_ops, in mlx5vf_pci_init_dev()
1355 struct mlx5vf_pci_core_device *mvdev = container_of(core_vdev, in mlx5vf_pci_release_dev() local
1358 mlx5vf_cmd_remove_migratable(mvdev); in mlx5vf_pci_release_dev()
1385 struct mlx5vf_pci_core_device *mvdev; in mlx5vf_pci_probe() local
1388 mvdev = vfio_alloc_device(mlx5vf_pci_core_device, core_device.vdev, in mlx5vf_pci_probe()
1390 if (IS_ERR(mvdev)) in mlx5vf_pci_probe()
1391 return PTR_ERR(mvdev); in mlx5vf_pci_probe()
1393 dev_set_drvdata(&pdev->dev, &mvdev->core_device); in mlx5vf_pci_probe()
1394 ret = vfio_pci_core_register_device(&mvdev->core_device); in mlx5vf_pci_probe()
1400 vfio_put_device(&mvdev->core_device.vdev); in mlx5vf_pci_probe()
1406 struct mlx5vf_pci_core_device *mvdev = mlx5vf_drvdata(pdev); in mlx5vf_pci_remove() local
1408 vfio_pci_core_unregister_device(&mvdev->core_device); in mlx5vf_pci_remove()
1409 vfio_put_device(&mvdev->core_device.vdev); in mlx5vf_pci_remove()