Skip to content

Commit 34a64c8

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

File tree

1 file changed

+13
-7
lines changed
  • drivers/vfio/pci/mlx5

1 file changed

+13
-7
lines changed

drivers/vfio/pci/mlx5/cmd.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,15 @@ mlx5vf_get_data_buffer(struct mlx5_vf_migration_file *migf,
475475
return buf;
476476
}
477477

478+
static void
479+
mlx5vf_save_callback_complete(struct mlx5_vf_migration_file *migf,
480+
struct mlx5vf_async_data *async_data)
481+
{
482+
kvfree(async_data->out);
483+
complete(&migf->save_comp);
484+
fput(migf->filp);
485+
}
486+
478487
void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work)
479488
{
480489
struct mlx5vf_async_data *async_data = container_of(_work,
@@ -494,9 +503,7 @@ void mlx5vf_mig_file_cleanup_cb(struct work_struct *_work)
494503
wake_up_interruptible(&migf->poll_wait);
495504
}
496505
mutex_unlock(&migf->lock);
497-
kvfree(async_data->out);
498-
complete(&migf->save_comp);
499-
fput(migf->filp);
506+
mlx5vf_save_callback_complete(migf, async_data);
500507
}
501508

502509
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)
560567
migf->state = async_data->last_chunk ?
561568
MLX5_MIGF_STATE_COMPLETE : MLX5_MIGF_STATE_PRE_COPY;
562569
wake_up_interruptible(&migf->poll_wait);
570+
mlx5vf_save_callback_complete(migf, async_data);
571+
return;
563572
}
564573

565574
err:
566-
/*
567-
* The error and the cleanup flows can't run from an
568-
* interrupt context
569-
*/
575+
/* The error flow can't run from an interrupt context */
570576
if (status == -EREMOTEIO)
571577
status = MLX5_GET(save_vhca_state_out, async_data->out, status);
572578
async_data->status = status;

0 commit comments

Comments
 (0)