Patchwork [for-1.3,v2] vfio-pci: Don't use kvm_irqchip_in_kernel

login
register
mail settings
Submitter Alex Williamson
Date Nov. 30, 2012, 7:50 p.m.
Message ID <20121130195006.4188.4903.stgit@bling.home>
Download mbox | patch
Permalink /patch/203032/
State New
Headers show

Comments

Alex Williamson - Nov. 30, 2012, 7:50 p.m.
kvm_irqchip_in_kernel() has an architecture specific meaning, so
we shouldn't be using it to determine whether to enabled KVM INTx
bypass.  kvm_irqfds_enabled() seems most appropriate.  Also use this
to protect our other call to kvm_check_extension() as that explodes
when KVM isn't enabled.  Post 1.3 we might think about adding a
kvm_intx_via_irqfd_enabled() helper.

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

Anthony, please include for 1.3.  Thanks.

 hw/vfio_pci.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
index 7c27834..fbfe670 100644
--- a/hw/vfio_pci.c
+++ b/hw/vfio_pci.c
@@ -275,7 +275,7 @@  static void vfio_enable_intx_kvm(VFIODevice *vdev)
     int ret, argsz;
     int32_t *pfd;
 
-    if (!kvm_irqchip_in_kernel() ||
+    if (!kvm_irqfds_enabled() ||
         vdev->intx.route.mode != PCI_INTX_ENABLED ||
         !kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
         return;
@@ -438,7 +438,8 @@  static int vfio_enable_intx(VFIODevice *vdev)
      * Only conditional to avoid generating error messages on platforms
      * where we won't actually use the result anyway.
      */
-    if (kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
+    if (kvm_irqfds_enabled() &&
+        kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
         vdev->intx.route = pci_device_route_intx_to_irq(&vdev->pdev,
                                                         vdev->intx.pin);
     }