From: Heng Qi <hengqi@linux.alibaba.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
eperezma@redhat.com, parav@nvidia.com, feliu@nvidia.com,
virtualization@lists.linux.dev
Subject: Re: [PATCH virtio 1/8] virtio_pci: push out single vq find code to vp_find_one_vq_msix()
Date: Mon, 24 Jun 2024 18:52:47 +0800 [thread overview]
Message-ID: <1719226367.026366-19-hengqi@linux.alibaba.com> (raw)
In-Reply-To: <20240624090451.2683976-2-jiri@resnulli.us>
On Mon, 24 Jun 2024 11:04:44 +0200, Jiri Pirko <jiri@resnulli.us> wrote:
> From: Jiri Pirko <jiri@nvidia.com>
>
> In order to be reused for admin queue setup, push out common code to
> setup and configure irq for one vq into a separate helper.
>
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
> drivers/virtio/virtio_pci_common.c | 69 ++++++++++++++++++------------
> 1 file changed, 41 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
> index f6b0b00e4599..1fb2183e409b 100644
> --- a/drivers/virtio/virtio_pci_common.c
> +++ b/drivers/virtio/virtio_pci_common.c
> @@ -284,6 +284,44 @@ void vp_del_vqs(struct virtio_device *vdev)
> vp_dev->vqs = NULL;
> }
>
> +static struct virtqueue *vp_find_one_vq_msix(struct virtio_device *vdev,
> + int queue_idx,
> + vq_callback_t *callback,
> + const char *name, bool ctx,
> + int *allocated_vectors)
> +{
> + struct virtio_pci_device *vp_dev = to_vp_device(vdev);
> + struct virtqueue *vq;
> + u16 msix_vec;
> + int err;
> +
> + if (!callback)
> + msix_vec = VIRTIO_MSI_NO_VECTOR;
> + else if (vp_dev->per_vq_vectors)
> + msix_vec = (*allocated_vectors)++;
> + else
> + msix_vec = VP_MSIX_VQ_VECTOR;
> + vq = vp_setup_vq(vdev, queue_idx++, callback, name, ctx, msix_vec);
Looks like we don't need this ++.
Thanks.
> + if (IS_ERR(vq))
> + return vq;
> +
> + if (!vp_dev->per_vq_vectors || msix_vec == VIRTIO_MSI_NO_VECTOR)
> + return vq;
> +
> + /* allocate per-vq irq if available and necessary */
> + snprintf(vp_dev->msix_names[msix_vec], sizeof(*vp_dev->msix_names),
> + "%s-%s", dev_name(&vp_dev->vdev.dev), name);
> + err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec),
> + vring_interrupt, 0,
> + vp_dev->msix_names[msix_vec], vq);
> + if (err) {
> + vp_del_vq(vq);
> + return ERR_PTR(err);
> + }
> +
> + return vq;
> +}
> +
> static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs,
> struct virtqueue *vqs[], vq_callback_t *callbacks[],
> const char * const names[], bool per_vq_vectors,
> @@ -291,7 +329,6 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs,
> struct irq_affinity *desc)
> {
> struct virtio_pci_device *vp_dev = to_vp_device(vdev);
> - u16 msix_vec;
> int i, err, nvectors, allocated_vectors, queue_idx = 0;
>
> vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL);
> @@ -321,37 +358,13 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs,
> vqs[i] = NULL;
> continue;
> }
> -
> - if (!callbacks[i])
> - msix_vec = VIRTIO_MSI_NO_VECTOR;
> - else if (vp_dev->per_vq_vectors)
> - msix_vec = allocated_vectors++;
> - else
> - msix_vec = VP_MSIX_VQ_VECTOR;
> - vqs[i] = vp_setup_vq(vdev, queue_idx++, callbacks[i], names[i],
> - ctx ? ctx[i] : false,
> - msix_vec);
> + vqs[i] = vp_find_one_vq_msix(vdev, queue_idx++, callbacks[i],
> + names[i], ctx ? ctx[i] : false,
> + &allocated_vectors);
> if (IS_ERR(vqs[i])) {
> err = PTR_ERR(vqs[i]);
> goto error_find;
> }
> -
> - if (!vp_dev->per_vq_vectors || msix_vec == VIRTIO_MSI_NO_VECTOR)
> - continue;
> -
> - /* allocate per-vq irq if available and necessary */
> - snprintf(vp_dev->msix_names[msix_vec],
> - sizeof *vp_dev->msix_names,
> - "%s-%s",
> - dev_name(&vp_dev->vdev.dev), names[i]);
> - err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec),
> - vring_interrupt, 0,
> - vp_dev->msix_names[msix_vec],
> - vqs[i]);
> - if (err) {
> - vp_del_vq(vqs[i]);
> - goto error_find;
> - }
> }
> return 0;
>
> --
> 2.45.1
>
>
next prev parent reply other threads:[~2024-06-24 10:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 9:04 [PATCH virtio 0/8] virtio_pci_modern: allow parallel admin queue commands execution Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 1/8] virtio_pci: push out single vq find code to vp_find_one_vq_msix() Jiri Pirko
2024-06-24 10:52 ` Heng Qi [this message]
2024-06-24 13:11 ` Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 2/8] virtio_pci_modern: treat vp_dev->admin_vq.info.vq pointer as static Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 3/8] virtio: push out code to vp_avq_index() Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 4/8] virtio: create admin queues alongside other virtqueues Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 5/8] virtio_pci_modern: create admin queue of queried size Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 6/8] virtio_pci_modern: pass cmd as an identification token Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 7/8] virtio_pci_modern: use completion instead of busy loop to wait on admin cmd result Jiri Pirko
2024-06-24 11:30 ` Michael S. Tsirkin
2024-06-24 13:10 ` Jiri Pirko
2024-06-25 11:07 ` Jiri Pirko
2024-06-25 12:53 ` Parav Pandit
2024-06-25 14:29 ` Jiri Pirko
2024-06-24 11:34 ` Michael S. Tsirkin
2024-06-24 13:10 ` Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 8/8] virtio_pci_modern: remove admin queue serialization lock Jiri Pirko
2024-06-24 9:53 ` [PATCH virtio 0/8] virtio_pci_modern: allow parallel admin queue commands execution Heng Qi
2024-06-24 11:23 ` Michael S. Tsirkin
2024-06-24 13:46 ` Jiri Pirko
2024-06-24 13:55 ` Michael S. Tsirkin
2024-06-24 14:51 ` Jiri Pirko
2024-06-24 15:16 ` Michael S. Tsirkin
2024-06-25 2:11 ` Heng Qi
2024-06-25 6:38 ` Jiri Pirko
2024-06-25 6:41 ` Parav Pandit
2024-06-25 7:29 ` Michael S. Tsirkin
2024-06-25 8:01 ` Jiri Pirko
2024-06-25 7:20 ` Michael S. Tsirkin
2024-06-25 7:25 ` Parav Pandit
2024-06-24 15:10 ` Jiri Pirko
2024-06-24 15:23 ` Michael S. Tsirkin
2024-06-24 15:45 ` Jiri Pirko
2024-06-24 11:07 ` Michael S. Tsirkin
2024-06-24 13:09 ` Jiri Pirko
2024-06-24 13:16 ` Michael S. Tsirkin
2024-06-24 13:36 ` Jiri Pirko
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=1719226367.026366-19-hengqi@linux.alibaba.com \
--to=hengqi@linux.alibaba.com \
--cc=eperezma@redhat.com \
--cc=feliu@nvidia.com \
--cc=jasowang@redhat.com \
--cc=jiri@resnulli.us \
--cc=mst@redhat.com \
--cc=parav@nvidia.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/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.