Skip to content

Commit 6a05395

Browse files
yishaihjgunthorpe
authored andcommitted
IB/mlx5: Fix unreg_umr to ignore the mkey state
Fix unreg_umr to ignore the mkey state and do not fail if was freed. This prevents a case that a user space application already changed the mkey state to free and then the UMR operation will fail leaving the mkey in an inappropriate state. Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> # 3.19 Fixes: 968e78d ("IB/mlx5: Enhance UMR support to allow partial page table update") Signed-off-by: Yishai Hadas <[email protected]> Reviewed-by: Artemy Kovalyov <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent af0653d commit 6a05395

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ struct mlx5_umr_wr {
481481
u64 length;
482482
int access_flags;
483483
u32 mkey;
484+
u8 ignore_free_state:1;
484485
};
485486

486487
static inline const struct mlx5_umr_wr *umr_wr(const struct ib_send_wr *wr)

drivers/infiniband/hw/mlx5/mr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,10 +1372,10 @@ static int unreg_umr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
13721372
if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
13731373
return 0;
13741374

1375-
umrwr.wr.send_flags = MLX5_IB_SEND_UMR_DISABLE_MR |
1376-
MLX5_IB_SEND_UMR_FAIL_IF_FREE;
1375+
umrwr.wr.send_flags = MLX5_IB_SEND_UMR_DISABLE_MR;
13771376
umrwr.wr.opcode = MLX5_IB_WR_UMR;
13781377
umrwr.mkey = mr->mmkey.key;
1378+
umrwr.ignore_free_state = 1;
13791379

13801380
return mlx5_ib_post_send_wait(dev, &umrwr);
13811381
}

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,10 +4295,14 @@ static int set_reg_umr_segment(struct mlx5_ib_dev *dev,
42954295

42964296
memset(umr, 0, sizeof(*umr));
42974297

4298-
if (wr->send_flags & MLX5_IB_SEND_UMR_FAIL_IF_FREE)
4299-
umr->flags = MLX5_UMR_CHECK_FREE; /* fail if free */
4300-
else
4301-
umr->flags = MLX5_UMR_CHECK_NOT_FREE; /* fail if not free */
4298+
if (!umrwr->ignore_free_state) {
4299+
if (wr->send_flags & MLX5_IB_SEND_UMR_FAIL_IF_FREE)
4300+
/* fail if free */
4301+
umr->flags = MLX5_UMR_CHECK_FREE;
4302+
else
4303+
/* fail if not free */
4304+
umr->flags = MLX5_UMR_CHECK_NOT_FREE;
4305+
}
43024306

43034307
umr->xlt_octowords = cpu_to_be16(get_xlt_octo(umrwr->xlt_size));
43044308
if (wr->send_flags & MLX5_IB_SEND_UMR_UPDATE_XLT) {

0 commit comments

Comments
 (0)