From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgxbm-0007H1-Kp for qemu-devel@nongnu.org; Wed, 22 Oct 2014 11:14:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xgxbb-0005UK-1g for qemu-devel@nongnu.org; Wed, 22 Oct 2014 11:13:54 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:33257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgxba-0005Tz-PI for qemu-devel@nongnu.org; Wed, 22 Oct 2014 11:13:42 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 Oct 2014 16:13:41 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id A82E7219005E for ; Wed, 22 Oct 2014 16:13:15 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s9MFDdWN56426668 for ; Wed, 22 Oct 2014 15:13:39 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s9MFDcYJ015013 for ; Wed, 22 Oct 2014 09:13:38 -0600 From: Frank Blaschka Date: Wed, 22 Oct 2014 17:13:35 +0200 Message-Id: <1413990815-40479-1-git-send-email-blaschka@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] vfio: check if host device supports INTx List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: alex.williamson@redhat.com Cc: pbonzini@redhat.com, Frank Blaschka , agraf@suse.de, qemu-devel@nongnu.org From: Frank Blaschka 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 --- 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