Lines Matching refs:migf
783 static void mtty_disable_file(struct mtty_migration_file *migf) in mtty_disable_file() argument
785 mutex_lock(&migf->lock); in mtty_disable_file()
786 migf->disabled = true; in mtty_disable_file()
787 migf->filled_size = 0; in mtty_disable_file()
788 migf->filp->f_pos = 0; in mtty_disable_file()
789 mutex_unlock(&migf->lock); in mtty_disable_file()
824 struct mtty_migration_file *migf = filp->private_data; in mtty_release_migf() local
826 mtty_disable_file(migf); in mtty_release_migf()
827 mutex_destroy(&migf->lock); in mtty_release_migf()
828 kfree(migf); in mtty_release_migf()
836 struct mtty_migration_file *migf = filp->private_data; in mtty_precopy_ioctl() local
837 struct mdev_state *mdev_state = migf->mdev_state; in mtty_precopy_ioctl()
860 mutex_lock(&migf->lock); in mtty_precopy_ioctl()
862 if (migf->disabled) { in mtty_precopy_ioctl()
863 mutex_unlock(&migf->lock); in mtty_precopy_ioctl()
868 if (*pos > migf->filled_size) { in mtty_precopy_ioctl()
869 mutex_unlock(&migf->lock); in mtty_precopy_ioctl()
875 info.initial_bytes = migf->filled_size - *pos; in mtty_precopy_ioctl()
876 mutex_unlock(&migf->lock); in mtty_precopy_ioctl()
887 struct mtty_migration_file *migf = filp->private_data; in mtty_save_read() local
895 mutex_lock(&migf->lock); in mtty_save_read()
897 dev_dbg(migf->mdev_state->vdev.dev, "%s ask %zu\n", __func__, len); in mtty_save_read()
899 if (migf->disabled) { in mtty_save_read()
904 if (*pos > migf->filled_size) { in mtty_save_read()
909 len = min_t(size_t, migf->filled_size - *pos, len); in mtty_save_read()
911 if (copy_to_user(buf, (void *)&migf->data + *pos, len)) { in mtty_save_read()
919 dev_dbg(migf->mdev_state->vdev.dev, "%s read %zu\n", __func__, ret); in mtty_save_read()
920 mutex_unlock(&migf->lock); in mtty_save_read()
934 struct mtty_migration_file *migf = mdev_state->saving_migf; in mtty_save_state() local
937 mutex_lock(&migf->lock); in mtty_save_state()
939 memcpy(&migf->data.ports[i], in mtty_save_state()
941 migf->filled_size += sizeof(struct serial_port); in mtty_save_state()
944 "%s filled to %zu\n", __func__, migf->filled_size); in mtty_save_state()
945 mutex_unlock(&migf->lock); in mtty_save_state()
950 struct mtty_migration_file *migf = mdev_state->resuming_migf; in mtty_load_state() local
953 mutex_lock(&migf->lock); in mtty_load_state()
955 if (migf->filled_size < mtty_data_size(mdev_state)) { in mtty_load_state()
958 migf->filled_size); in mtty_load_state()
959 mutex_unlock(&migf->lock); in mtty_load_state()
965 &migf->data.ports[i], sizeof(struct serial_port)); in mtty_load_state()
967 mutex_unlock(&migf->lock); in mtty_load_state()
975 struct mtty_migration_file *migf = mdev_state->saving_migf; in mtty_save_device_data() local
978 if (migf) { in mtty_save_device_data()
984 migf = kzalloc(sizeof(*migf), GFP_KERNEL_ACCOUNT); in mtty_save_device_data()
985 if (!migf) in mtty_save_device_data()
988 migf->filp = anon_inode_getfile("mtty_mig", &mtty_save_fops, in mtty_save_device_data()
989 migf, O_RDONLY); in mtty_save_device_data()
990 if (IS_ERR(migf->filp)) { in mtty_save_device_data()
991 int rc = PTR_ERR(migf->filp); in mtty_save_device_data()
993 kfree(migf); in mtty_save_device_data()
997 stream_open(migf->filp->f_inode, migf->filp); in mtty_save_device_data()
998 mutex_init(&migf->lock); in mtty_save_device_data()
999 migf->mdev_state = mdev_state; in mtty_save_device_data()
1001 migf->data.magic = MTTY_MAGIC; in mtty_save_device_data()
1002 migf->data.major_ver = MTTY_MAJOR_VER; in mtty_save_device_data()
1003 migf->data.minor_ver = MTTY_MINOR_VER; in mtty_save_device_data()
1004 migf->data.nr_ports = mdev_state->nr_ports; in mtty_save_device_data()
1006 migf->filled_size = offsetof(struct mtty_data, ports); in mtty_save_device_data()
1009 __func__, migf->filled_size); in mtty_save_device_data()
1011 ret = mdev_state->saving_migf = migf; in mtty_save_device_data()
1023 struct mtty_migration_file *migf = filp->private_data; in mtty_resume_write() local
1024 struct mdev_state *mdev_state = migf->mdev_state; in mtty_resume_write()
1040 mutex_lock(&migf->lock); in mtty_resume_write()
1042 if (migf->disabled) { in mtty_resume_write()
1047 if (copy_from_user((void *)&migf->data + *pos, buf, len)) { in mtty_resume_write()
1055 dev_dbg(migf->mdev_state->vdev.dev, "%s received %zu, total %zu\n", in mtty_resume_write()
1056 __func__, len, migf->filled_size + len); in mtty_resume_write()
1058 if (migf->filled_size < offsetof(struct mtty_data, ports) && in mtty_resume_write()
1059 migf->filled_size + len >= offsetof(struct mtty_data, ports)) { in mtty_resume_write()
1060 if (migf->data.magic != MTTY_MAGIC || migf->data.flags || in mtty_resume_write()
1061 migf->data.major_ver != MTTY_MAJOR_VER || in mtty_resume_write()
1062 migf->data.minor_ver != MTTY_MINOR_VER || in mtty_resume_write()
1063 migf->data.nr_ports != mdev_state->nr_ports) { in mtty_resume_write()
1064 dev_dbg(migf->mdev_state->vdev.dev, in mtty_resume_write()
1068 dev_dbg(migf->mdev_state->vdev.dev, in mtty_resume_write()
1073 migf->filled_size += len; in mtty_resume_write()
1076 mutex_unlock(&migf->lock); in mtty_resume_write()
1089 struct mtty_migration_file *migf; in mtty_resume_device_data() local
1092 migf = kzalloc(sizeof(*migf), GFP_KERNEL_ACCOUNT); in mtty_resume_device_data()
1093 if (!migf) in mtty_resume_device_data()
1096 migf->filp = anon_inode_getfile("mtty_mig", &mtty_resume_fops, in mtty_resume_device_data()
1097 migf, O_WRONLY); in mtty_resume_device_data()
1098 if (IS_ERR(migf->filp)) { in mtty_resume_device_data()
1099 ret = PTR_ERR(migf->filp); in mtty_resume_device_data()
1100 kfree(migf); in mtty_resume_device_data()
1104 stream_open(migf->filp->f_inode, migf->filp); in mtty_resume_device_data()
1105 mutex_init(&migf->lock); in mtty_resume_device_data()
1106 migf->mdev_state = mdev_state; in mtty_resume_device_data()
1108 mdev_state->resuming_migf = migf; in mtty_resume_device_data()
1110 return migf; in mtty_resume_device_data()
1192 struct mtty_migration_file *migf; in mtty_step_state() local
1194 migf = mtty_save_device_data(mdev_state, new); in mtty_step_state()
1195 if (IS_ERR(migf)) in mtty_step_state()
1196 return ERR_CAST(migf); in mtty_step_state()
1198 if (migf) { in mtty_step_state()
1199 get_file(migf->filp); in mtty_step_state()
1201 return migf->filp; in mtty_step_state()
1208 struct mtty_migration_file *migf; in mtty_step_state() local
1210 migf = mtty_resume_device_data(mdev_state); in mtty_step_state()
1211 if (IS_ERR(migf)) in mtty_step_state()
1212 return ERR_CAST(migf); in mtty_step_state()
1214 get_file(migf->filp); in mtty_step_state()
1216 return migf->filp; in mtty_step_state()