public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org, mingo@elte.hu, gorcunov@gmail.com
Cc: kvm@vger.kernel.org, Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI
Date: Thu,  2 Aug 2012 16:29:24 +0200	[thread overview]
Message-ID: <1343917764-28715-2-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1343917764-28715-1-git-send-email-levinsasha928@gmail.com>

Use the new KVM_SIGNAL_MSI ioctl to inject interrupts directly.

We still create GSIs and keep them for two reasons:

 - They're required by virtio-* devices.
 - There's not much overhead since we just create them when starting the
guest, they don't use anything when the guest is running.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/virtio/pci.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c
index f17cd8a..9888b1a 100644
--- a/tools/kvm/virtio/pci.c
+++ b/tools/kvm/virtio/pci.c
@@ -10,6 +10,7 @@
 #include <linux/virtio_pci.h>
 #include <linux/byteorder.h>
 #include <string.h>
+#include <sys/ioctl.h>
 
 static void virtio_pci__ioevent_callback(struct kvm *kvm, void *param)
 {
@@ -236,6 +237,17 @@ static void virtio_pci__mmio_callback(u64 addr, u8 *data, u32 len, u8 is_write,
 		memcpy(data, table + addr - offset, len);
 }
 
+static void virtio_pci__signal_msi(struct kvm *kvm, struct virtio_pci *vpci, int vec)
+{
+	struct kvm_msi msi = {
+		.address_lo = vpci->msix_table[vec].msg.address_lo,
+		.address_hi = vpci->msix_table[vec].msg.address_hi,
+		.data = vpci->msix_table[vec].msg.data,
+	};
+
+	ioctl(kvm->vm_fd, KVM_SIGNAL_MSI, &msi);
+}
+
 int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq)
 {
 	struct virtio_pci *vpci = vdev->virtio;
@@ -249,7 +261,7 @@ int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq)
 			return 0;
 		}
 
-		kvm__irq_trigger(kvm, vpci->gsis[vq]);
+		virtio_pci__signal_msi(kvm, vpci, vpci->vq_vector[vq]);
 	} else {
 		vpci->isr = VIRTIO_IRQ_HIGH;
 		kvm__irq_trigger(kvm, vpci->pci_hdr.irq_line);
@@ -270,7 +282,7 @@ int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev)
 			return 0;
 		}
 
-		kvm__irq_trigger(kvm, vpci->config_gsi);
+		virtio_pci__signal_msi(kvm, vpci, vpci->vq_vector[vpci->config_vector]);
 	} else {
 		vpci->isr = VIRTIO_PCI_ISR_CONFIG;
 		kvm__irq_trigger(kvm, vpci->pci_hdr.irq_line);
-- 
1.7.8.6


  reply	other threads:[~2012-08-02 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02 14:29 [PATCH 1/2] kvm tools: prevent guest softlockup errors when pausing Sasha Levin
2012-08-02 14:29 ` Sasha Levin [this message]
2012-08-04  9:14   ` [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI Pekka Enberg
2012-08-04  9:30     ` Sasha Levin
2012-08-04 11:02       ` Pekka Enberg
2012-08-05  7:02         ` Sasha Levin
2012-08-05  9:08           ` Pekka Enberg
2012-08-05  9:14             ` Sasha Levin
2012-08-05  9:31               ` Pekka Enberg

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=1343917764-28715-2-git-send-email-levinsasha928@gmail.com \
    --to=levinsasha928@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.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