All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Si-Wei Liu <si-wei.liu@oracle.com>
Cc: Laurent Vivier <lvivier@redhat.com>, mst <mst@redhat.com>,
	virtualization <virtualization@lists.linux-foundation.org>,
	eperezma <eperezma@redhat.com>, Eli Cohen <elic@nvidia.com>
Subject: Re: [PATCH 4/4] vdpa/mlx5: Fix tracking of current number of VQs
Date: Wed, 12 Jan 2022 10:29:46 +0800	[thread overview]
Message-ID: <CACGkMEs77urb3Ef++tVHvQow2eRKpzW3c8TPtdiGrq9jQcmWjA@mail.gmail.com> (raw)
In-Reply-To: <8f1d7e2c-e8ca-4c09-f18c-72cd4c09c44f@oracle.com>

On Wed, Jan 12, 2022 at 6:15 AM Si-Wei Liu <si-wei.liu@oracle.com> wrote:
>
>
>
> On 1/11/2022 10:34 AM, Eli Cohen wrote:
> > Modify the code such that ndev->cur_num_vqs better reflects the actual
> > number of data virtqueues. The value can be accurately realized after
> > features have been negotiated.
> >
> > This is to prevent possible failures when modifying the RQT object if
> > the cur_num_vqs bears invalid value.
> >
> > No issue was actually encountered but this also makes the code more
> > readable.
> >
> > Fixes: c5a5cd3d3217 ("vdpa/mlx5: Support configuring max data virtqueue")
> > Signed-off-by: Eli Cohen <elic@nvidia.com>
> > ---
> >   drivers/vdpa/mlx5/net/mlx5_vnet.c | 12 ++++++++----
> >   1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > index 9eacfdb48434..b53603d94082 100644
> > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > @@ -1246,8 +1246,7 @@ static int create_rqt(struct mlx5_vdpa_net *ndev)
> >       if (!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_MQ)))
> >               num = 1;
> >       else
> > -             num = mlx5vdpa16_to_cpu(&ndev->mvdev,
> > -                                     ndev->config.max_virtqueue_pairs);
> > +             num = ndev->cur_num_vqs / 2;
> Nit: the if branch can be consolidated
>
> >
> >       max_rqt = min_t(int, roundup_pow_of_two(num),
> >                       1 << MLX5_CAP_GEN(ndev->mvdev.mdev, log_max_rqt_size));
> > @@ -1983,6 +1982,11 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features)
> >               return err;
> >
> >       ndev->mvdev.actual_features = features & ndev->mvdev.mlx_features;
> > +     if (ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_MQ))
> > +             ndev->cur_num_vqs = 2 * mlx5vdpa16_to_cpu(mvdev, ndev->config.max_virtqueue_pairs);
> Hmmm, not this patch, but there should've been validation done in the
> upper layer to guarantee set_featuers() for VIRTIO_NET_F_MQ always comes
> with VIRTIO_NET_F_CTRL_VQ. Maybe checking both: BIT_ULL(VIRTIO_NET_F_MQ)
> |  BIT_ULL(VIRTIO_NET_F_CTRL_VQ)?

So the upper layer is unaware of the device type. It's better to do
that in mlx5's set_features() according to the spec:

The device MUST NOT offer a feature which requires another feature
which was not offered.

Thanks

>
> otherwise it looks good to me.
>
> Reviewed-by: Si-Wei Liu<si-wei.liu@oracle.com>
> > +     else
> > +             ndev->cur_num_vqs = 2;
> > +
> >       update_cvq_info(mvdev);
> >       return err;
> >   }
> > @@ -2233,6 +2237,7 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev)
> >       clear_vqs_ready(ndev);
> >       mlx5_vdpa_destroy_mr(&ndev->mvdev);
> >       ndev->mvdev.status = 0;
> > +     ndev->cur_num_vqs = 0;
> >       memset(ndev->event_cbs, 0, sizeof(*ndev->event_cbs) * (mvdev->max_vqs + 1));
> >       ndev->mvdev.actual_features = 0;
> >       ++mvdev->generation;
> > @@ -2641,9 +2646,8 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
> >
> >       ndev->nb.notifier_call = event_handler;
> >       mlx5_notifier_register(mdev, &ndev->nb);
> > -     ndev->cur_num_vqs = 2 * mlx5_vdpa_max_qps(max_vqs);
> >       mvdev->vdev.mdev = &mgtdev->mgtdev;
> > -     err = _vdpa_register_device(&mvdev->vdev, ndev->cur_num_vqs + 1);
> > +     err = _vdpa_register_device(&mvdev->vdev, 2 * mlx5_vdpa_max_qps(max_vqs) + 1);
> >       if (err)
> >               goto err_reg;
> >
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2022-01-12  2:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220111183400.38418-1-elic@nvidia.com>
     [not found] ` <20220111183400.38418-2-elic@nvidia.com>
2022-01-11 21:46   ` [PATCH 1/4] vdpa: Avoid taking cf_mutex lock on get status Si-Wei Liu
2022-01-12  2:32   ` Jason Wang
     [not found] ` <20220111183400.38418-3-elic@nvidia.com>
2022-01-11 21:47   ` [PATCH 2/4] vdpa: Protect vdpa reset with cf_mutex Si-Wei Liu
2022-01-12  2:34   ` Jason Wang
     [not found] ` <20220111183400.38418-4-elic@nvidia.com>
2022-01-11 21:47   ` [PATCH 3/4] vdpa/mlx5: Fix is_index_valid() to refer to features Si-Wei Liu
2022-01-12  2:35   ` Jason Wang
     [not found] ` <20220111183400.38418-5-elic@nvidia.com>
2022-01-11 22:14   ` [PATCH 4/4] vdpa/mlx5: Fix tracking of current number of VQs Si-Wei Liu
2022-01-12  2:29     ` Jason Wang [this message]
2022-01-12  3:12       ` Si-Wei Liu
2022-01-12  3:57         ` Jason Wang
     [not found]     ` <20220112063732.GA196570@mtl-vdi-166.wap.labs.mlnx>
2022-01-12  7:46       ` Si-Wei Liu
2022-01-14 20:25     ` Michael S. Tsirkin
2022-01-12  2:35   ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACGkMEs77urb3Ef++tVHvQow2eRKpzW3c8TPtdiGrq9jQcmWjA@mail.gmail.com \
    --to=jasowang@redhat.com \
    --cc=elic@nvidia.com \
    --cc=eperezma@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=si-wei.liu@oracle.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.