[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC][PATCH 25/45] qemu-kvm: Update MSI cache on kvm_msi_ir
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [RFC][PATCH 25/45] qemu-kvm: Update MSI cache on kvm_msi_irqfd_set |
Date: |
Mon, 17 Oct 2011 11:27:59 +0200 |
Updating the MSI message registration on kvm_msi_irqfd_set will allow us
to switch to a lazy mode and remove the need to track message changes in
the device config space.
Signed-off-by: Jan Kiszka <address@hidden>
---
hw/virtio-pci.c | 10 ++++++----
kvm.h | 3 ++-
qemu-kvm.c | 17 ++++++++++++++---
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 6718945..85d6771 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -521,10 +521,10 @@ static void virtio_pci_guest_notifier_read(void *opaque)
}
static int virtio_pci_mask_vq(PCIDevice *dev, unsigned int vector,
- VirtQueue *vq, bool masked)
+ MSIMessage *msg, VirtQueue *vq, bool masked)
{
EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
- int r = kvm_msi_irqfd_set(&dev->msix_cache[vector],
+ int r = kvm_msi_irqfd_set(msg, &dev->msix_cache[vector],
event_notifier_get_fd(notifier),
!masked);
if (r < 0) {
@@ -554,7 +554,8 @@ static int virtio_pci_msi_vector_config(PCIDevice *dev,
unsigned int vector,
if (virtio_queue_vector(vdev, n) != vector) {
continue;
}
- r = virtio_pci_mask_vq(dev, vector, virtio_get_queue(vdev, n), masked);
+ r = virtio_pci_mask_vq(dev, vector, msg, virtio_get_queue(vdev, n),
+ masked);
if (r < 0) {
goto undo;
}
@@ -565,7 +566,8 @@ undo:
if (virtio_queue_vector(vdev, n) != vector) {
continue;
}
- virtio_pci_mask_vq(dev, vector, virtio_get_queue(vdev, n), !masked);
+ virtio_pci_mask_vq(dev, vector, msg, virtio_get_queue(vdev, n),
+ !masked);
}
return r;
}
diff --git a/kvm.h b/kvm.h
index fe2eec5..8647647 100644
--- a/kvm.h
+++ b/kvm.h
@@ -208,7 +208,8 @@ int kvm_msi_message_add(MSIMessage *msg, MSIRoutingCache
*cache);
int kvm_msi_message_del(MSIRoutingCache *cache);
int kvm_msi_message_update(MSIMessage *msg, MSIRoutingCache *cache);
-int kvm_msi_irqfd_set(MSIRoutingCache *cache, int fd, bool assigned);
+int kvm_msi_irqfd_set(MSIMessage *msg, MSIRoutingCache *cache, int fd,
+ bool assigned);
int kvm_commit_irq_routes(void);
diff --git a/qemu-kvm.c b/qemu-kvm.c
index ab7703b..6bdd7b5 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -524,10 +524,21 @@ int kvm_msi_message_update(MSIMessage *msg,
MSIRoutingCache *cache)
}
-int kvm_msi_irqfd_set(MSIRoutingCache *cache, int fd, bool assigned)
+int kvm_msi_irqfd_set(MSIMessage *msg, MSIRoutingCache *cache, int fd,
+ bool assigned)
{
- if (cache->type == MSI_ROUTE_NONE) {
- return assigned ? -EINVAL : 0;
+ int ret;
+
+ if (assigned) {
+ if (cache->type == MSI_ROUTE_NONE) {
+ return -EINVAL;
+ }
+ ret = kvm_msi_message_update(msg, cache);
+ if (ret < 0) {
+ return ret;
+ }
+ } else if (cache->type == MSI_ROUTE_NONE) {
+ return 0;
}
cache->kvm_irqfd = assigned ? fd : -1;
return kvm_set_irqfd(cache->kvm_gsi, fd, assigned);
--
1.7.3.4
- Re: [Qemu-devel] [RFC][PATCH 06/45] msix: Prevent bogus mask updates on MMIO accesses, (continued)
[Qemu-devel] [RFC][PATCH 09/45] msi: Factor out msi_message_from_vector, Jan Kiszka, 2011/10/17
[Qemu-devel] [RFC][PATCH 26/45] qemu-kvm: Use g_realloc for irq_routes extension, Jan Kiszka, 2011/10/17
[Qemu-devel] [RFC][PATCH 17/45] qemu-kvm: Track MSIRoutingCache in KVM routing table, Jan Kiszka, 2011/10/17
[Qemu-devel] [RFC][PATCH 04/45] msi: Invoke msi/msix_reset from PCI core, Jan Kiszka, 2011/10/17
[Qemu-devel] [RFC][PATCH 25/45] qemu-kvm: Update MSI cache on kvm_msi_irqfd_set,
Jan Kiszka <=
[Qemu-devel] [RFC][PATCH 20/45] qemu-kvm: msix: Only invoke msix_handle_mask_update on changes, Jan Kiszka, 2011/10/17
[Qemu-devel] [RFC][PATCH 14/45] qemu-kvm: Drop useless kvm_clear_gsi_routes, Jan Kiszka, 2011/10/17
[Qemu-devel] [RFC][PATCH 34/45] qemu-kvm: Factor out kvm_device_msi_assign, Jan Kiszka, 2011/10/17
[Qemu-devel] [RFC][PATCH 08/45] Introduce MSIMessage structure, Jan Kiszka, 2011/10/17
- Re: [Qemu-devel] [RFC][PATCH 08/45] Introduce MSIMessage structure, Michael S. Tsirkin, 2011/10/17
- Re: [Qemu-devel] [RFC][PATCH 08/45] Introduce MSIMessage structure, Jan Kiszka, 2011/10/17
- Re: [Qemu-devel] [RFC][PATCH 08/45] Introduce MSIMessage structure, Michael S. Tsirkin, 2011/10/17
- Re: [Qemu-devel] [RFC][PATCH 08/45] Introduce MSIMessage structure, Jan Kiszka, 2011/10/17
- Re: [Qemu-devel] [RFC][PATCH 08/45] Introduce MSIMessage structure, Michael S. Tsirkin, 2011/10/17
- Re: [Qemu-devel] [RFC][PATCH 08/45] Introduce MSIMessage structure, Jan Kiszka, 2011/10/18