]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/mlx5: Drop FRMR pool handle on UMR revoke failure
authorMichael Guralnik <michaelgur@nvidia.com>
Wed, 10 Jun 2026 00:01:45 +0000 (03:01 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 11 Jun 2026 18:36:09 +0000 (15:36 -0300)
When UMR revoke fails during MR cleanup, the handle is left in an
unknown state and cannot be returned to the pool. The driver already
destroys the mkey via the fallback path, but the pool's in_use counter
is never decremented, drifting upward over time.

Call ib_frmr_pool_drop on the revoke-failure path so the pool's
accounting stays consistent with the handles it has handed out.

Fixes: 36680ef7bceb ("RDMA/mlx5: Switch from MR cache to FRMR pools")
Link: https://patch.msgid.link/r/20260610000145.820592-10-michaelgur@nvidia.com
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mlx5/mr.c

index 46cbdc86321f4c28120c2f7a32f557b711ebbe97..499bfd201831127ea92c420537e58196b0c5d147 100644 (file)
@@ -1398,9 +1398,11 @@ static int mlx5r_handle_mkey_cleanup(struct mlx5_ib_mr *mr)
        bool is_odp = is_odp_mr(mr);
        int ret;
 
-       if (mr->ibmr.frmr.pool && !mlx5_umr_revoke_mr_with_lock(mr)) {
-               ib_frmr_pool_push(mr->ibmr.device, &mr->ibmr);
-               return 0;
+       if (mr->ibmr.frmr.pool) {
+               if (!mlx5_umr_revoke_mr_with_lock(mr)) {
+                       ib_frmr_pool_push(mr->ibmr.device, &mr->ibmr);
+                       return 0;
+               }
        }
 
        if (is_odp)
@@ -1422,6 +1424,10 @@ static int mlx5r_handle_mkey_cleanup(struct mlx5_ib_mr *mr)
                dma_resv_unlock(
                        to_ib_umem_dmabuf(mr->umem)->attach->dmabuf->resv);
        }
+
+       if (mr->ibmr.frmr.pool && !ret)
+               ib_frmr_pool_drop(&mr->ibmr);
+
        return ret;
 }