From patchwork Wed Mar 21 22:39:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 10300495 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 EF81D600F6 for ; Wed, 21 Mar 2018 22:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE507297AF for ; Wed, 21 Mar 2018 22:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D039A29883; Wed, 21 Mar 2018 22:39:54 +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 7EB71297AF for ; Wed, 21 Mar 2018 22:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754017AbeCUWjm (ORCPT ); Wed, 21 Mar 2018 18:39:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33634 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753865AbeCUWjk (ORCPT ); Wed, 21 Mar 2018 18:39:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59E5780469; Wed, 21 Mar 2018 22:39:40 +0000 (UTC) Received: from gimli.home (ovpn-116-103.phx2.redhat.com [10.3.116.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id A73D381408; Wed, 21 Mar 2018 22:39:36 +0000 (UTC) Subject: [PATCH v2] 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: Wed, 21 Mar 2018 16:39:36 -0600 Message-ID: <20180321223147.1305.30569.stgit@gimli.home> User-Agent: StGit/0.18-102-gdf9f MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 21 Mar 2018 22:39: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 and remove the free pass for non-i40e Intel devices. Reported-by: Arjun Vynipadath Fixes: 2170dd04316e ("vfio-pci: Mask INTx if a device is not capabable of enabling it") Acked-by: Casey Leedom Signed-off-by: Alex Williamson --- v2: One more quick spin on this, barring issues I'd like to get a pull request in for rc7. The regression was originally masked because I generally test on Intel SR-IOV, which doesn't exhibit the problem because it traps in the switch case above, as vendor quirks were the original intent of this funciton. v2 drops that default case so that all vendors reach the pdev->irq test, which I think was also the original intent of 2170dd04316e. Leaving Casey's ack since it shouldn't affect testing on non-Intel parts. drivers/vfio/pci/vfio_pci.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index b0f759476900..dccc2feca6ec 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) { @@ -202,12 +204,21 @@ static bool vfio_pci_nointx(struct pci_dev *pdev) case 0x1583 ... 0x158b: case 0x37d0 ... 0x37d2: return true; - default: - return false; } } - 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;