linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vdpa/mlx5: should keep avail_index despite device status
@ 2020-10-01 20:18 Si-Wei Liu
  2020-10-02 20:17 ` Si-Wei Liu
  2020-10-10  7:31 ` Jason Wang
  0 siblings, 2 replies; 5+ messages in thread
From: Si-Wei Liu @ 2020-10-01 20:18 UTC (permalink / raw)
  To: netdev, mst, jasowang
  Cc: joao.m.martins, boris.ostrovsky, linux-kernel, virtualization

A VM with mlx5 vDPA has below warnings while being reset:

vhost VQ 0 ring restore failed: -1: Resource temporarily unavailable (11)
vhost VQ 1 ring restore failed: -1: Resource temporarily unavailable (11)

We should allow userspace emulating the virtio device be
able to get to vq's avail_index, regardless of vDPA device
status. Save the index that was last seen when virtq was
stopped, so that userspace doesn't complain.

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 70676a6..74264e59 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1133,15 +1133,17 @@ static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m
 	if (!mvq->initialized)
 		return;
 
-	if (query_virtqueue(ndev, mvq, &attr)) {
-		mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
-		return;
-	}
 	if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
 		return;
 
 	if (modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND))
 		mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n");
+
+	if (query_virtqueue(ndev, mvq, &attr)) {
+		mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
+		return;
+	}
+	mvq->avail_idx = attr.available_index;
 }
 
 static void suspend_vqs(struct mlx5_vdpa_net *ndev)
