qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Frank Blaschka <blaschka@linux.vnet.ibm.com>
To: alex.williamson@redhat.com
Cc: pbonzini@redhat.com, Frank Blaschka <frank.blaschka@de.ibm.com>,
	agraf@suse.de, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] vfio: check if host device supports INTx
Date: Wed, 22 Oct 2014 17:13:35 +0200	[thread overview]
Message-ID: <1413990815-40479-1-git-send-email-blaschka@linux.vnet.ibm.com> (raw)

From: Frank Blaschka <frank.blaschka@de.ibm.com>

Let the kernel announce if INTx is available. Yes, there are platforms
(e.g. s390) which do not support INTx.

Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
---
 hw/misc/vfio.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index d66f3d2..3e9600b 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -109,6 +109,7 @@ typedef struct VFIOVGA {
 } VFIOVGA;
 
 typedef struct VFIOINTx {
+    bool available; /* intx available */
     bool pending; /* interrupt pending */
     bool kvm_accel; /* set when QEMU bypass through KVM enabled */
     uint8_t pin; /* which pin to pull for qemu_set_irq */
@@ -554,7 +555,7 @@ static int vfio_enable_intx(VFIODevice *vdev)
     struct vfio_irq_set *irq_set;
     int32_t *pfd;
 
-    if (!pin) {
+    if (!pin || !vdev->intx.available) {
         return 0;
     }
 
@@ -4032,6 +4033,21 @@ static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev)
                      vdev->host.function);
     }
 
+    irq_info.index = VFIO_PCI_INTX_IRQ_INDEX;
+    ret = ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
+    if (ret) {
+        /*
+         * This can fail for an old kernel or legacy PCI dev
+         * we assume intx is available
+         */
+        vdev->intx.available = true;
+        ret = 0;
+    } else if (irq_info.count == 0) {
+        vdev->intx.available = false;
+    } else {
+        vdev->intx.available = true;
+    }
+
 error:
     if (ret) {
         QLIST_REMOVE(vdev, next);
-- 
1.8.5.5

             reply	other threads:[~2014-10-22 15:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-22 15:13 Frank Blaschka [this message]
2014-10-22 17:17 ` [Qemu-devel] [PATCH] vfio: check if host device supports INTx Alex Williamson
2014-10-23  8:21   ` Frank Blaschka
2014-10-23 14:26     ` Alex Williamson
2014-10-24  9:28       ` Frank Blaschka

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=1413990815-40479-1-git-send-email-blaschka@linux.vnet.ibm.com \
    --to=blaschka@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=frank.blaschka@de.ibm.com \
    --cc=pbonzini@redhat.com \
    --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).