diff mbox series

[V1,mlx5-next,13/13] vfio/mlx5: Trap device RESET and update state accordingly

Message ID 20211013094707.163054-14-yishaih@nvidia.com (mailing list archive)
State New, archived
Headers show
Series Add mlx5 live migration driver | expand

Commit Message

Yishai Hadas Oct. 13, 2021, 9:47 a.m. UTC
Trap device RESET and update state accordingly, it's done by registering
the matching callbacks.

Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/vfio/pci/mlx5/main.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Jason Gunthorpe Oct. 13, 2021, 6:06 p.m. UTC | #1
On Wed, Oct 13, 2021 at 12:47:07PM +0300, Yishai Hadas wrote:
> Trap device RESET and update state accordingly, it's done by registering
> the matching callbacks.
> 
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
>  drivers/vfio/pci/mlx5/main.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
> index e36302b444a6..8fe44ed13552 100644
> +++ b/drivers/vfio/pci/mlx5/main.c
> @@ -613,6 +613,19 @@ static const struct vfio_device_ops mlx5vf_pci_ops = {
>  	.match = vfio_pci_core_match,
>  };
>  
> +static void mlx5vf_reset_done(struct vfio_pci_core_device *core_vdev)
> +{
> +	struct mlx5vf_pci_core_device *mvdev = container_of(
> +			core_vdev, struct mlx5vf_pci_core_device,
> +			core_device);
> +
> +	mvdev->vmig.vfio_dev_state = VFIO_DEVICE_STATE_RUNNING;

This should hold the state mutex too

Jason
Yishai Hadas Oct. 14, 2021, 9:18 a.m. UTC | #2
On 10/13/2021 9:06 PM, Jason Gunthorpe wrote:
> On Wed, Oct 13, 2021 at 12:47:07PM +0300, Yishai Hadas wrote:
>> Trap device RESET and update state accordingly, it's done by registering
>> the matching callbacks.
>>
>> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
>> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
>>   drivers/vfio/pci/mlx5/main.c | 17 ++++++++++++++++-
>>   1 file changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
>> index e36302b444a6..8fe44ed13552 100644
>> +++ b/drivers/vfio/pci/mlx5/main.c
>> @@ -613,6 +613,19 @@ static const struct vfio_device_ops mlx5vf_pci_ops = {
>>   	.match = vfio_pci_core_match,
>>   };
>>   
>> +static void mlx5vf_reset_done(struct vfio_pci_core_device *core_vdev)
>> +{
>> +	struct mlx5vf_pci_core_device *mvdev = container_of(
>> +			core_vdev, struct mlx5vf_pci_core_device,
>> +			core_device);
>> +
>> +	mvdev->vmig.vfio_dev_state = VFIO_DEVICE_STATE_RUNNING;
> This should hold the state mutex too
>
Thanks Jason, I'll add as part of V2.

Alex,

Any feedback from your side before that we'll send V2 ?

We already got ACK for the PCI patches, there are some minor changes to 
be done so far.

Thanks,

Yishai
Alex Williamson Oct. 15, 2021, 7:54 p.m. UTC | #3
On Thu, 14 Oct 2021 12:18:30 +0300
Yishai Hadas <yishaih@nvidia.com> wrote:

> On 10/13/2021 9:06 PM, Jason Gunthorpe wrote:
> > On Wed, Oct 13, 2021 at 12:47:07PM +0300, Yishai Hadas wrote:  
> >> Trap device RESET and update state accordingly, it's done by registering
> >> the matching callbacks.
> >>
> >> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> >> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> >>   drivers/vfio/pci/mlx5/main.c | 17 ++++++++++++++++-
> >>   1 file changed, 16 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
> >> index e36302b444a6..8fe44ed13552 100644
> >> +++ b/drivers/vfio/pci/mlx5/main.c
> >> @@ -613,6 +613,19 @@ static const struct vfio_device_ops mlx5vf_pci_ops = {
> >>   	.match = vfio_pci_core_match,
> >>   };
> >>   
> >> +static void mlx5vf_reset_done(struct vfio_pci_core_device *core_vdev)
> >> +{
> >> +	struct mlx5vf_pci_core_device *mvdev = container_of(
> >> +			core_vdev, struct mlx5vf_pci_core_device,
> >> +			core_device);
> >> +
> >> +	mvdev->vmig.vfio_dev_state = VFIO_DEVICE_STATE_RUNNING;  
> > This should hold the state mutex too
> >  
> Thanks Jason, I'll add as part of V2.
> 
> Alex,
> 
> Any feedback from your side before that we'll send V2 ?
> 
> We already got ACK for the PCI patches, there are some minor changes to 
> be done so far.

Provided.  Thanks,

Alex
diff mbox series

Patch

diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
index e36302b444a6..8fe44ed13552 100644
--- a/drivers/vfio/pci/mlx5/main.c
+++ b/drivers/vfio/pci/mlx5/main.c
@@ -613,6 +613,19 @@  static const struct vfio_device_ops mlx5vf_pci_ops = {
 	.match = vfio_pci_core_match,
 };
 
+static void mlx5vf_reset_done(struct vfio_pci_core_device *core_vdev)
+{
+	struct mlx5vf_pci_core_device *mvdev = container_of(
+			core_vdev, struct mlx5vf_pci_core_device,
+			core_device);
+
+	mvdev->vmig.vfio_dev_state = VFIO_DEVICE_STATE_RUNNING;
+}
+
+static const struct vfio_pci_core_device_ops mlx5vf_pci_core_ops = {
+	.reset_done = mlx5vf_reset_done,
+};
+
 static int mlx5vf_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *id)
 {
@@ -629,8 +642,10 @@  static int mlx5vf_pci_probe(struct pci_dev *pdev,
 			mlx5_vf_get_core_dev(pdev);
 
 		if (mdev) {
-			if (MLX5_CAP_GEN(mdev, migration))
+			if (MLX5_CAP_GEN(mdev, migration)) {
 				mvdev->migrate_cap = 1;
+				mvdev->core_device.ops = &mlx5vf_pci_core_ops;
+			}
 			mlx5_vf_put_core_dev(mdev);
 		}
 	}