Commit 9114100d authored by Yishai Hadas's avatar Yishai Hadas Committed by Alex Williamson

vfio/mlx5: Rename some stuff to match chunk mode

Upon chunk mode there may be multiple images that will be read from the
device upon STOP_COPY.

This patch is some preparation for that mode by replacing the relevant
stuff to a better matching name.

As part of that, be stricter to recognize PRE_COPY error only when it
didn't occur on a STOP_COPY chunk.
Signed-off-by: default avatarYishai Hadas <yishaih@nvidia.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20230911093856.81910-6-yishaih@nvidia.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 543640af
...@@ -503,7 +503,8 @@ void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work) ...@@ -503,7 +503,8 @@ void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work)
mlx5vf_put_data_buffer(async_data->buf); mlx5vf_put_data_buffer(async_data->buf);
if (async_data->header_buf) if (async_data->header_buf)
mlx5vf_put_data_buffer(async_data->header_buf); mlx5vf_put_data_buffer(async_data->header_buf);
if (async_data->status == MLX5_CMD_STAT_BAD_RES_STATE_ERR) if (!async_data->stop_copy_chunk &&
async_data->status == MLX5_CMD_STAT_BAD_RES_STATE_ERR)
migf->state = MLX5_MIGF_STATE_PRE_COPY_ERROR; migf->state = MLX5_MIGF_STATE_PRE_COPY_ERROR;
else else
migf->state = MLX5_MIGF_STATE_ERROR; migf->state = MLX5_MIGF_STATE_ERROR;
...@@ -553,7 +554,7 @@ static void mlx5vf_save_callback(int status, struct mlx5_async_work *context) ...@@ -553,7 +554,7 @@ static void mlx5vf_save_callback(int status, struct mlx5_async_work *context)
size_t image_size; size_t image_size;
unsigned long flags; unsigned long flags;
bool initial_pre_copy = migf->state != MLX5_MIGF_STATE_PRE_COPY && bool initial_pre_copy = migf->state != MLX5_MIGF_STATE_PRE_COPY &&
!async_data->last_chunk; !async_data->stop_copy_chunk;
image_size = MLX5_GET(save_vhca_state_out, async_data->out, image_size = MLX5_GET(save_vhca_state_out, async_data->out,
actual_image_size); actual_image_size);
...@@ -571,7 +572,7 @@ static void mlx5vf_save_callback(int status, struct mlx5_async_work *context) ...@@ -571,7 +572,7 @@ static void mlx5vf_save_callback(int status, struct mlx5_async_work *context)
spin_unlock_irqrestore(&migf->list_lock, flags); spin_unlock_irqrestore(&migf->list_lock, flags);
if (initial_pre_copy) if (initial_pre_copy)
migf->pre_copy_initial_bytes += image_size; migf->pre_copy_initial_bytes += image_size;
migf->state = async_data->last_chunk ? migf->state = async_data->stop_copy_chunk ?
MLX5_MIGF_STATE_COMPLETE : MLX5_MIGF_STATE_PRE_COPY; MLX5_MIGF_STATE_COMPLETE : MLX5_MIGF_STATE_PRE_COPY;
wake_up_interruptible(&migf->poll_wait); wake_up_interruptible(&migf->poll_wait);
mlx5vf_save_callback_complete(migf, async_data); mlx5vf_save_callback_complete(migf, async_data);
...@@ -623,7 +624,7 @@ int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev, ...@@ -623,7 +624,7 @@ int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev,
async_data = &migf->async_data; async_data = &migf->async_data;
async_data->buf = buf; async_data->buf = buf;
async_data->last_chunk = !track; async_data->stop_copy_chunk = !track;
async_data->out = kvzalloc(out_size, GFP_KERNEL); async_data->out = kvzalloc(out_size, GFP_KERNEL);
if (!async_data->out) { if (!async_data->out) {
err = -ENOMEM; err = -ENOMEM;
...@@ -631,7 +632,7 @@ int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev, ...@@ -631,7 +632,7 @@ int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev,
} }
if (MLX5VF_PRE_COPY_SUPP(mvdev)) { if (MLX5VF_PRE_COPY_SUPP(mvdev)) {
if (async_data->last_chunk && migf->buf_header) { if (async_data->stop_copy_chunk && migf->buf_header) {
header_buf = migf->buf_header; header_buf = migf->buf_header;
migf->buf_header = NULL; migf->buf_header = NULL;
} else { } else {
...@@ -644,8 +645,8 @@ int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev, ...@@ -644,8 +645,8 @@ int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev,
} }
} }
if (async_data->last_chunk) if (async_data->stop_copy_chunk)
migf->state = MLX5_MIGF_STATE_SAVE_LAST; migf->state = MLX5_MIGF_STATE_SAVE_STOP_COPY_CHUNK;
async_data->header_buf = header_buf; async_data->header_buf = header_buf;
get_file(migf->filp); get_file(migf->filp);
......
...@@ -20,7 +20,7 @@ enum mlx5_vf_migf_state { ...@@ -20,7 +20,7 @@ enum mlx5_vf_migf_state {
MLX5_MIGF_STATE_ERROR = 1, MLX5_MIGF_STATE_ERROR = 1,
MLX5_MIGF_STATE_PRE_COPY_ERROR, MLX5_MIGF_STATE_PRE_COPY_ERROR,
MLX5_MIGF_STATE_PRE_COPY, MLX5_MIGF_STATE_PRE_COPY,
MLX5_MIGF_STATE_SAVE_LAST, MLX5_MIGF_STATE_SAVE_STOP_COPY_CHUNK,
MLX5_MIGF_STATE_COMPLETE, MLX5_MIGF_STATE_COMPLETE,
}; };
...@@ -78,7 +78,7 @@ struct mlx5vf_async_data { ...@@ -78,7 +78,7 @@ struct mlx5vf_async_data {
struct mlx5_vhca_data_buffer *buf; struct mlx5_vhca_data_buffer *buf;
struct mlx5_vhca_data_buffer *header_buf; struct mlx5_vhca_data_buffer *header_buf;
int status; int status;
u8 last_chunk:1; u8 stop_copy_chunk:1;
void *out; void *out;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment