aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Morgenstein <jackm@dev.mellanox.co.il>2014-09-30 05:03:47 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-30 16:27:49 -0400
commitbbb07af4cdfd0c154db4c636927bd262f71c6401 (patch)
tree9f08f3e7096521d7173c964a56ceafd272c9eb33
parent57f5877c11b244ff2315f4ba0e57b54fe013581f (diff)
net/mlx4_core: Don't disable SRIOV if there are active VFs
When unloading the host driver while there are VFs active on VMs, the PF driver disabled sriov anyway, causing kernel crashes. We now leave SRIOV enabled, to avoid that. When the driver is reloaded, __mlx4_init_one is invoked on the PF. It now checks to see if SRIOV is already enabled on the PF -- and if so does not enable sriov again. Signed-off-by: Tal Alon <talal@mellanox.com> Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 1f10023af1db..4e9857b409f3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2272,6 +2272,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
2272 unsigned total_vfs = 0; 2272 unsigned total_vfs = 0;
2273 int sriov_initialized = 0; 2273 int sriov_initialized = 0;
2274 unsigned int i; 2274 unsigned int i;
2275 int existing_vfs = 0;
2275 2276
2276 pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev)); 2277 pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev));
2277 2278
@@ -2431,7 +2432,15 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
2431 err = 0; 2432 err = 0;
2432 } else { 2433 } else {
2433 atomic_inc(&pf_loading); 2434 atomic_inc(&pf_loading);
2434 err = pci_enable_sriov(pdev, total_vfs); 2435 existing_vfs = pci_num_vf(pdev);
2436 if (existing_vfs) {
2437 err = 0;
2438 if (existing_vfs != total_vfs)
2439 mlx4_err(dev, "SR-IOV was already enabled, but with num_vfs (%d) different than requested (%d)\n",
2440 existing_vfs, total_vfs);
2441 } else {
2442 err = pci_enable_sriov(pdev, total_vfs);
2443 }
2435 if (err) { 2444 if (err) {
2436 mlx4_err(dev, "Failed to enable SR-IOV, continuing without SR-IOV (err = %d)\n", 2445 mlx4_err(dev, "Failed to enable SR-IOV, continuing without SR-IOV (err = %d)\n",
2437 err); 2446 err);
@@ -2645,7 +2654,7 @@ err_cmd:
2645 mlx4_cmd_cleanup(dev); 2654 mlx4_cmd_cleanup(dev);
2646 2655
2647err_sriov: 2656err_sriov:
2648 if (dev->flags & MLX4_FLAG_SRIOV) 2657 if (dev->flags & MLX4_FLAG_SRIOV && !existing_vfs)
2649 pci_disable_sriov(pdev); 2658 pci_disable_sriov(pdev);
2650 2659
2651err_rel_own: 2660err_rel_own:
@@ -2693,16 +2702,21 @@ static void __mlx4_remove_one(struct pci_dev *pdev)
2693 struct mlx4_priv *priv = mlx4_priv(dev); 2702 struct mlx4_priv *priv = mlx4_priv(dev);
2694 int pci_dev_data; 2703 int pci_dev_data;
2695 int p; 2704 int p;
2705 int active_vfs = 0;
2696 2706
2697 if (priv->removed) 2707 if (priv->removed)
2698 return; 2708 return;
2699 2709
2700 pci_dev_data = priv->pci_dev_data; 2710 pci_dev_data = priv->pci_dev_data;
2701 2711
2702 /* in SRIOV it is not allowed to unload the pf's 2712 /* Disabling SR-IOV is not allowed while there are active vf's */
2703 * driver while there are alive vf's */ 2713 if (mlx4_is_master(dev)) {
2704 if (mlx4_is_master(dev) && mlx4_how_many_lives_vf(dev)) 2714 active_vfs = mlx4_how_many_lives_vf(dev);
2705 pr_warn("Removing PF when there are assigned VF's !!!\n"); 2715 if (active_vfs) {
2716 pr_warn("Removing PF when there are active VF's !!\n");
2717 pr_warn("Will not disable SR-IOV.\n");
2718 }
2719 }
2706 mlx4_stop_sense(dev); 2720 mlx4_stop_sense(dev);
2707 mlx4_unregister_device(dev); 2721 mlx4_unregister_device(dev);
2708 2722
@@ -2745,7 +2759,7 @@ static void __mlx4_remove_one(struct pci_dev *pdev)
2745 2759
2746 if (dev->flags & MLX4_FLAG_MSI_X) 2760 if (dev->flags & MLX4_FLAG_MSI_X)
2747 pci_disable_msix(pdev); 2761 pci_disable_msix(pdev);
2748 if (dev->flags & MLX4_FLAG_SRIOV) { 2762 if (dev->flags & MLX4_FLAG_SRIOV && !active_vfs) {
2749 mlx4_warn(dev, "Disabling SR-IOV\n"); 2763 mlx4_warn(dev, "Disabling SR-IOV\n");
2750 pci_disable_sriov(pdev); 2764 pci_disable_sriov(pdev);
2751 dev->num_vfs = 0; 2765 dev->num_vfs = 0;