public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2]  pci-assign: Fix MSI-X support
@ 2011-09-22 18:08 Alex Williamson
  2011-09-22 18:09 ` [PATCH v2 1/2] pci-assign: Re-order initfn for memory API Alex Williamson
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alex Williamson @ 2011-09-22 18:08 UTC (permalink / raw)
  To: kvm; +Cc: jan.kiszka, avi, yongjie.ren, alex.williamson

Assigned device MSI-X support hasn't been working, this fixes
it.  I believe this should also fix:

https://bugs.launchpad.net/qemu/+bug/830558

v2:
   Incorporate comments from Jan

WRT exposing KVM_CAP_DEVICE_MSIX, I'll send a patch with a big
comment noting that we can't rely on it for older kernels.  Maybe
some day we'll draw a line in the sand and be able to use it.
Thanks,

Alex

---

Alex Williamson (2):
      pci-assign: Fix MSI-X capability test
      pci-assign: Re-order initfn for memory API


 hw/device-assignment.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] pci-assign: Re-order initfn for memory API
  2011-09-22 18:08 [PATCH v2 0/2] pci-assign: Fix MSI-X support Alex Williamson
@ 2011-09-22 18:09 ` Alex Williamson
  2011-09-22 18:09 ` [PATCH v2 2/2] pci-assign: Fix MSI-X capability test Alex Williamson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2011-09-22 18:09 UTC (permalink / raw)
  To: kvm; +Cc: jan.kiszka, avi, yongjie.ren, alex.williamson

We now need to scan PCI capabilities and setup an MSI-X page
before we walk the device resources since the overlay is now
setup during init instead of at the first mapping by the guest.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/device-assignment.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 288f80c..137c409 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1603,6 +1603,17 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
         goto out;
     }
 
+    if (assigned_device_pci_cap_init(pci_dev) < 0) {
+        goto out;
+    }
+
+    /* intercept MSI-X entry page in the MMIO */
+    if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) {
+        if (assigned_dev_register_msix_mmio(dev)) {
+            goto out;
+        }
+    }
+
     /* handle real device's MMIO/PIO BARs */
     if (assigned_dev_register_regions(dev->real_device.regions,
                                       dev->real_device.region_number,
@@ -1618,9 +1629,6 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
     dev->h_busnr = dev->host.bus;
     dev->h_devfn = PCI_DEVFN(dev->host.dev, dev->host.func);
 
-    if (assigned_device_pci_cap_init(pci_dev) < 0)
-        goto out;
-
     /* assign device to guest */
     r = assign_device(dev);
     if (r < 0)
@@ -1631,11 +1639,6 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
     if (r < 0)
         goto assigned_out;
 
-    /* intercept MSI-X entry page in the MMIO */
-    if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX)
-        if (assigned_dev_register_msix_mmio(dev))
-            goto assigned_out;
-
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] pci-assign: Fix MSI-X capability test
  2011-09-22 18:08 [PATCH v2 0/2] pci-assign: Fix MSI-X support Alex Williamson
  2011-09-22 18:09 ` [PATCH v2 1/2] pci-assign: Re-order initfn for memory API Alex Williamson
@ 2011-09-22 18:09 ` Alex Williamson
  2011-09-23 17:00 ` [PATCH v2 0/2] pci-assign: Fix MSI-X support Jan Kiszka
  2011-10-03 19:39 ` Marcelo Tosatti
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2011-09-22 18:09 UTC (permalink / raw)
  To: kvm; +Cc: jan.kiszka, avi, yongjie.ren, alex.williamson

Commit c4525754 added a capability check for KVM_CAP_DEVICE_MSIX,
which is unfortunately not exposed, resulting in MSIX never
being listed as a capability.  This breaks anything depending on
MSIX, such as igbvf.  Instead let's use a dummy call to
KVM_ASSIGN_SET_MSIX_NR which will return -EFAULT if the call
exists.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/device-assignment.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 137c409..f0a6ca9 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1212,7 +1212,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
     }
     /* Expose MSI-X capability */
     pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0);
-    if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_DEVICE_MSIX)) {
+    /* Would really like to test kvm_check_extension(, KVM_CAP_DEVICE_MSIX),
+     * but the kernel doesn't expose it.  Instead do a dummy call to
+     * KVM_ASSIGN_SET_MSIX_NR to see if it exists. */
+    if (pos != 0 && kvm_assign_set_msix_nr(kvm_state, NULL) == -EFAULT) {
         int bar_nr;
         uint32_t msix_table_entry;
 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2]  pci-assign: Fix MSI-X support
  2011-09-22 18:08 [PATCH v2 0/2] pci-assign: Fix MSI-X support Alex Williamson
  2011-09-22 18:09 ` [PATCH v2 1/2] pci-assign: Re-order initfn for memory API Alex Williamson
  2011-09-22 18:09 ` [PATCH v2 2/2] pci-assign: Fix MSI-X capability test Alex Williamson
@ 2011-09-23 17:00 ` Jan Kiszka
  2011-10-03 19:39 ` Marcelo Tosatti
  3 siblings, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2011-09-23 17:00 UTC (permalink / raw)
  To: Alex Williamson
  Cc: kvm@vger.kernel.org, avi@redhat.com, yongjie.ren@intel.com

On 2011-09-22 20:08, Alex Williamson wrote:
> Assigned device MSI-X support hasn't been working, this fixes
> it.  I believe this should also fix:
> 
> https://bugs.launchpad.net/qemu/+bug/830558
> 
> v2:
>    Incorporate comments from Jan

Looks good.

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2]  pci-assign: Fix MSI-X support
  2011-09-22 18:08 [PATCH v2 0/2] pci-assign: Fix MSI-X support Alex Williamson
                   ` (2 preceding siblings ...)
  2011-09-23 17:00 ` [PATCH v2 0/2] pci-assign: Fix MSI-X support Jan Kiszka
@ 2011-10-03 19:39 ` Marcelo Tosatti
  3 siblings, 0 replies; 5+ messages in thread
From: Marcelo Tosatti @ 2011-10-03 19:39 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, jan.kiszka, avi, yongjie.ren

On Thu, Sep 22, 2011 at 12:08:55PM -0600, Alex Williamson wrote:
> Assigned device MSI-X support hasn't been working, this fixes
> it.  I believe this should also fix:
> 
> https://bugs.launchpad.net/qemu/+bug/830558
> 
> v2:
>    Incorporate comments from Jan
> 
> WRT exposing KVM_CAP_DEVICE_MSIX, I'll send a patch with a big
> comment noting that we can't rely on it for older kernels.  Maybe
> some day we'll draw a line in the sand and be able to use it.
> Thanks,
> 
> Alex

Applied, thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-03 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-22 18:08 [PATCH v2 0/2] pci-assign: Fix MSI-X support Alex Williamson
2011-09-22 18:09 ` [PATCH v2 1/2] pci-assign: Re-order initfn for memory API Alex Williamson
2011-09-22 18:09 ` [PATCH v2 2/2] pci-assign: Fix MSI-X capability test Alex Williamson
2011-09-23 17:00 ` [PATCH v2 0/2] pci-assign: Fix MSI-X support Jan Kiszka
2011-10-03 19:39 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox