From patchwork Wed Oct 22 15:13:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Blaschka X-Patchwork-Id: 402179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EA6D314001A for ; Thu, 23 Oct 2014 02:15:46 +1100 (AEDT) Received: from localhost ([::1]:58133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgxdY-0001xG-Ck for incoming@patchwork.ozlabs.org; Wed, 22 Oct 2014 11:15:44 -0400 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 d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 22 Oct 2014 16:13:40 +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 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s9MFDbAp014973; Wed, 22 Oct 2014 09:13:37 -0600 From: Frank Blaschka To: alex.williamson@redhat.com Date: Wed, 22 Oct 2014 17:13:35 +0200 Message-Id: <1413990815-40479-1-git-send-email-blaschka@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.5.5 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14102215-0013-0000-0000-0000019080D2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.109 Cc: pbonzini@redhat.com, Frank Blaschka , agraf@suse.de, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] vfio: check if host device supports INTx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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);