Commit 4638a3b2 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Doug Ledford

RDMA/mlx5: Unify error flows in rereg MR failure paths

According to the IBTA spec 1.3, the driver failure in
MR reregister shall release old and new MRs.

 C11-20: If the CI returns any other error, the CI shall
 invalidate both "old" and "new" registrations, and release
 any associated resources.
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent ea30f013
...@@ -1375,10 +1375,8 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, ...@@ -1375,10 +1375,8 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
ib_umem_release(mr->umem); ib_umem_release(mr->umem);
err = mr_umem_get(pd, addr, len, access_flags, &mr->umem, err = mr_umem_get(pd, addr, len, access_flags, &mr->umem,
&npages, &page_shift, &ncont, &order); &npages, &page_shift, &ncont, &order);
if (err < 0) { if (err)
clean_mr(dev, mr); goto err;
return err;
}
} }
if (flags & IB_MR_REREG_TRANS && !use_umr_mtt_update(mr, addr, len)) { if (flags & IB_MR_REREG_TRANS && !use_umr_mtt_update(mr, addr, len)) {
...@@ -1395,13 +1393,16 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, ...@@ -1395,13 +1393,16 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
mlx5_ib_warn(dev, "Failed to destroy MKey\n"); mlx5_ib_warn(dev, "Failed to destroy MKey\n");
} }
if (err) if (err)
return err; goto err;
mr = reg_create(ib_mr, pd, addr, len, mr->umem, ncont, mr = reg_create(ib_mr, pd, addr, len, mr->umem, ncont,
page_shift, access_flags, true); page_shift, access_flags, true);
if (IS_ERR(mr)) if (IS_ERR(mr)) {
return PTR_ERR(mr); err = PTR_ERR(mr);
mr = to_mmr(ib_mr);
goto err;
}
mr->allocated_from_cache = 0; mr->allocated_from_cache = 0;
mr->live = 1; mr->live = 1;
...@@ -1427,13 +1428,8 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, ...@@ -1427,13 +1428,8 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
err = rereg_umr(pd, mr, access_flags, flags); err = rereg_umr(pd, mr, access_flags, flags);
} }
if (err) { if (err)
mlx5_ib_warn(dev, "Failed to rereg UMR\n"); goto err;
ib_umem_release(mr->umem);
mr->umem = NULL;
clean_mr(dev, mr);
return err;
}
} }
set_mr_fileds(dev, mr, npages, len, access_flags); set_mr_fileds(dev, mr, npages, len, access_flags);
...@@ -1442,6 +1438,14 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, ...@@ -1442,6 +1438,14 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
update_odp_mr(mr); update_odp_mr(mr);
#endif #endif
return 0; return 0;
err:
if (mr->umem) {
ib_umem_release(mr->umem);
mr->umem = NULL;
}
clean_mr(dev, mr);
return err;
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment