netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] cxgb4: Fix for SR-IOV VF initialization
@ 2014-07-22 10:56 Hariprasad Shenai
  2014-07-22 22:34 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Hariprasad Shenai @ 2014-07-22 10:56 UTC (permalink / raw)
  To: netdev; +Cc: davem, leedom, nirranjan, kumaras, anish, Hariprasad Shenai

Commit 35b1de5 ("rdma/cxgb4: Fixes cxgb4 probe failure in VM when PF is exposed
through PCI Passthrough") introduced a regression, where VF failed to
initialize. This commit fixes it.

Signed-off-by: Casey Leedom <leedom@chelsio.com>
Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   51 +++++++++++++++++++++--
 1 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 8b46534..c78e6b2 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -6695,11 +6695,33 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		attach_ulds(adapter);
 
 #ifdef CONFIG_PCI_IOV
-	if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0)
-		if (pci_enable_sriov(pdev, num_vf[func]) == 0)
-			dev_info(&pdev->dev,
+	for (func = 0; func < ARRAY_SIZE(num_vf); func++) {
+		struct pci_dev *pf;
+
+		if (num_vf[func] <= 0)
+			continue;
+
+		pf = pci_get_slot(pdev->bus,
+				  PCI_DEVFN(PCI_SLOT(pdev->devfn),
+					    func));
+		if (pf == NULL) {
+			dev_warn(&pdev->dev, "failed to find PF%d; not"
+				 " enabling %d virtual functions\n",
+				 func, num_vf[func]);
+			continue;
+		}
+		err = pci_enable_sriov(pf, num_vf[func]);
+		if (err < 0)
+			dev_warn(&pf->dev, "failed to instantiate %d"
+				 " virtual functions; err=%d\n",
+				 num_vf[func], err);
+		else
+			dev_info(&pf->dev,
 				 "instantiated %u virtual functions\n",
 				 num_vf[func]);
+
+		pci_dev_put(pf);
+	}
 #endif
 	return 0;
 
@@ -6725,8 +6747,29 @@ static void remove_one(struct pci_dev *pdev)
 	struct adapter *adapter = pci_get_drvdata(pdev);
 
 #ifdef CONFIG_PCI_IOV
-	pci_disable_sriov(pdev);
+	/* Loop accross SR-IOV PFs to see if any VFs need to be
+	 * uninstantiated.
+	 */
+	int func;
+
+	for (func = 0; func < ARRAY_SIZE(num_vf); func++) {
+		struct pci_dev *pf;
+
+		if (num_vf[func] <= 0)
+			continue;
 
+		pf = pci_get_slot(pdev->bus,
+				  PCI_DEVFN(PCI_SLOT(pdev->devfn),
+					    func));
+		if (pf == NULL) {
+			dev_warn(&pdev->dev, "failed to find PF%d; not"
+				 " disabling %d virtual functions\n",
+				 func, num_vf[func]);
+			continue;
+		}
+		pci_disable_sriov(pf);
+		pci_dev_put(pf);
+	}
 #endif
 
 	if (adapter) {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-23  3:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-22 10:56 [PATCH net-next] cxgb4: Fix for SR-IOV VF initialization Hariprasad Shenai
2014-07-22 22:34 ` David Miller
2014-07-22 22:47   ` Casey Leedom
2014-07-23  3:01   ` Alexander Duyck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).