2fe1fc7b2d
- kvm-virtio-introduce-macro-VIRTIO_CONFIG_IRQ_IDX.patch [bz#1905805] - kvm-virtio-pci-decouple-notifier-from-interrupt-process.patch [bz#1905805] - kvm-virtio-pci-decouple-the-single-vector-from-the-inter.patch [bz#1905805] - kvm-vhost-introduce-new-VhostOps-vhost_set_config_call.patch [bz#1905805] - kvm-vhost-vdpa-add-support-for-config-interrupt.patch [bz#1905805] - kvm-virtio-add-support-for-configure-interrupt.patch [bz#1905805] - kvm-vhost-add-support-for-configure-interrupt.patch [bz#1905805] - kvm-virtio-net-add-support-for-configure-interrupt.patch [bz#1905805] - kvm-virtio-mmio-add-support-for-configure-interrupt.patch [bz#1905805] - kvm-virtio-pci-add-support-for-configure-interrupt.patch [bz#1905805] - kvm-s390x-s390-virtio-ccw-Activate-zPCI-features-on-s390.patch [bz#2159408] - kvm-vhost-fix-vq-dirty-bitmap-syncing-when-vIOMMU-is-ena.patch [bz#2124856] - kvm-block-drop-bdrv_remove_filter_or_cow_child.patch [bz#2155112] - kvm-qed-Don-t-yield-in-bdrv_qed_co_drain_begin.patch [bz#2155112] - kvm-test-bdrv-drain-Don-t-yield-in-.bdrv_co_drained_begi.patch [bz#2155112] - kvm-block-Revert-.bdrv_drained_begin-end-to-non-coroutin.patch [bz#2155112] - kvm-block-Remove-drained_end_counter.patch [bz#2155112] - kvm-block-Inline-bdrv_drain_invoke.patch [bz#2155112] - kvm-block-Fix-locking-for-bdrv_reopen_queue_child.patch [bz#2155112] - kvm-block-Drain-individual-nodes-during-reopen.patch [bz#2155112] - kvm-block-Don-t-use-subtree-drains-in-bdrv_drop_intermed.patch [bz#2155112] - kvm-stream-Replace-subtree-drain-with-a-single-node-drai.patch [bz#2155112] - kvm-block-Remove-subtree-drains.patch [bz#2155112] - kvm-block-Call-drain-callbacks-only-once.patch [bz#2155112] - kvm-block-Remove-ignore_bds_parents-parameter-from-drain.patch [bz#2155112] - kvm-block-Drop-out-of-coroutine-in-bdrv_do_drained_begin.patch [bz#2155112] - kvm-block-Don-t-poll-in-bdrv_replace_child_noperm.patch [bz#2155112] - kvm-block-Remove-poll-parameter-from-bdrv_parent_drained.patch [bz#2155112] - kvm-accel-introduce-accelerator-blocker-API.patch [bz#1979276] - kvm-KVM-keep-track-of-running-ioctls.patch [bz#1979276] - kvm-kvm-Atomic-memslot-updates.patch [bz#1979276] - Resolves: bz#1905805 (support config interrupt in vhost-vdpa qemu) - Resolves: bz#2159408 ([s390x] VMs with ISM passthrough don't autostart after leapp upgrade from RHEL 8) - Resolves: bz#2124856 (VM with virtio interface and iommu=on will crash when try to migrate) - Resolves: bz#2155112 (Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)) - Resolves: bz#1979276 (SVM: non atomic memslot updates cause boot failure with seabios and cpu-pm=on)
273 lines
11 KiB
Diff
273 lines
11 KiB
Diff
From 9a234f849273d3480e4a88042cb1ea06a37a626b Mon Sep 17 00:00:00 2001
|
|
From: Cindy Lu <lulu@redhat.com>
|
|
Date: Thu, 22 Dec 2022 15:04:43 +0800
|
|
Subject: [PATCH 02/31] virtio-pci: decouple notifier from interrupt process
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Cindy Lu <lulu@redhat.com>
|
|
RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
|
|
RH-Bugzilla: 1905805
|
|
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
|
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
RH-Commit: [2/10] a20f4c9ff38b239531d12cbcc7deaa649c86abc3 (lulu6/qemu-kvm3)
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1905805
|
|
To reuse the notifier process. We add the virtio_pci_get_notifier
|
|
to get the notifier and vector. The INPUT for this function is IDX,
|
|
The OUTPUT is the notifier and the vector
|
|
|
|
Signed-off-by: Cindy Lu <lulu@redhat.com>
|
|
Message-Id: <20221222070451.936503-3-lulu@redhat.com>
|
|
Acked-by: Jason Wang <jasowang@redhat.com>
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
(cherry picked from commit 2e07f69d0c828e21515b63dc22884d548540b382)
|
|
Signed-off-by: Cindy Lu <lulu@redhat.com>
|
|
---
|
|
hw/virtio/virtio-pci.c | 88 +++++++++++++++++++++++++++---------------
|
|
1 file changed, 57 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
|
|
index a1c9dfa7bb..52c7692fff 100644
|
|
--- a/hw/virtio/virtio-pci.c
|
|
+++ b/hw/virtio/virtio-pci.c
|
|
@@ -728,29 +728,41 @@ 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;
|
|
|
|
ret = kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, irqfd->virq);
|
|
assert(ret == 0);
|
|
}
|
|
+static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
|
|
+ EventNotifier **n, unsigned int *vector)
|
|
+{
|
|
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
|
+ VirtQueue *vq;
|
|
+
|
|
+ if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
|
|
+ return -1;
|
|
+ } else {
|
|
+ if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
+ return -1;
|
|
+ }
|
|
+ *vector = virtio_queue_vector(vdev, queue_no);
|
|
+ vq = virtio_get_queue(vdev, queue_no);
|
|
+ *n = virtio_queue_get_guest_notifier(vq);
|
|
+ }
|
|
+ return 0;
|
|
+}
|
|
|
|
static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
|
|
{
|
|
@@ -759,12 +771,15 @@ 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;
|
|
-
|
|
+ EventNotifier *n;
|
|
for (queue_no = 0; queue_no < nvqs; queue_no++) {
|
|
if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
break;
|
|
}
|
|
- vector = virtio_queue_vector(vdev, queue_no);
|
|
+ ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
+ if (ret < 0) {
|
|
+ break;
|
|
+ }
|
|
if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
continue;
|
|
}
|
|
@@ -776,7 +791,7 @@ 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);
|
|
+ ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
|
|
if (ret < 0) {
|
|
kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
goto undo;
|
|
@@ -792,7 +807,11 @@ undo:
|
|
continue;
|
|
}
|
|
if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
|
|
- kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
|
|
+ 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);
|
|
}
|
|
@@ -806,12 +825,16 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
|
|
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;
|
|
}
|
|
- vector = virtio_queue_vector(vdev, queue_no);
|
|
+ ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
|
|
+ if (ret < 0) {
|
|
+ break;
|
|
+ }
|
|
if (vector >= msix_nr_vectors_allocated(dev)) {
|
|
continue;
|
|
}
|
|
@@ -819,21 +842,20 @@ 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);
|
|
+ kvm_virtio_pci_irqfd_release(proxy, n, vector);
|
|
}
|
|
kvm_virtio_pci_vq_vector_release(proxy, vector);
|
|
}
|
|
}
|
|
|
|
-static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
|
|
+static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,
|
|
unsigned int queue_no,
|
|
unsigned int vector,
|
|
- MSIMessage msg)
|
|
+ MSIMessage msg,
|
|
+ EventNotifier *n)
|
|
{
|
|
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;
|
|
|
|
@@ -860,14 +882,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,
|
|
+static void virtio_pci_one_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);
|
|
@@ -878,7 +901,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);
|
|
}
|
|
}
|
|
|
|
@@ -888,6 +911,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) {
|
|
@@ -896,7 +920,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_one_vector_unmask(proxy, index, vector, msg, n);
|
|
if (ret < 0) {
|
|
goto undo;
|
|
}
|
|
@@ -912,7 +937,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_one_vector_mask(proxy, index, vector, n);
|
|
--unmasked;
|
|
}
|
|
vq = virtio_vector_next_queue(vq);
|
|
@@ -925,15 +951,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);
|
|
if (!virtio_queue_get_num(vdev, index)) {
|
|
break;
|
|
}
|
|
if (index < proxy->nvqs_with_notifiers) {
|
|
- virtio_pci_vq_vector_mask(proxy, index, vector);
|
|
+ virtio_pci_one_vector_mask(proxy, index, vector, n);
|
|
}
|
|
vq = virtio_vector_next_queue(vq);
|
|
}
|
|
@@ -949,19 +977,17 @@ static void virtio_pci_vector_poll(PCIDevice *dev,
|
|
int queue_no;
|
|
unsigned int vector;
|
|
EventNotifier *notifier;
|
|
- VirtQueue *vq;
|
|
+ int ret;
|
|
|
|
for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) {
|
|
- if (!virtio_queue_get_num(vdev, queue_no)) {
|
|
+ ret = virtio_pci_get_notifier(proxy, queue_no, ¬ifier, &vector);
|
|
+ if (ret < 0) {
|
|
break;
|
|
}
|
|
- vector = virtio_queue_vector(vdev, queue_no);
|
|
if (vector < vector_start || vector >= vector_end ||
|
|
!msix_is_masked(dev, vector)) {
|
|
continue;
|
|
}
|
|
- vq = virtio_get_queue(vdev, queue_no);
|
|
- notifier = virtio_queue_get_guest_notifier(vq);
|
|
if (k->guest_notifier_pending) {
|
|
if (k->guest_notifier_pending(vdev, queue_no)) {
|
|
msix_set_pending(dev, vector);
|
|
--
|
|
2.31.1
|
|
|