From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Subject: [Qemu-devel] [RFC PATCH 4/4] pci-assign: Add MSI affinity support
Date: Tue, 27 Nov 2012 15:01:01 -0700 [thread overview]
Message-ID: <20121127220101.5751.96242.stgit@bling.home> (raw)
In-Reply-To: <20121127215203.5751.6523.stgit@bling.home>
Track the last MSIMessage programmed so we can determine when it has
changed and update the routing to the guest. We track MSI-X for
consistency, but we don't do anything with it here.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/kvm/pci-assign.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c
index 3e667d1..500c62c 100644
--- a/hw/kvm/pci-assign.c
+++ b/hw/kvm/pci-assign.c
@@ -133,6 +133,7 @@ typedef struct AssignedDevice {
int msi_nr;
struct {
int virq;
+ MSIMessage msg;
} *msi;
MSIXTableEntry *msix_table;
hwaddr msix_table_addr;
@@ -1009,6 +1010,7 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev)
assigned_dev->msi = g_malloc(sizeof(*assigned_dev->msi));
assigned_dev->msi_nr = 1;
assigned_dev->msi[0].virq = virq;
+ assigned_dev->msi[0].msg = msg;
if (kvm_device_msi_assign(kvm_state, assigned_dev->dev_id, virq) < 0) {
perror("assigned_dev_update_msi: kvm_device_msi_assign");
}
@@ -1021,6 +1023,27 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev)
}
}
+static void assigned_dev_update_msi_msg(PCIDevice *pci_dev)
+{
+ AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ uint8_t ctrl_byte = pci_get_byte(pci_dev->config + pci_dev->msi_cap +
+ PCI_MSI_FLAGS);
+ MSIMessage msg;
+
+ if (assigned_dev->assigned_irq_type != ASSIGNED_IRQ_MSI ||
+ !(ctrl_byte & PCI_MSI_FLAGS_ENABLE)) {
+ return;
+ }
+
+ msg = msi_get_message(pci_dev, 0);
+
+ if (msg.address != assigned_dev->msi[0].msg.address ||
+ msg.data != assigned_dev->msi[0].msg.data) {
+ kvm_irqchip_update_msi_route(kvm_state, assigned_dev->msi[0].virq, msg);
+ assigned_dev->msi[0].msg = msg;
+ }
+}
+
static bool assigned_dev_msix_masked(MSIXTableEntry *entry)
{
return (entry->ctrl & cpu_to_le32(0x1)) != 0;
@@ -1076,6 +1099,7 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
return r;
}
adev->msi[i].virq = r;
+ adev->msi[i].msg = msg;
DEBUG("MSI-X vector %d, gsi %d, addr %08x_%08x, data %08x\n", i,
r, entry->addr_hi, entry->addr_lo, entry->data);
@@ -1183,6 +1207,10 @@ static void assigned_dev_pci_write_config(PCIDevice *pci_dev, uint32_t address,
if (range_covers_byte(address, len,
pci_dev->msi_cap + PCI_MSI_FLAGS)) {
assigned_dev_update_msi(pci_dev);
+ } else if (ranges_overlap(address, len,
+ pci_dev->msi_cap + PCI_MSI_ADDRESS_LO,
+ 10 - PCI_MSI_ADDRESS_LO)) {
+ assigned_dev_update_msi_msg(pci_dev);
}
}
if (assigned_dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) {
@@ -1561,6 +1589,7 @@ static void assigned_dev_msix_mmio_write(void *opaque, hwaddr addr,
msg.address = entry->addr_lo |
((uint64_t)entry->addr_hi << 32);
msg.data = entry->data;
+ adev->msi[i].msg = msg;
ret = kvm_irqchip_update_msi_route(kvm_state,
adev->msi[i].virq, msg);
next prev parent reply other threads:[~2012-11-27 22:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 22:00 [Qemu-devel] [RFC PATCH 0/4] MSI affinity for assigned devices Alex Williamson
2012-11-27 22:00 ` [Qemu-devel] [RFC PATCH 1/4] kvm: Stub kvm_irqchip_update_msi_route Alex Williamson
2012-11-27 22:00 ` [Qemu-devel] [RFC PATCH 2/4] vfio-pci: Add support for MSI affinity Alex Williamson
2012-11-27 22:00 ` [Qemu-devel] [RFC PATCH 3/4] pci-assign: Refactor MSI virq array Alex Williamson
2012-11-27 22:01 ` Alex Williamson [this message]
2012-11-27 23:08 ` [Qemu-devel] [RFC PATCH 0/4] MSI affinity for assigned devices Jan Kiszka
2012-11-27 23:21 ` Alex Williamson
2012-11-29 6:57 ` Jan Kiszka
2012-11-28 16:32 ` [Qemu-devel] PCI device pass through support Krishna J
2012-11-28 17:00 ` Alex Williamson
2013-01-07 20:14 ` [Qemu-devel] [RFC PATCH 0/4] MSI affinity for assigned devices Krishna J
2013-01-07 20:52 ` Alex Williamson
2013-01-07 21:22 ` Krishna J
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=20121127220101.5751.96242.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.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).