aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx5/core
diff options
context:
space:
mode:
authorSaeed Mahameed <saeedm@mellanox.com>2019-03-29 15:37:55 -0700
committerSaeed Mahameed <saeedm@mellanox.com>2019-04-02 12:49:37 -0700
commit52c368dc3da7beb7b283133024af1b6d07bf93b9 (patch)
tree00bdfe723b94c29455414581a9963f194cf08e24 /drivers/net/ethernet/mellanox/mlx5/core
parentnet/mlx5: Split mdev init and pci init (diff)
downloadlinux-dev-52c368dc3da7beb7b283133024af1b6d07bf93b9.tar.xz
linux-dev-52c368dc3da7beb7b283133024af1b6d07bf93b9.zip
net/mlx5: Move health and page alloc init to mdev_init
Software structure initialization should be in mdev_init stage. This provides a better logical separation of mlx5 core device initialization flow and will help to seamlessly support creating different mlx5 device types such as PF, VF and SF mlx5 sub-function virtual device. This patch does not change any functionality. Signed-off-by: Vu Pham <vuhuong@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx5/core')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c37
2 files changed, 27 insertions, 17 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 196c07383082..1ab694bc22c0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -352,6 +352,13 @@ void mlx5_drain_health_recovery(struct mlx5_core_dev *dev)
cancel_delayed_work_sync(&dev->priv.health.recover_work);
}
+void mlx5_health_flush(struct mlx5_core_dev *dev)
+{
+ struct mlx5_core_health *health = &dev->priv.health;
+
+ flush_workqueue(health->wq);
+}
+
void mlx5_health_cleanup(struct mlx5_core_dev *dev)
{
struct mlx5_core_health *health = &dev->priv.health;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index e26246eacea5..4bdcbfcc5476 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1220,6 +1220,7 @@ static const struct devlink_ops mlx5_devlink_ops = {
static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx, const char *name)
{
struct mlx5_priv *priv = &dev->priv;
+ int err;
strncpy(priv->name, name, MLX5_MAX_NAME_LEN);
priv->name[MLX5_MAX_NAME_LEN - 1] = 0;
@@ -1247,11 +1248,28 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx, const char
return -ENOMEM;
}
+ err = mlx5_health_init(dev);
+ if (err)
+ goto err_health_init;
+
+ err = mlx5_pagealloc_init(dev);
+ if (err)
+ goto err_pagealloc_init;
+
return 0;
+
+err_pagealloc_init:
+ mlx5_health_cleanup(dev);
+err_health_init:
+ debugfs_remove(dev->priv.dbg_root);
+
+ return err;
}
static void mlx5_mdev_uninit(struct mlx5_core_dev *dev)
{
+ mlx5_pagealloc_cleanup(dev);
+ mlx5_health_cleanup(dev);
debugfs_remove_recursive(dev->priv.dbg_root);
}
@@ -1280,16 +1298,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)
goto pci_init_err;
}
- err = mlx5_health_init(dev);
- if (err) {
- dev_err(&pdev->dev, "mlx5_health_init failed with error code %d\n", err);
- goto close_pci;
- }
-
- err = mlx5_pagealloc_init(dev);
- if (err)
- goto err_pagealloc_init;
-
err = mlx5_load_one(dev, true);
if (err) {
dev_err(&pdev->dev, "mlx5_load_one failed with error code %d\n", err);
@@ -1307,11 +1315,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)
clean_load:
mlx5_unload_one(dev, true);
+
err_load_one:
- mlx5_pagealloc_cleanup(dev);
-err_pagealloc_init:
- mlx5_health_cleanup(dev);
-close_pci:
mlx5_pci_close(dev);
pci_init_err:
mlx5_mdev_uninit(dev);
@@ -1331,12 +1336,10 @@ static void remove_one(struct pci_dev *pdev)
if (mlx5_unload_one(dev, true)) {
dev_err(&dev->pdev->dev, "mlx5_unload_one failed\n");
- mlx5_health_cleanup(dev);
+ mlx5_health_flush(dev);
return;
}
- mlx5_pagealloc_cleanup(dev);
- mlx5_health_cleanup(dev);
mlx5_pci_close(dev);
mlx5_mdev_uninit(dev);
devlink_free(devlink);