Commit b4c1df93 authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: provision VF resources before enabling SR-IOV

When the PF driver calls pci_enable_sriov(), the VFs may be probed
inline before the call returns. So, the resources required for all VFs
must be provisioned by the PF driver *before* calling pci_enable_sriov();
else, VF probe will fail.
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent de9c9f86
...@@ -2783,6 +2783,8 @@ static void be_vf_clear(struct be_adapter *adapter) ...@@ -2783,6 +2783,8 @@ static void be_vf_clear(struct be_adapter *adapter)
goto done; goto done;
} }
pci_disable_sriov(adapter->pdev);
for_all_vfs(adapter, vf_cfg, vf) { for_all_vfs(adapter, vf_cfg, vf) {
if (lancer_chip(adapter)) if (lancer_chip(adapter))
be_cmd_set_mac_list(adapter, NULL, 0, vf + 1); be_cmd_set_mac_list(adapter, NULL, 0, vf + 1);
...@@ -2792,7 +2794,6 @@ static void be_vf_clear(struct be_adapter *adapter) ...@@ -2792,7 +2794,6 @@ static void be_vf_clear(struct be_adapter *adapter)
be_cmd_if_destroy(adapter, vf_cfg->if_handle, vf + 1); be_cmd_if_destroy(adapter, vf_cfg->if_handle, vf + 1);
} }
pci_disable_sriov(adapter->pdev);
done: done:
kfree(adapter->vf_cfg); kfree(adapter->vf_cfg);
adapter->num_vfs = 0; adapter->num_vfs = 0;
...@@ -2889,13 +2890,8 @@ static int be_vf_setup(struct be_adapter *adapter) ...@@ -2889,13 +2890,8 @@ static int be_vf_setup(struct be_adapter *adapter)
dev_info(dev, "Device supports %d VFs and not %d\n", dev_info(dev, "Device supports %d VFs and not %d\n",
adapter->dev_num_vfs, num_vfs); adapter->dev_num_vfs, num_vfs);
adapter->num_vfs = min_t(u16, num_vfs, adapter->dev_num_vfs); adapter->num_vfs = min_t(u16, num_vfs, adapter->dev_num_vfs);
if (!adapter->num_vfs)
status = pci_enable_sriov(adapter->pdev, num_vfs);
if (status) {
dev_err(dev, "SRIOV enable failed\n");
adapter->num_vfs = 0;
return 0; return 0;
}
} }
status = be_vf_setup_init(adapter); status = be_vf_setup_init(adapter);
...@@ -2944,6 +2940,15 @@ static int be_vf_setup(struct be_adapter *adapter) ...@@ -2944,6 +2940,15 @@ static int be_vf_setup(struct be_adapter *adapter)
be_cmd_enable_vf(adapter, vf + 1); be_cmd_enable_vf(adapter, vf + 1);
} }
if (!old_vfs) {
status = pci_enable_sriov(adapter->pdev, adapter->num_vfs);
if (status) {
dev_err(dev, "SRIOV enable failed\n");
adapter->num_vfs = 0;
goto err;
}
}
return 0; return 0;
err: err:
dev_err(dev, "VF setup failed\n"); dev_err(dev, "VF setup failed\n");
...@@ -3198,7 +3203,7 @@ static int be_setup(struct be_adapter *adapter) ...@@ -3198,7 +3203,7 @@ static int be_setup(struct be_adapter *adapter)
be_cmd_set_flow_control(adapter, adapter->tx_fc, be_cmd_set_flow_control(adapter, adapter->tx_fc,
adapter->rx_fc); adapter->rx_fc);
if (be_physfn(adapter) && num_vfs) { if (be_physfn(adapter)) {
if (adapter->dev_num_vfs) if (adapter->dev_num_vfs)
be_vf_setup(adapter); be_vf_setup(adapter);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment