mlx4: Split restart_one into two functions
authorJiri Pirko <jiri@mellanox.com>
Thu, 12 Sep 2019 08:49:44 +0000 (10:49 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 13 Sep 2019 20:11:14 +0000 (22:11 +0200)
Split the function restart_one into two functions and separate teardown
and buildup.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/catas.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/mlx4.h

index 87e90b5d4d7d03e1ad8fb26d0d3921b33cd4aa26..5b11557f1ae477dc4223107dc7a36edb80375878 100644 (file)
@@ -210,7 +210,7 @@ static void mlx4_handle_error_state(struct mlx4_dev_persistent *persist)
        mutex_lock(&persist->interface_state_mutex);
        if (persist->interface_state & MLX4_INTERFACE_STATE_UP &&
            !(persist->interface_state & MLX4_INTERFACE_STATE_DELETION)) {
-               err = mlx4_restart_one(persist->pdev, false, NULL);
+               err = mlx4_restart_one(persist->pdev);
                mlx4_info(persist->dev, "mlx4_restart_one was ended, ret=%d\n",
                          err);
        }
index 07c204bd3fc41bf41a6c8440545b65dea8cfcc76..a39c647c12dcb25f188ccb90f1a326d45735d1c5 100644 (file)
@@ -3931,6 +3931,10 @@ static void mlx4_devlink_param_load_driverinit_values(struct devlink *devlink)
        }
 }
 
+static void mlx4_restart_one_down(struct pci_dev *pdev);
+static int mlx4_restart_one_up(struct pci_dev *pdev, bool reload,
+                              struct devlink *devlink);
+
 static int mlx4_devlink_reload(struct devlink *devlink,
                               struct netlink_ext_ack *extack)
 {
@@ -3941,9 +3945,11 @@ static int mlx4_devlink_reload(struct devlink *devlink,
 
        if (persist->num_vfs)
                mlx4_warn(persist->dev, "Reload performed on PF, will cause reset on operating Virtual Functions\n");
-       err = mlx4_restart_one(persist->pdev, true, devlink);
+       mlx4_restart_one_down(persist->pdev);
+       err = mlx4_restart_one_up(persist->pdev, true, devlink);
        if (err)
-               mlx4_err(persist->dev, "mlx4_restart_one failed, ret=%d\n", err);
+               mlx4_err(persist->dev, "mlx4_restart_one_up failed, ret=%d\n",
+                        err);
 
        return err;
 }
@@ -4163,7 +4169,13 @@ static int restore_current_port_types(struct mlx4_dev *dev,
        return err;
 }
 
-int mlx4_restart_one(struct pci_dev *pdev, bool reload, struct devlink *devlink)
+static void mlx4_restart_one_down(struct pci_dev *pdev)
+{
+       mlx4_unload_one(pdev);
+}
+
+static int mlx4_restart_one_up(struct pci_dev *pdev, bool reload,
+                              struct devlink *devlink)
 {
        struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
        struct mlx4_dev  *dev  = persist->dev;
@@ -4175,7 +4187,6 @@ int mlx4_restart_one(struct pci_dev *pdev, bool reload, struct devlink *devlink)
        total_vfs = dev->persist->num_vfs;
        memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
 
-       mlx4_unload_one(pdev);
        if (reload)
                mlx4_devlink_param_load_driverinit_values(devlink);
        err = mlx4_load_one(pdev, pci_dev_data, total_vfs, nvfs, priv, 1);
@@ -4194,6 +4205,12 @@ int mlx4_restart_one(struct pci_dev *pdev, bool reload, struct devlink *devlink)
        return err;
 }
 
+int mlx4_restart_one(struct pci_dev *pdev)
+{
+       mlx4_restart_one_down(pdev);
+       return mlx4_restart_one_up(pdev, false, NULL);
+}
+
 #define MLX_SP(id) { PCI_VDEVICE(MELLANOX, id), MLX4_PCI_DEV_FORCE_SENSE_PORT }
 #define MLX_VF(id) { PCI_VDEVICE(MELLANOX, id), MLX4_PCI_DEV_IS_VF }
 #define MLX_GN(id) { PCI_VDEVICE(MELLANOX, id), 0 }
index 23f1b5b512c2198cb664167e42fb91ff9c549f13..527b52e482768ea4d0503f8e94d849f17f0964b2 100644 (file)
@@ -1043,8 +1043,7 @@ int mlx4_catas_init(struct mlx4_dev *dev);
 void mlx4_catas_end(struct mlx4_dev *dev);
 int mlx4_crdump_init(struct mlx4_dev *dev);
 void mlx4_crdump_end(struct mlx4_dev *dev);
-int mlx4_restart_one(struct pci_dev *pdev, bool reload,
-                    struct devlink *devlink);
+int mlx4_restart_one(struct pci_dev *pdev);
 int mlx4_register_device(struct mlx4_dev *dev);
 void mlx4_unregister_device(struct mlx4_dev *dev);
 void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,