netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] vdpa/mlx5: Setup driver only if VIRTIO_CONFIG_S_DRIVER_OK
@ 2020-09-08 12:33 Eli Cohen
  2020-09-09  2:08 ` Jason Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Cohen @ 2020-09-08 12:33 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, Cindy Lu, virtualization, netdev

set_map() is used by mlx5 vdpa to create a memory region based on the
address map passed by the iotlb argument. If we get successive calls, we
will destroy the current memory region and build another one based on
the new address mapping. We also need to setup the hardware resources
since they depend on the memory region.

If these calls happen before DRIVER_OK, It means that driver VQs may
also not been setup and we may not create them yet. In this case we want
to avoid setting up the other resources and defer this till we get
DRIVER OK.

Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Signed-off-by: Eli Cohen <elic@nvidia.com>
---
V1->V2: Improve changelog description

 drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 9df69d5efe8c..c89cd48a0aab 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1645,6 +1645,9 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_net *ndev, struct vhost_iotlb *
 	if (err)
 		goto err_mr;
 
+	if (!(ndev->mvdev.status & VIRTIO_CONFIG_S_DRIVER_OK))
+		return 0;
+
 	restore_channels_info(ndev);
 	err = setup_driver(ndev);
 	if (err)
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] vdpa/mlx5: Setup driver only if VIRTIO_CONFIG_S_DRIVER_OK
  2020-09-08 12:33 [PATCH v2] vdpa/mlx5: Setup driver only if VIRTIO_CONFIG_S_DRIVER_OK Eli Cohen
@ 2020-09-09  2:08 ` Jason Wang
  2020-09-09  5:30   ` Eli Cohen
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Wang @ 2020-09-09  2:08 UTC (permalink / raw)
  To: Eli Cohen; +Cc: Michael S. Tsirkin, Cindy Lu, virtualization, netdev



----- Original Message -----
> set_map() is used by mlx5 vdpa to create a memory region based on the
> address map passed by the iotlb argument. If we get successive calls, we
> will destroy the current memory region and build another one based on
> the new address mapping. We also need to setup the hardware resources
> since they depend on the memory region.
> 
> If these calls happen before DRIVER_OK, It means that driver VQs may
> also not been setup and we may not create them yet. In this case we want
> to avoid setting up the other resources and defer this till we get
> DRIVER OK.
> 
> Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
> Signed-off-by: Eli Cohen <elic@nvidia.com>
> ---
> V1->V2: Improve changelog description
> 
>  drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 9df69d5efe8c..c89cd48a0aab 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -1645,6 +1645,9 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_net
> *ndev, struct vhost_iotlb *
>  	if (err)
>  		goto err_mr;
>  
> +	if (!(ndev->mvdev.status & VIRTIO_CONFIG_S_DRIVER_OK))
> +		return 0;
> +

Is there any reason that we still need to do vq suspending and saving before?

Thanks

>  	restore_channels_info(ndev);
>  	err = setup_driver(ndev);
>  	if (err)
> --
> 2.26.0
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] vdpa/mlx5: Setup driver only if VIRTIO_CONFIG_S_DRIVER_OK
  2020-09-09  2:08 ` Jason Wang
@ 2020-09-09  5:30   ` Eli Cohen
  2020-10-13  5:37     ` Jason Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Cohen @ 2020-09-09  5:30 UTC (permalink / raw)
  To: Jason Wang; +Cc: Michael S. Tsirkin, Cindy Lu, virtualization, netdev

