From: Jason Wang <jasowang@redhat.com>
To: Cindy Lu <lulu@redhat.com>, mst@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v7 02/10] virtio-pci:decouple virtqueue from interrupt setting process
Date: Thu, 3 Jun 2021 13:51:30 +0800 [thread overview]
Message-ID: <f64b31dc-eab2-0e5f-17f0-6e60c74084ad@redhat.com> (raw)
In-Reply-To: <20210602034750.23377-3-lulu@redhat.com>
在 2021/6/2 上午11:47, Cindy Lu 写道:
> Decouple virtqueue from interrupt setting process to support config interrupt
> Now the code for interrupt/vector are coupling
> with the vq number, this patch will decouple the vritqueue
> numbers from these functions.
>
> Signed-off-by: Cindy Lu <lulu@redhat.com>
> ---
> hw/virtio/virtio-pci.c | 51 ++++++++++++++++++++++++------------------
> 1 file changed, 29 insertions(+), 22 deletions(-)
>
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index b321604d9b..c5c080ec94 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -693,23 +693,17 @@ static void kvm_virtio_pci_vq_vector_release(VirtIOPCIProxy *proxy,
> }
>
> static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy,
> - unsigned int queue_no,
> + EventNotifier *n,
> unsigned int vector)
> {
> VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
> - VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
> - VirtQueue *vq = virtio_get_queue(vdev, queue_no);
> - EventNotifier *n = virtio_queue_get_guest_notifier(vq);
> return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->virq);
> }
>
> static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy,
> - unsigned int queue_no,
> + EventNotifier *n ,
> unsigned int vector)
> {
> - VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
> - VirtQueue *vq = virtio_get_queue(vdev, queue_no);
> - EventNotifier *n = virtio_queue_get_guest_notifier(vq);
> VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
> int ret;
>
> @@ -724,7 +718,8 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
> VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> unsigned int vector;
> int ret, queue_no;
> -
> + VirtQueue *vq;
> + EventNotifier *n;
Let's leave a newline here.
> for (queue_no = 0; queue_no < nvqs; queue_no++) {
> if (!virtio_queue_get_num(vdev, queue_no)) {
> break;
> @@ -741,7 +736,9 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
> * Otherwise, delay until unmasked in the frontend.
> */
> if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
> - ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
> + vq = virtio_get_queue(vdev, queue_no);
> + n = virtio_queue_get_guest_notifier(vq);
> + ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
> if (ret < 0) {
> kvm_virtio_pci_vq_vector_release(proxy, vector);
> goto undo;
> @@ -757,7 +754,9 @@ undo:
> continue;
> }
> if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
> - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
> + vq = virtio_get_queue(vdev, queue_no);
> + n = virtio_queue_get_guest_notifier(vq);
> + kvm_virtio_pci_irqfd_release(proxy, n, vector);
> }
> kvm_virtio_pci_vq_vector_release(proxy, vector);
> }
> @@ -771,7 +770,8 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
> unsigned int vector;
> int queue_no;
> VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> -
> + VirtQueue *vq;
> + EventNotifier *n;
Similar here.
> for (queue_no = 0; queue_no < nvqs; queue_no++) {
> if (!virtio_queue_get_num(vdev, queue_no)) {
> break;
> @@ -784,7 +784,9 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
> * Otherwise, it was cleaned when masked in the frontend.
> */
> if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
> - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
> + vq = virtio_get_queue(vdev, queue_no);
> + n = virtio_queue_get_guest_notifier(vq);
> + kvm_virtio_pci_irqfd_release(proxy, n, vector);
> }
> kvm_virtio_pci_vq_vector_release(proxy, vector);
> }
> @@ -793,12 +795,11 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
> static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
> unsigned int queue_no,
> unsigned int vector,
> - MSIMessage msg)
> + MSIMessage msg,
> + EventNotifier *n)
> {
A question: if this function needs to be used by configure interrupt, it
needs rename. Otherwise we don't need to bother since it only deal with
vq vector.
> VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
> VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> - VirtQueue *vq = virtio_get_queue(vdev, queue_no);
> - EventNotifier *n = virtio_queue_get_guest_notifier(vq);
> VirtIOIRQFD *irqfd;
> int ret = 0;
>
> @@ -825,14 +826,15 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
> event_notifier_set(n);
> }
> } else {
> - ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
> + ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
> }
> return ret;
> }
>
> static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy,
> unsigned int queue_no,
> - unsigned int vector)
> + unsigned int vector,
> + EventNotifier *n)
> {
> VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
> VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> @@ -843,7 +845,7 @@ static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy,
> if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
> k->guest_notifier_mask(vdev, queue_no, true);
> } else {
> - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
> + kvm_virtio_pci_irqfd_release(proxy, n, vector);
> }
> }
>
> @@ -853,6 +855,7 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
> VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
> VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
> VirtQueue *vq = virtio_vector_first_queue(vdev, vector);
> + EventNotifier *n;
> int ret, index, unmasked = 0;
>
> while (vq) {
> @@ -861,7 +864,8 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
> break;
> }
> if (index < proxy->nvqs_with_notifiers) {
> - ret = virtio_pci_vq_vector_unmask(proxy, index, vector, msg);
> + n = virtio_queue_get_guest_notifier(vq);
> + ret = virtio_pci_vq_vector_unmask(proxy, index, vector, msg, n);
> if (ret < 0) {
> goto undo;
> }
> @@ -877,7 +881,8 @@ undo:
> while (vq && unmasked >= 0) {
> index = virtio_get_queue_index(vq);
> if (index < proxy->nvqs_with_notifiers) {
> - virtio_pci_vq_vector_mask(proxy, index, vector);
> + n = virtio_queue_get_guest_notifier(vq);
> + virtio_pci_vq_vector_mask(proxy, index, vector, n);
> --unmasked;
> }
> vq = virtio_vector_next_queue(vq);
> @@ -890,15 +895,17 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsigned vector)
> VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
> VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
> VirtQueue *vq = virtio_vector_first_queue(vdev, vector);
> + EventNotifier *n;
> int index;
>
> while (vq) {
> index = virtio_get_queue_index(vq);
> + n = virtio_queue_get_guest_notifier(vq);
Indentation looks wrong.
Thanks
> if (!virtio_queue_get_num(vdev, index)) {
> break;
> }
> if (index < proxy->nvqs_with_notifiers) {
> - virtio_pci_vq_vector_mask(proxy, index, vector);
> + virtio_pci_vq_vector_mask(proxy, index, vector, n);
> }
> vq = virtio_vector_next_queue(vq);
> }
next prev parent reply other threads:[~2021-06-03 5:52 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 3:47 [PATCH v7 00/10] vhost-vdpa: add support for configure interrupt Cindy Lu
2021-06-02 3:47 ` [PATCH v7 01/10] virtio: introduce macro IRTIO_CONFIG_IRQ_IDX 聽 Cindy Lu
2021-06-02 3:47 ` [PATCH v7 02/10] virtio-pci:decouple virtqueue from interrupt setting process Cindy Lu
2021-06-03 5:51 ` Jason Wang [this message]
2021-06-02 3:47 ` [PATCH v7 03/10] virtio: decouple virtqueue from set notifier fd handler Cindy Lu
2021-06-03 6:01 ` Jason Wang
2021-06-02 3:47 ` [PATCH v7 04/10] vhost: add new call back function for config interrupt Cindy Lu
2021-06-03 6:04 ` Jason Wang
2021-06-02 3:47 ` [PATCH v7 05/10] vhost-vdpa: add support for config interrupt call back Cindy Lu
2021-06-03 6:06 ` Jason Wang
2021-06-07 6:34 ` Cindy Lu
2021-06-02 3:47 ` [PATCH v7 06/10] vhost:add support for configure interrupt Cindy Lu
2021-06-03 6:28 ` Jason Wang
2021-06-08 3:20 ` Cindy Lu
2021-06-02 3:47 ` [PATCH v7 07/10] virtio-mmio: add " Cindy Lu
2021-06-03 6:35 ` Jason Wang
2021-06-07 6:35 ` Cindy Lu
2021-06-02 3:47 ` [PATCH v7 08/10] virtio-pci: decouple virtqueue from kvm_virtio_pci_vector_use Cindy Lu
2021-06-03 6:39 ` Jason Wang
2021-06-07 6:36 ` Cindy Lu
2021-06-02 3:47 ` [PATCH v7 09/10] virtio-pci: add support for configure interrupt Cindy Lu
2021-06-03 6:45 ` Jason Wang
2021-06-07 6:44 ` Cindy Lu
2021-06-02 3:47 ` [PATCH v7 10/10] virtio-net: add peer_deleted check in virtio_net_handle_rx Cindy Lu
2021-06-03 6:58 ` Jason Wang
2021-06-07 6:20 ` Cindy Lu
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=f64b31dc-eab2-0e5f-17f0-6e60c74084ad@redhat.com \
--to=jasowang@redhat.com \
--cc=lulu@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.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 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).