Skip to content

Commit 9114100

Browse files
Yishai Hadasawilliam
authored andcommitted
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: Yishai Hadas <yishaih@nvidia.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20230911093856.81910-6-yishaih@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 543640a commit 9114100

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

drivers/vfio/pci/mlx5/cmd.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work)
503503
mlx5vf_put_data_buffer(async_data->buf);
504504
if (async_data->header_buf)
505505
mlx5vf_put_data_buffer(async_data->header_buf);
506-
if (async_data->status == MLX5_CMD_STAT_BAD_RES_STATE_ERR)
506+
if (!async_data->stop_copy_chunk &&
507+
async_data->status == MLX5_CMD_STAT_BAD_RES_STATE_ERR)
507508
migf->state = MLX5_MIGF_STATE_PRE_COPY_ERROR;
508509
else
509510
migf->state = MLX5_MIGF_STATE_ERROR;
@@ -553,7 +554,7 @@ static void mlx5vf_save_callback(int status, struct mlx5_async_work *context)
553554
size_t image_size;
554555
unsigned long flags;
555556
bool initial_pre_copy = migf->state != MLX5_MIGF_STATE_PRE_COPY &&
556-
!async_data->last_chunk;
557+
!async_data->stop_copy_chunk;
557558

558559
image_size = MLX5_GET(save_vhca_state_out, async_data->out,
559560
actual_image_size);
@@ -571,7 +572,7 @@ static void mlx5vf_save_callback(int status, struct mlx5_async_work *context)
571572
spin_unlock_irqrestore(&migf->list_lock, flags);
572573
if (initial_pre_copy)
573574
migf->pre_copy_initial_bytes += image_size;
574-
migf->state = async_data->last_chunk ?
575+
migf->state = async_data->stop_copy_chunk ?
575576
MLX5_MIGF_STATE_COMPLETE : MLX5_MIGF_STATE_PRE_COPY;
576577
wake_up_interruptible(&migf->poll_wait);
577578
mlx5vf_save_callback_complete(migf, async_data);
@@ -623,15 +624,15 @@ int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev,
623624

624625
async_data = &migf->async_data;
625626
async_data->buf = buf;
626-
async_data->last_chunk = !track;
627+
async_data->stop_copy_chunk = !track;
627628
async_data->out = kvzalloc(out_size, GFP_KERNEL);
628629
if (!async_data->out) {
629630
err = -ENOMEM;
630631
goto err_out;
631632
}
632633

633634
if (MLX5VF_PRE_COPY_SUPP(mvdev)) {
634-
if (async_data->last_chunk && migf->buf_header) {
635+
if (async_data->stop_copy_chunk && migf->buf_header) {
635636
header_buf = migf->buf_header;
636637
migf->buf_header = NULL;
637638
} else {
@@ -644,8 +645,8 @@ int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev,
644645
}
645646
}
646647

647-
if (async_data->last_chunk)
648-
migf->state = MLX5_MIGF_STATE_SAVE_LAST;
648+
if (async_data->stop_copy_chunk)
649+
migf->state = MLX5_MIGF_STATE_SAVE_STOP_COPY_CHUNK;
649650

650651
async_data->header_buf = header_buf;
651652
get_file(migf->filp);

drivers/vfio/pci/mlx5/cmd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enum mlx5_vf_migf_state {
2020
MLX5_MIGF_STATE_ERROR = 1,
2121
MLX5_MIGF_STATE_PRE_COPY_ERROR,
2222
MLX5_MIGF_STATE_PRE_COPY,
23-
MLX5_MIGF_STATE_SAVE_LAST,
23+
MLX5_MIGF_STATE_SAVE_STOP_COPY_CHUNK,
2424
MLX5_MIGF_STATE_COMPLETE,
2525
};
2626

@@ -78,7 +78,7 @@ struct mlx5vf_async_data {
7878
struct mlx5_vhca_data_buffer *buf;
7979
struct mlx5_vhca_data_buffer *header_buf;
8080
int status;
81-
u8 last_chunk:1;
81+
u8 stop_copy_chunk:1;
8282
void *out;
8383
};
8484

0 commit comments

Comments
 (0)