@@ -1411,8 +1413,14 @@ static int mlx5_vdpa_get_vq_state(struct vdpa_device *vdev, u16 idx, struct vdpa
 	struct mlx5_virtq_attr attr;
 	int err;
 
-	if (!mvq->initialized)
-		return -EAGAIN;
+	/* If the virtq object was destroyed, use the value saved at
+	 * the last minute of suspend_vq. This caters for userspace
+	 * that cares about emulating the index after vq is stopped.
+	 */
+	if (!mvq->initialized) {
+		state->avail_index = mvq->avail_idx;
+		return 0;
+	}
 
 	err = query_virtqueue(ndev, mvq, &attr);
 	if (err) {
-- 
1.8.3.1


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

* Re: [PATCH] vdpa/mlx5: should keep avail_index despite device status
  2020-10-01 20:18 [PATCH] vdpa/mlx5: should keep avail_index despite device status Si-Wei Liu
@ 2020-10-02 20:17 ` Si-Wei Liu
  2020-10-06  6:22   ` Michael S. Tsirkin
  2020-10-10  7:31 ` Jason Wang
  1 sibling, 1 reply; 5+ messages in thread
From: Si-Wei Liu @ 2020-10-02 20:17 UTC (permalink / raw)
  To: elic, mst, jasowang, netdev
  Cc: joao.m.martins, boris.ostrovsky, linux-kernel, virtualization,
	Si-Wei Liu

+ Eli.

On Thu, Oct 1, 2020 at 2:02 PM Si-Wei Liu <si-wei.liu@oracle.com> wrote:
>
> A VM with mlx5 vDPA has below warnings while being reset:
>
> vhost VQ 0 ring restore failed: -1: Resource temporarily unavailable (11)
> vhost VQ 1 ring restore failed: -1: Resource temporarily unavailable (11)
>
> We should allow userspace emulating the virtio device be
> able to get to vq's avail_index, regardless of vDPA device
> status. Save the index that was last seen when virtq was
> stopped, so that userspace doesn't complain.
>
> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
> ---
>  drivers/vdpa/mlx5/net/mlx5_vnet.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 70676a6..74264e59 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -1133,15 +1133,17 @@ static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m
>         if (!mvq->initialized)
>                 return;
>
> -       if (query_virtqueue(ndev, mvq, &attr)) {
> -               mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
> -               return;
> -       }
>         if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
>                 return;
>
>         if (modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND))
>                 mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n");
> +
> +       if (query_virtqueue(ndev, mvq, &attr)) {
> +               mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
> +               return;
> +       }
> +       mvq->avail_idx = attr.available_index;
>  }
>
>  static void suspend_vqs(struct mlx5_vdpa_net *ndev)
> @@ -1411,8 +1413,14 @@ static int mlx5_vdpa_get_vq_state(struct vdpa_device *vdev, u16 idx, struct vdpa
>         struct mlx5_virtq_attr attr;
>         int err;
>
> -       if (!mvq->initialized)
> -               return -EAGAIN;
> +       /* If the virtq object was destroyed, use the value saved at
> +        * the last minute of suspend_vq. This caters for userspace
> +        * that cares about emulating the index after vq is stopped.
> +        */
> +       if (!mvq->initialized) {
> +               state->avail_index = mvq->avail_idx;
> +               return 0;
> +       }
>
>         err = query_virtqueue(ndev, mvq, &attr);
>         if (err) {
> --
> 1.8.3.1
>

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

* Re: [PATCH] vdpa/mlx5: should keep avail_index despite device status
  2020-10-02 20:17 ` Si-Wei Liu
@ 2020-10-06  6:22   ` Michael S. Tsirkin
  2020-10-06  6:42     ` Eli Cohen
  0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2020-10-06  6:22 UTC (permalink / raw)
  To: Si-Wei Liu
  Cc: elic, jasowang, netdev, joao.m.martins, boris.ostrovsky,
	linux-kernel, virtualization, Si-Wei Liu

On Fri, Oct 02, 2020 at 01:17:00PM -0700, Si-Wei Liu wrote:
> + Eli.
> 
> On Thu, Oct 1, 2020 at 2:02 PM Si-Wei Liu <si-wei.liu@oracle.com> wrote:
> >
> > A VM with mlx5 vDPA has below warnings while being reset:
> >
> > vhost VQ 0 ring restore failed: -1: Resource temporarily unavailable (11)
> > vhost VQ 1 ring restore failed: -1: Resource temporarily unavailable (11)
> >
> > We should allow userspace emulating the virtio device be
> > able to get to vq's avail_index, regardless of vDPA device
> > status. Save the index that was last seen when virtq was
> > stopped, so that userspace doesn't complain.
> >
> > Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>

Eli can you review this pls? I need to send a pull request to Linux by
tomorrow - do we want to include this?

> > ---
> >  drivers/vdpa/mlx5/net/mlx5_vnet.c | 20 ++++++++++++++------
> >  1 file changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > index 70676a6..74264e59 100644
> > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > @@ -1133,15 +1133,17 @@ static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m
> >         if (!mvq->initialized)
> >                 return;
> >
> > -       if (query_virtqueue(ndev, mvq, &attr)) {
> > -               mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
> > -               return;
> > -       }
> >         if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
> >                 return;
> >
> >         if (modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND))
> >                 mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n");
> > +
> > +       if (query_virtqueue(ndev, mvq, &attr)) {
> > +               mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
> > +               return;
> > +       }
> > +       mvq->avail_idx = attr.available_index;
> >  }
> >
> >  static void suspend_vqs(struct mlx5_vdpa_net *ndev)
> > @@ -1411,8 +1413,14 @@ static int mlx5_vdpa_get_vq_state(struct vdpa_device *vdev, u16 idx, struct vdpa
> >         struct mlx5_virtq_attr attr;
> >         int err;
> >
> > -       if (!mvq->initialized)
> > -               return -EAGAIN;
> > +       /* If the virtq object was destroyed, use the value saved at
> > +        * the last minute of suspend_vq. This caters for userspace
> > +        * that cares about emulating the index after vq is stopped.
> > +        */
> > +       if (!mvq->initialized) {
> > +               state->avail_index = mvq->avail_idx;
> > +               return 0;
> > +       }
> >
> >         err = query_virtqueue(ndev, mvq, &attr);
> >         if (err) {
> > --
> > 1.8.3.1
> >


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

* Re: [PATCH] vdpa/mlx5: should keep avail_index despite device status
  2020-10-06  6:22   ` Michael S. Tsirkin
@ 2020-10-06  6:42     ` Eli Cohen
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Cohen @ 2020-10-06  6:42 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Si-Wei Liu, jasowang, netdev, joao.m.martins, boris.ostrovsky,
	linux-kernel, virtualization, Si-Wei Liu

On Tue, Oct 06, 2020 at 02:22:15AM -0400, Michael S. Tsirkin wrote:

Acked-by: Eli Cohen <elic@nvidia.com>

> On Fri, Oct 02, 2020 at 01:17:00PM -0700, Si-Wei Liu wrote:
> > + Eli.
> > 
> > On Thu, Oct 1, 2020 at 2:02 PM Si-Wei Liu <si-wei.liu@oracle.com> wrote:
> > >
> > > A VM with mlx5 vDPA has below warnings while being reset:
> > >
> > > vhost VQ 0 ring restore failed: -1: Resource temporarily unavailable (11)
> > > vhost VQ 1 ring restore failed: -1: Resource temporarily unavailable (11)
> > >
> > > We should allow userspace emulating the virtio device be
> > > able to get to vq's avail_index, regardless of vDPA device
> > > status. Save the index that was last seen when virtq was
> > > stopped, so that userspace doesn't complain.
> > >
> > > Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
> 
> Eli can you review this pls? I need to send a pull request to Linux by
> tomorrow - do we want to include this?
> 
> > > ---
> > >  drivers/vdpa/mlx5/net/mlx5_vnet.c | 20 ++++++++++++++------
> > >  1 file changed, 14 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > > index 70676a6..74264e59 100644
> > > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > > @@ -1133,15 +1133,17 @@ static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m
> > >         if (!mvq->initialized)
> > >                 return;
> > >
> > > -       if (query_virtqueue(ndev, mvq, &attr)) {
> > > -               mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
> > > -               return;
> > > -       }
> > >         if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
> > >                 return;
> > >
> > >         if (modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND))
> > >                 mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n");
> > > +
> > > +       if (query_virtqueue(ndev, mvq, &attr)) {
> > > +               mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
> > > +               return;
> > > +       }
> > > +       mvq->avail_idx = attr.available_index;
> > >  }
> > >
> > >  static void suspend_vqs(struct mlx5_vdpa_net *ndev)
> > > @@ -1411,8 +1413,14 @@ static int mlx5_vdpa_get_vq_state(struct vdpa_device *vdev, u16 idx, struct vdpa
> > >         struct mlx5_virtq_attr attr;
> > >         int err;
> > >
> > > -       if (!mvq->initialized)
> > > -               return -EAGAIN;
> > > +       /* If the virtq object was destroyed, use the value saved at
> > > +        * the last minute of suspend_vq. This caters for userspace
> > > +        * that cares about emulating the index after vq is stopped.
> > > +        */
> > > +       if (!mvq->initialized) {
> > > +               state->avail_index = mvq->avail_idx;
> > > +               return 0;
> > > +       }
> > >
> > >         err = query_virtqueue(ndev, mvq, &attr);
> > >         if (err) {
> > > --
> > > 1.8.3.1
> > >
> 

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

* Re: [PATCH] vdpa/mlx5: should keep avail_index despite device status
  2020-10-01 20:18 [PATCH] vdpa/mlx5: should keep avail_index despite device status Si-Wei Liu
  2020-10-02 20:17 ` Si-Wei Liu
@ 2020-10-10  7:31 ` Jason Wang
  1 sibling, 0 replies; 5+ messages in thread
From: Jason Wang @ 2020-10-10  7:31 UTC (permalink / raw)
  To: Si-Wei Liu, netdev, mst
  Cc: joao.m.martins, boris.ostrovsky, linux-kernel, virtualization


On 2020/10/2 上午4:18, Si-Wei Liu wrote:
> A VM with mlx5 vDPA has below warnings while being reset:
>
> vhost VQ 0 ring restore failed: -1: Resource temporarily unavailable (11)
> vhost VQ 1 ring restore failed: -1: Resource temporarily unavailable (11)
>
> We should allow userspace emulating the virtio device be
> able to get to vq's avail_index, regardless of vDPA device
> status. Save the index that was last seen when virtq was
> stopped, so that userspace doesn't complain.
>
> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>


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


> ---
>   drivers/vdpa/mlx5/net/mlx5_vnet.c | 20 ++++++++++++++------
>   1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 70676a6..74264e59 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -1133,15 +1133,17 @@ static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m
>   	if (!mvq->initialized)
>   		return;
>   
> -	if (query_virtqueue(ndev, mvq, &attr)) {
> -		mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
> -		return;
> -	}
>   	if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
>   		return;
>   
>   	if (modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND))
>   		mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n");
> +
> +	if (query_virtqueue(ndev, mvq, &attr)) {
> +		mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
> +		return;
> +	}
> +	mvq->avail_idx = attr.available_index;
>   }
>   
>   static void suspend_vqs(struct mlx5_vdpa_net *ndev)
> @@ -1411,8 +1413,14 @@ static int mlx5_vdpa_get_vq_state(struct vdpa_device *vdev, u16 idx, struct vdpa
>   	struct mlx5_virtq_attr attr;
>   	int err;
>   
> -	if (!mvq->initialized)
> -		return -EAGAIN;
> +	/* If the virtq object was destroyed, use the value saved at
> +	 * the last minute of suspend_vq. This caters for userspace
> +	 * that cares about emulating the index after vq is stopped.
> +	 */
> +	if (!mvq->initialized) {
> +		state->avail_index = mvq->avail_idx;
> +		return 0;
> +	}
>   
>   	err = query_virtqueue(ndev, mvq, &attr);
>   	if (err) {


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

end of thread, other threads:[~2020-10-10  7:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01 20:18 [PATCH] vdpa/mlx5: should keep avail_index despite device status Si-Wei Liu
2020-10-02 20:17 ` Si-Wei Liu
2020-10-06  6:22   ` Michael S. Tsirkin
2020-10-06  6:42     ` Eli Cohen
2020-10-10  7:31 ` 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).