From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>, Cindy Lu <lulu@redhat.com>
Subject: [PULL v2 08/10] Revert "virtio-pci: decouple the single vector from the interrupt process"
Date: Mon, 10 Jan 2022 16:05:07 -0500 [thread overview]
Message-ID: <20220110210416.18779-9-mst@redhat.com> (raw)
In-Reply-To: <20220110210416.18779-1-mst@redhat.com>
This reverts commit 316011b8a74e777eb3ba03171cd701a291c28867.
Fixes: 316011b8a7 ("virtio-pci: decouple the single vector from the interrupt process")
Cc: "Cindy Lu" <lulu@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio-pci.c | 163 +++++++++++++++++++----------------------
1 file changed, 74 insertions(+), 89 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 7201cf3dc1..4bdb6e5694 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -677,6 +677,7 @@ static uint32_t virtio_read_config(PCIDevice *pci_dev,
}
static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy,
+ unsigned int queue_no,
unsigned int vector)
{
VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
@@ -739,103 +740,87 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
return 0;
}
-static int kvm_virtio_pci_vector_use_one(VirtIOPCIProxy *proxy, int queue_no)
-{
- unsigned int vector;
- int ret;
- EventNotifier *n;
- PCIDevice *dev = &proxy->pci_dev;
- VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
- VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
-
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
- if (ret < 0) {
- return ret;
- }
- if (vector >= msix_nr_vectors_allocated(dev)) {
- return 0;
- }
- ret = kvm_virtio_pci_vq_vector_use(proxy, vector);
- if (ret < 0) {
- goto undo;
- }
- /*
- * If guest supports masking, set up irqfd now.
- * Otherwise, delay until unmasked in the frontend.
- */
- if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
- ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
- if (ret < 0) {
- kvm_virtio_pci_vq_vector_release(proxy, vector);
- goto undo;
- }
- }
-
- return 0;
-undo:
-
- vector = virtio_queue_vector(vdev, queue_no);
- if (vector >= msix_nr_vectors_allocated(dev)) {
- return ret;
- }
- if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
- if (ret < 0) {
- return ret;
- }
- kvm_virtio_pci_irqfd_release(proxy, n, vector);
- }
- return ret;
-}
static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
{
- int queue_no;
- int ret = 0;
- VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
-
- for (queue_no = 0; queue_no < nvqs; queue_no++) {
- if (!virtio_queue_get_num(vdev, queue_no)) {
- return -1;
- }
- ret = kvm_virtio_pci_vector_use_one(proxy, queue_no);
- }
- return ret;
-}
-
-
-static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy,
- int queue_no)
-{
- VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
- unsigned int vector;
- EventNotifier *n;
- int ret;
- VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
PCIDevice *dev = &proxy->pci_dev;
-
- ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
- if (ret < 0) {
- return;
- }
- if (vector >= msix_nr_vectors_allocated(dev)) {
- return;
- }
- if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
- kvm_virtio_pci_irqfd_release(proxy, n, vector);
- }
- kvm_virtio_pci_vq_vector_release(proxy, vector);
-}
-
-static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
-{
- int queue_no;
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
-
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
+ unsigned int vector;
+ int ret, queue_no;
+ EventNotifier *n;
for (queue_no = 0; queue_no < nvqs; queue_no++) {
if (!virtio_queue_get_num(vdev, queue_no)) {
break;
}
- kvm_virtio_pci_vector_release_one(proxy, queue_no);
+ ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
+ if (ret < 0) {
+ break;
+ }
+ if (vector >= msix_nr_vectors_allocated(dev)) {
+ continue;
+ }
+ ret = kvm_virtio_pci_vq_vector_use(proxy, queue_no, vector);
+ if (ret < 0) {
+ goto undo;
+ }
+ /* If guest supports masking, set up irqfd now.
+ * Otherwise, delay until unmasked in the frontend.
+ */
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
+ ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
+ if (ret < 0) {
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
+ goto undo;
+ }
+ }
+ }
+ return 0;
+
+undo:
+ while (--queue_no >= 0) {
+ vector = virtio_queue_vector(vdev, queue_no);
+ if (vector >= msix_nr_vectors_allocated(dev)) {
+ continue;
+ }
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
+ ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
+ if (ret < 0) {
+ break;
+ }
+ kvm_virtio_pci_irqfd_release(proxy, n, vector);
+ }
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
+ }
+ return ret;
+}
+
+static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
+{
+ PCIDevice *dev = &proxy->pci_dev;
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
+ unsigned int vector;
+ int queue_no;
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
+ EventNotifier *n;
+ int ret ;
+ for (queue_no = 0; queue_no < nvqs; queue_no++) {
+ if (!virtio_queue_get_num(vdev, queue_no)) {
+ break;
+ }
+ ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
+ if (ret < 0) {
+ break;
+ }
+ if (vector >= msix_nr_vectors_allocated(dev)) {
+ continue;
+ }
+ /* If guest supports masking, clean up irqfd now.
+ * 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, n, vector);
+ }
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
}
}
--
MST
next prev parent reply other threads:[~2022-01-10 21:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 21:04 [PULL v2 00/10] virtio: revert config interrupt changes Michael S. Tsirkin
2022-01-10 21:04 ` [PULL v2 01/10] Revert "virtio-pci: add support for configure interrupt" Michael S. Tsirkin
2022-01-10 21:04 ` [PULL v2 02/10] Revert "virtio-mmio: " Michael S. Tsirkin
2022-01-10 21:04 ` [PULL v2 03/10] Revert "virtio-net: " Michael S. Tsirkin
2022-01-10 21:04 ` [PULL v2 04/10] Revert "vhost: " Michael S. Tsirkin
2022-01-10 21:04 ` [PULL v2 05/10] Revert "virtio: " Michael S. Tsirkin
2022-01-10 21:05 ` [PULL v2 06/10] Revert "vhost-vdpa: add support for config interrupt" Michael S. Tsirkin
2022-01-10 21:05 ` [PULL v2 07/10] Revert "vhost: introduce new VhostOps vhost_set_config_call" Michael S. Tsirkin
2022-01-10 21:05 ` Michael S. Tsirkin [this message]
2022-01-10 21:05 ` [PULL v2 09/10] Revert "virtio-pci: decouple notifier from interrupt process" Michael S. Tsirkin
2022-01-10 21:05 ` [PULL v2 10/10] Revert "virtio: introduce macro IRTIO_CONFIG_IRQ_IDX" Michael S. Tsirkin
2022-01-11 11:37 ` [PULL v2 00/10] virtio: revert config interrupt changes Peter Maydell
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=20220110210416.18779-9-mst@redhat.com \
--to=mst@redhat.com \
--cc=lulu@redhat.com \
--cc=peter.maydell@linaro.org \
--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).