From patchwork Thu Mar 15 16:40:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 10285199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DD6360386 for ; Thu, 15 Mar 2018 16:41:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2112D28B61 for ; Thu, 15 Mar 2018 16:41:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15E7528B64; Thu, 15 Mar 2018 16:41:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 982C128B61 for ; Thu, 15 Mar 2018 16:41:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748AbeCOQkl (ORCPT ); Thu, 15 Mar 2018 12:40:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751456AbeCOQkk (ORCPT ); Thu, 15 Mar 2018 12:40:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99FBD40F25; Thu, 15 Mar 2018 16:40:40 +0000 (UTC) Received: from gimli.home (ovpn-117-203.phx2.redhat.com [10.3.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id C35B4600C0; Thu, 15 Mar 2018 16:40:35 +0000 (UTC) Subject: [PATCH] vfio/pci: Quiet broken INTx whining when INTx is unsupported by device From: Alex Williamson To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, aik@ozlabs.ru, alex.williamson@redhat.com, leedom@chelsio.com, ganeshgr@chelsio.com, arjun@chelsio.com, indranil@chelsio.com, nirranjan@chelsio.com Date: Thu, 15 Mar 2018 10:40:35 -0600 Message-ID: <20180315163956.30579.92502.stgit@gimli.home> User-Agent: StGit/0.18-102-gdf9f MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 15 Mar 2018 16:40:40 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The intent of commit 2170dd04316e ("vfio-pci: Mask INTx if a device is not capabable of enabling it") was to disallow the user from seeing that the device supports INTx if the platform is incapable of enabling it. The detection of this case however incorrectly includes devices which natively do not support INTx, such as SR-IOV VFs. We don't need the nointx handling code for such devices, nor do we want to issue a broken INTx masking warning. Check whether the device supports INTx before enabling nointx. Reported-by: Arjun Vynipadath Fixes: 2170dd04316e ("vfio-pci: Mask INTx if a device is not capabable of enabling it") Signed-off-by: Alex Williamson --- drivers/vfio/pci/vfio_pci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index ad18ed266dc0..f2ca24644a2c 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -192,6 +192,8 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev); */ static bool vfio_pci_nointx(struct pci_dev *pdev) { + u8 pin; + switch (pdev->vendor) { case PCI_VENDOR_ID_INTEL: switch (pdev->device) { @@ -207,7 +209,18 @@ static bool vfio_pci_nointx(struct pci_dev *pdev) } } - if (!pdev->irq) + pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin); + + /* + * If the device supports INTx, but it cannot be enabled, invoke + * nointx to mask the pin value and INTx IRQ_INFO to the user. + * + * NB. Generally nointx depends on at least being able to prevent the + * device from generating INTx, so ideally we might check if INTx + * masking is supported, but perhaps we can interpret lack of an irq + * as lack of routing and presume the INTx line is unwired. + */ + if (pin && !pdev->irq) return true; return false;