From: Leon Romanovsky <leonro@xxxxxxxxxxxx> Adapt mlx5 to use restrack automatic ID allocation scheme. Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/hw/mlx5/cq.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index c283c32f30fe..935f5f46cc39 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c @@ -914,6 +914,12 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, if (!cq) return ERR_PTR(-ENOMEM); + cq->ibcq.device = ibdev; + rdma_rt_set_type(&cq->ibcq.res, RDMA_RESTRACK_CQ); + err = rdma_restrack_add(&cq->ibcq.res); + if (err) + goto err_rt; + cq->ibcq.cqe = entries - 1; mutex_init(&cq->resize_mutex); spin_lock_init(&cq->lock); @@ -991,6 +997,8 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, destroy_cq_kernel(dev, cq); err_create: + rdma_restrack_del(&cq->ibcq.res); +err_rt: kfree(cq); return ERR_PTR(err); @@ -1012,6 +1020,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; -- 2.19.1