Commit 34a64c8e authored by Yishai Hadas's avatar Yishai Hadas Committed by Alex Williamson

vfio/mlx5: Refactor the SAVE callback to activate a work only upon an error

Upon a successful SAVE callback there is no need to activate a work, all
the required stuff can be done directly.

As so, refactor the above flow to activate a work only upon an error.
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-4-yishaih@nvidia.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 82470eba
...@@ -475,6 +475,15 @@ mlx5vf_get_data_buffer(struct mlx5_vf_migration_file *migf, ...@@ -475,6 +475,15 @@ mlx5vf_get_data_buffer(struct mlx5_vf_migration_file *migf,
return buf; return buf;
} }
static void
mlx5vf_save_callback_complete(struct mlx5_vf_migration_file *migf,
struct mlx5vf_async_data *async_data)
{
kvfree(async_data->out);
complete(&migf->save_comp);
fput(migf->filp);
}
void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work) void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work)
{ {
struct mlx5vf_async_data *async_data = container_of(_work, struct mlx5vf_async_data *async_data = container_of(_work,
...@@ -494,9 +503,7 @@ void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work) ...@@ -494,9 +503,7 @@ void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work)
wake_up_interruptible(&migf->poll_wait); wake_up_interruptible(&migf->poll_wait);
} }
mutex_unlock(&migf->lock); mutex_unlock(&migf->lock);
kvfree(async_data->out); mlx5vf_save_callback_complete(migf, async_data);
complete(&migf->save_comp);
fput(migf->filp);
} }
static int add_buf_header(struct mlx5_vhca_data_buffer *header_buf, static int add_buf_header(struct mlx5_vhca_data_buffer *header_buf,
...@@ -560,13 +567,12 @@ static void mlx5vf_save_callback(int status, struct mlx5_async_work *context) ...@@ -560,13 +567,12 @@ static void mlx5vf_save_callback(int status, struct mlx5_async_work *context)
migf->state = async_data->last_chunk ? migf->state = async_data->last_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);
return;
} }
err: err:
/* /* The error flow can't run from an interrupt context */
* The error and the cleanup flows can't run from an
* interrupt context
*/
if (status == -EREMOTEIO) if (status == -EREMOTEIO)
status = MLX5_GET(save_vhca_state_out, async_data->out, status); status = MLX5_GET(save_vhca_state_out, async_data->out, status);
async_data->status = status; async_data->status = status;
......
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