From: Alex Williamson <alex.williamson@redhat.com>
To: kvm@vger.kernel.org
Cc: alex.williamson@redhat.com, avi@redhat.com, mst@redhat.com,
jan.kiszka@siemens.com, shashidhar.patil@gmail.com
Subject: [PATCH v2 6/8] pci-assign: Allocate entries for all MSI-X vectors
Date: Tue, 31 Jan 2012 22:32:59 -0700 [thread overview]
Message-ID: <20120201053259.9843.54385.stgit@bling.home> (raw)
In-Reply-To: <20120201052203.9843.80792.stgit@bling.home>
We still only initialize the number used in the host. This lets
us do direct access based on MSI-X table offset on write without
needing to translate between physical vector space and initalized
vector space. It's expected that guests will typically use the
majority of the available vectors, so we're likely not allocating
significantly more entires than are used.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/device-assignment.c | 44 ++++++++++++++++++++++----------------------
1 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index a33e5b9..fe10a23 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -627,8 +627,11 @@ static void free_dev_irq_entries(AssignedDevice *dev)
{
int i;
- for (i = 0; i < dev->irq_entries_nr; i++)
- kvm_del_routing_entry(&dev->entry[i]);
+ for (i = 0; i < dev->irq_entries_nr; i++) {
+ if (dev->entry[i].type) {
+ kvm_del_routing_entry(&dev->entry[i]);
+ }
+ }
g_free(dev->entry);
dev->entry = NULL;
dev->irq_entries_nr = 0;
@@ -976,7 +979,7 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
if (entry->data == 0) {
continue;
}
- entries_nr ++;
+ entries_nr++;
}
if (entries_nr == 0) {
@@ -993,15 +996,13 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
}
free_dev_irq_entries(adev);
- adev->irq_entries_nr = entries_nr;
- adev->entry = g_malloc0(entries_nr * sizeof(*(adev->entry)));
+
+ adev->irq_entries_nr = adev->msix_max;
+ adev->entry = g_malloc0(adev->msix_max * sizeof(*(adev->entry)));
msix_entry.assigned_dev_id = msix_nr.assigned_dev_id;
- entries_nr = 0;
entry = adev->msix_table;
for (i = 0; i < adev->msix_max; i++, entry++) {
- if (entries_nr >= msix_nr.entry_nr)
- break;
if (entry->data == 0) {
continue;
}
@@ -1010,26 +1011,25 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
if (r < 0)
return r;
- adev->entry[entries_nr].gsi = r;
- adev->entry[entries_nr].type = KVM_IRQ_ROUTING_MSI;
- adev->entry[entries_nr].flags = 0;
- adev->entry[entries_nr].u.msi.address_lo = entry->addr_lo;
- adev->entry[entries_nr].u.msi.address_hi = entry->addr_hi;
- adev->entry[entries_nr].u.msi.data = entry->data;
- DEBUG("MSI-X data 0x%x, MSI-X addr_lo 0x%x\n!",
- entry->data, entry->addr_lo);
- kvm_add_routing_entry(&adev->entry[entries_nr]);
-
- msix_entry.gsi = adev->entry[entries_nr].gsi;
+ adev->entry[i].gsi = r;
+ adev->entry[i].type = KVM_IRQ_ROUTING_MSI;
+ adev->entry[i].flags = 0;
+ adev->entry[i].u.msi.address_lo = entry->addr_lo;
+ adev->entry[i].u.msi.address_hi = entry->addr_hi;
+ adev->entry[i].u.msi.data = entry->data;
+
+ DEBUG("MSI-X vector %d, gsi %d, addr %08x_%08x, data %08x\n", i,
+ r, entry->addr_hi, entry->addr_lo, entry->data);
+
+ kvm_add_routing_entry(&adev->entry[i]);
+
+ msix_entry.gsi = adev->entry[i].gsi;
msix_entry.entry = i;
r = kvm_assign_set_msix_entry(kvm_state, &msix_entry);
if (r) {
fprintf(stderr, "fail to set MSI-X entry! %s\n", strerror(-r));
break;
}
- DEBUG("MSI-X entry gsi 0x%x, entry %d\n!",
- msix_entry.gsi, msix_entry.entry);
- entries_nr ++;
}
if (r == 0 && kvm_commit_irq_routes() < 0) {
next prev parent reply other threads:[~2012-02-01 5:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-01 5:32 [PATCH v2 0/8] pci-assign: better MSI-X table support Alex Williamson
2012-02-01 5:32 ` [PATCH v2 1/8] pci-assign: Fix warnings with DEBUG enabled Alex Williamson
2012-02-01 5:32 ` [PATCH v2 2/8] pci-assign: Update MSI-X MMIO to Memory API Alex Williamson
2012-02-01 5:32 ` [PATCH v2 3/8] pci-assign: Use struct for MSI-X table Alex Williamson
2012-02-01 5:32 ` [PATCH v2 4/8] pci-assign: Only calculate maximum MSI-X vector entries once Alex Williamson
2012-02-01 5:32 ` [PATCH v2 5/8] pci-assign: Proper initialization for MSI-X table Alex Williamson
2012-02-01 5:32 ` Alex Williamson [this message]
2012-02-01 5:33 ` [PATCH v2 7/8] pci-assign: Use MSIX_PAGE_SIZE Alex Williamson
2012-02-01 5:33 ` [PATCH v2 8/8] pci-assign: Update MSI-X config based on table writes Alex Williamson
2012-02-01 7:22 ` Michael S. Tsirkin
2012-02-01 13:48 ` Alex Williamson
2012-02-01 14:13 ` Jan Kiszka
2012-02-01 15:13 ` Michael S. Tsirkin
2012-02-01 7:25 ` Michael S. Tsirkin
2012-02-01 13:51 ` Alex Williamson
2012-02-07 20:04 ` [PATCH v2 0/8] pci-assign: better MSI-X table support Marcelo Tosatti
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=20120201053259.9843.54385.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=shashidhar.patil@gmail.com \
/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).