From: Leon Romanovsky <leonro@xxxxxxxxxxxx> Adapt mlx5 to use restrack HW ID allocation scheme. Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/hw/mlx5/cq.c | 10 +++++++++- drivers/infiniband/hw/mlx5/main.c | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index c283c32f30fe..202f977e7092 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c @@ -976,8 +976,15 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, goto err_cmd; } - kvfree(cqb); + + cq->ibcq.device = ibdev; + rdma_rt_set_type(&cq->ibcq.res, RDMA_RESTRACK_CQ); + rdma_rt_set_id(&cq->ibcq.res, cq->mcq.cqn); + err = rdma_restrack_add(&cq->ibcq.res); + if (err) + goto err_cmd; + return &cq->ibcq; err_cmd: @@ -1012,6 +1019,7 @@ int mlx5_ib_destroy_cq(struct ib_cq *cq) else destroy_cq_kernel(dev, mcq); + rdma_restrack_del(&cq->res); kfree(mcq); return 0; diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 1348e4e9e119..3e1fb9d57724 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -6527,6 +6527,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) /* PD ID managed by FW */ rdma_rt_set_id_range(&dev->ib_dev, RDMA_RESTRACK_PD, 0, 0); + /* CQ ID managed by FW */ + rdma_rt_set_id_range(&dev->ib_dev, RDMA_RESTRACK_CQ, 0, 0); dev->mdev = mdev; dev->num_ports = max(MLX5_CAP_GEN(mdev, num_ports), -- 2.19.1