On Tue, Sep 08, 2020 at 10:08:39PM -0400, Jason Wang wrote:
> 
> 
> ----- Original Message -----
> > set_map() is used by mlx5 vdpa to create a memory region based on the
> > address map passed by the iotlb argument. If we get successive calls, we
> > will destroy the current memory region and build another one based on
> > the new address mapping. We also need to setup the hardware resources
> > since they depend on the memory region.
> > 
> > If these calls happen before DRIVER_OK, It means that driver VQs may
> > also not been setup and we may not create them yet. In this case we want
> > to avoid setting up the other resources and defer this till we get
> > DRIVER OK.
> > 
> > Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
> > Signed-off-by: Eli Cohen <elic@nvidia.com>
> > ---
> > V1->V2: Improve changelog description
> > 
> >  drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > index 9df69d5efe8c..c89cd48a0aab 100644
> > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > @@ -1645,6 +1645,9 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_net
> > *ndev, struct vhost_iotlb *
> >  	if (err)
> >  		goto err_mr;
> >  
> > +	if (!(ndev->mvdev.status & VIRTIO_CONFIG_S_DRIVER_OK))
> > +		return 0;
> > +
> 
> Is there any reason that we still need to do vq suspending and saving before?
> 
Though suspend_vqs() and save_channels_info() will be called, they will
not actually do any work because the mvq->initialized is false.

Since we don't expect so many false map updates I think it makes sense
to avoid logic around the calls suspend_vqs() and save_channels_info().

> Thanks
> 
> >  	restore_channels_info(ndev);
> >  	err = setup_driver(ndev);
> >  	if (err)
> > --
> > 2.26.0
> > 
> > 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] vdpa/mlx5: Setup driver only if VIRTIO_CONFIG_S_DRIVER_OK
  2020-09-09  5:30   ` Eli Cohen
@ 2020-10-13  5:37     ` Jason Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2020-10-13  5:37 UTC (permalink / raw)
  To: Eli Cohen; +Cc: Michael S. Tsirkin, Cindy Lu, virtualization, netdev


On 2020/9/9 下午1:30, Eli Cohen wrote:
> On Tue, Sep 08, 2020 at 10:08:39PM -0400, Jason Wang wrote:
>>
>> ----- Original Message -----
>>> set_map() is used by mlx5 vdpa to create a memory region based on the
>>> address map passed by the iotlb argument. If we get successive calls, we
>>> will destroy the current memory region and build another one based on
>>> the new address mapping. We also need to setup the hardware resources
>>> since they depend on the memory region.
>>>
>>> If these calls happen before DRIVER_OK, It means that driver VQs may
>>> also not been setup and we may not create them yet. In this case we want
>>> to avoid setting up the other resources and defer this till we get
>>> DRIVER OK.
>>>
>>> Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
>>> Signed-off-by: Eli Cohen <elic@nvidia.com>
>>> ---
>>> V1->V2: Improve changelog description
>>>
>>>   drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++
>>>   1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c
>>> b/drivers/vdpa/mlx5/net/mlx5_vnet.c
>>> index 9df69d5efe8c..c89cd48a0aab 100644
>>> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
>>> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
>>> @@ -1645,6 +1645,9 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_net
>>> *ndev, struct vhost_iotlb *
>>>   	if (err)
>>>   		goto err_mr;
>>>   
>>> +	if (!(ndev->mvdev.status & VIRTIO_CONFIG_S_DRIVER_OK))
>>> +		return 0;
>>> +
>> Is there any reason that we still need to do vq suspending and saving before?
>>
> Though suspend_vqs() and save_channels_info() will be called, they will
> not actually do any work because the mvq->initialized is false.
>
> Since we don't expect so many false map updates I think it makes sense
> to avoid logic around the calls suspend_vqs() and save_channels_info().


I see.

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks


>
>> Thanks
>>
>>>   	restore_channels_info(ndev);
>>>   	err = setup_driver(ndev);
>>>   	if (err)
>>> --
>>> 2.26.0
>>>
>>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-13  5:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 12:33 [PATCH v2] vdpa/mlx5: Setup driver only if VIRTIO_CONFIG_S_DRIVER_OK Eli Cohen
2020-09-09  2:08 ` Jason Wang
2020-09-09  5:30   ` Eli Cohen
2020-10-13  5:37     ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).