Re: [PATCH V2 vfio 03/14] vfio/mlx5: Enforce a single SAVE command at a time

Yishai Hadas
2022-12-04T12:07:50Z

On 02/12/2022 2:51, Jason Gunthorpe wrote:
> On Thu, Dec 01, 2022 at 05:29:20PM +0200, Yishai Hadas wrote:
>
>> diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
>> index 6e9cf2aacc52..4081a0f7e057 100644
>> --- a/drivers/vfio/pci/mlx5/main.c
>> +++ b/drivers/vfio/pci/mlx5/main.c
>> @@ -245,6 +245,8 @@ mlx5vf_pci_save_device_data(struct mlx5vf_pci_core_device *mvdev)
>> stream_open(migf->filp->f_inode, migf->filp);
>> mutex_init(&migf->lock);
>> init_waitqueue_head(&migf->poll_wait);
>> + init_completion(&migf->save_comp);
>> + complete(&migf->save_comp);
> Add comment here
>
> save_comp is being used as a binary semaphore built from a
> completion. A normal mutex cannot be used because the lock is passed
> between kernel threads and lockdep can't model this.
>
> Jason

Sure, will add the comment as part of V3.

Yishai