From patchwork Wed May 13 01:35:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Allan, Bruce W" X-Patchwork-Id: 471652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 83780140D1A for ; Wed, 13 May 2015 11:35:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 76813A2F1B; Wed, 13 May 2015 01:35:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oZ86TrMwYQbC; Wed, 13 May 2015 01:35:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id D45B6A2E4B; Wed, 13 May 2015 01:35:53 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 681931BFC0A for ; Wed, 13 May 2015 01:35:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 62391A2E60 for ; Wed, 13 May 2015 01:35:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hWBBteep_Jtn for ; Wed, 13 May 2015 01:35:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by fraxinus.osuosl.org (Postfix) with ESMTP id D6910A2E4B for ; Wed, 13 May 2015 01:35:52 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 12 May 2015 18:35:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,418,1427785200"; d="scan'208";a="728241608" Received: from bwallan-smackover2.jf.intel.com ([134.134.3.159]) by orsmga002.jf.intel.com with ESMTP; 12 May 2015 18:35:52 -0700 Received: from bwallan-smackover2.jf.intel.com (localhost.localdomain [127.0.0.1]) by bwallan-smackover2.jf.intel.com (8.14.8/8.14.8) with ESMTP id t4D1ZoCD010350; Tue, 12 May 2015 18:35:50 -0700 From: Bruce Allan To: kvm@vger.kernel.org Date: Tue, 12 May 2015 18:35:50 -0700 Message-ID: <20150513013550.10328.1416.stgit@bwallan-smackover2.jf.intel.com> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Subject: [Intel-wired-lan] [PATCH] vfio-pci: PCI_DEV_FLAGS_ASSIGNED flag not set when PCI device is assigned X-BeenThere: intel-wired-lan@lists.osuosl.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@lists.osuosl.org Sender: "Intel-wired-lan" A number of PCI device drivers supporting SR-IOV use pci_vfs_assigned() to check if there are any VF devices assigned by a VMM prior to disabling SR-IOV (i.e. bnx2x, be2net, fm10k, i40e, igb, ixgbe, qlcnic). This check works fine with the legacy device assignment (pci-stub enables the device) which calls pci_set_dev_assigned(). The newer VFIO-based assignment (vfio-pci enables device) doesn't call pci_set_dev_assigned() potentially leading to issues in those drivers when disabling SR-IOV with VFs assigned. Add calls to pci_[set|clear]_dev_assigned() to set the flag as expected. Signed-off-by: Bruce Allan --- drivers/vfio/pci/vfio_pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 69fab0f..3f368ce 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -956,6 +956,8 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) return ret; } + pci_set_dev_assigned(pdev); + if (vfio_pci_is_vga(pdev)) { vga_client_register(pdev, vdev, NULL, vfio_pci_set_vga_decode); vga_set_legacy_decoding(pdev, @@ -990,6 +992,8 @@ static void vfio_pci_remove(struct pci_dev *pdev) iommu_group_put(pdev->dev.iommu_group); kfree(vdev); + pci_clear_dev_assigned(pdev); + if (vfio_pci_is_vga(pdev)) { vga_client_register(pdev, NULL, NULL, NULL); vga_set_legacy_decoding(pdev,