Commit 4a6dc855 authored by Mark Bloch's avatar Mark Bloch Committed by Jason Gunthorpe

RDMA/mlx5: Free IB device on remove

Simplify the code and move the deallocation of the IB device into the
remove function.
Signed-off-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 95579e78
...@@ -65,10 +65,8 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) ...@@ -65,10 +65,8 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
ibdev->mdev = dev; ibdev->mdev = dev;
ibdev->num_ports = max(MLX5_CAP_GEN(dev, num_ports), ibdev->num_ports = max(MLX5_CAP_GEN(dev, num_ports),
MLX5_CAP_GEN(dev, num_vhca_ports)); MLX5_CAP_GEN(dev, num_vhca_ports));
if (!__mlx5_ib_add(ibdev, profile)) { if (!__mlx5_ib_add(ibdev, profile))
ib_dealloc_device(&ibdev->ib_dev);
return -EINVAL; return -EINVAL;
}
rep->rep_if[REP_IB].priv = ibdev; rep->rep_if[REP_IB].priv = ibdev;
...@@ -86,7 +84,6 @@ mlx5_ib_vport_rep_unload(struct mlx5_eswitch_rep *rep) ...@@ -86,7 +84,6 @@ mlx5_ib_vport_rep_unload(struct mlx5_eswitch_rep *rep)
dev = mlx5_ib_rep_to_dev(rep); dev = mlx5_ib_rep_to_dev(rep);
__mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX); __mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX);
rep->rep_if[REP_IB].priv = NULL; rep->rep_if[REP_IB].priv = NULL;
ib_dealloc_device(&dev->ib_dev);
} }
static void *mlx5_ib_vport_get_proto_dev(struct mlx5_eswitch_rep *rep) static void *mlx5_ib_vport_get_proto_dev(struct mlx5_eswitch_rep *rep)
......
...@@ -6417,6 +6417,8 @@ void __mlx5_ib_remove(struct mlx5_ib_dev *dev, ...@@ -6417,6 +6417,8 @@ void __mlx5_ib_remove(struct mlx5_ib_dev *dev,
if (profile->stage[stage].cleanup) if (profile->stage[stage].cleanup)
profile->stage[stage].cleanup(dev); profile->stage[stage].cleanup(dev);
} }
ib_dealloc_device(&dev->ib_dev);
} }
void *__mlx5_ib_add(struct mlx5_ib_dev *dev, void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
...@@ -6639,8 +6641,6 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) ...@@ -6639,8 +6641,6 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context)
dev = context; dev = context;
__mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX); __mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX);
ib_dealloc_device((struct ib_device *)dev);
} }
static struct mlx5_interface mlx5_ib_interface = { static struct mlx5_interface mlx5_ib_interface = {
......
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