[PATCH rdma-next 6/6] RDMA/mlx5: Annotate MR allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Leon Romanovsky <leonro@xxxxxxxxxxxx>

Use restrack ID ability to track MRs.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/hw/mlx5/mr.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 8f557f90ad7f..55a7ca561025 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1673,6 +1673,7 @@ static void dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
 
 int mlx5_ib_dereg_mr(struct ib_mr *ibmr)
 {
+	rdma_restrack_del(&ibmr->res);
 	dereg_mr(to_mdev(ibmr->device), to_mmr(ibmr));
 	return 0;
 }
@@ -1693,6 +1694,13 @@ struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,
 	if (!mr)
 		return ERR_PTR(-ENOMEM);
 
+	mr->ibmr.device = pd->device;
+	rdma_rt_set_type(&mr->ibmr.res, RDMA_RESTRACK_MR);
+	err = rdma_restrack_add(&mr->ibmr.res);
+	if (err)
+		goto err_rt;
+
+
 	in = kzalloc(inlen, GFP_KERNEL);
 	if (!in) {
 		err = -ENOMEM;
@@ -1789,6 +1797,8 @@ struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,
 err_free_in:
 	kfree(in);
 err_free:
+	rdma_restrack_del(&mr->ibmr.res);
+err_rt:
 	kfree(mr);
 	return ERR_PTR(err);
 }
-- 
2.19.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux