From: Leon Romanovsky <leonro@xxxxxxxxxxxx> Device memory (DM) are registered to MR during initialization flow, these MRs were not tracked by resource tracker and had res->valid set as a false. Update the code to manage them too. Before this change: [leonro@vm ~]$ ibv_rc_pingpong -j & [leonro@vm ~]$ rdma res show mr <-- shows nothing After this change: [leonro@mtl-leonro-l-vm ~]$ ibv_rc_pingpong -j & [leonro@mtl-leonro-l-vm ~]$ rdma res show mr dev ibp0s9 mrn 0 mrlen 4096 pdn 3 pid 734 comm ibv_rc_pingpong Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/core/uverbs_std_types_mr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/infiniband/core/uverbs_std_types_mr.c b/drivers/infiniband/core/uverbs_std_types_mr.c index 9b22bb553e8b..9ec5ea49e06e 100644 --- a/drivers/infiniband/core/uverbs_std_types_mr.c +++ b/drivers/infiniband/core/uverbs_std_types_mr.c @@ -31,6 +31,7 @@ */ #include "rdma_core.h" +#include "restrack.h" #include "uverbs.h" #include <rdma/uverbs_std_types.h> @@ -134,6 +135,15 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)( atomic_inc(&pd->usecnt); atomic_inc(&dm->usecnt); + rdma_restrack_new(&mr->res, RDMA_RESTRACK_MR); + rdma_restrack_set_name(&mr->res, NULL); + ret = rdma_restrack_add(&mr->res); + if (ret) { + rdma_restrack_put(&mr->res); + pd->device->ops.dereg_mr(mr, &attrs->driver_udata); + return ret; + } + uobj->object = mr; uverbs_finalize_uobj_create(attrs, UVERBS_ATTR_REG_DM_MR_HANDLE); -- 2.26.2