Skip to content

Commit 5aa3771

Browse files
yishaihdledford
authored andcommitted
IB/mlx5: Allow XRC usage via verbs in DEVX context
Allows XRC usage from the verbs flow in a DEVX context. As XRCD is some shared kernel resource between processes it should be created with UID=0 to point on that. As a result once XRC QP/SRQ are created they must be used as well with UID=0 so that firmware will allow the XRCD usage. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 719598c commit 5aa3771

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ struct mlx5_ib_srq {
543543
struct mlx5_ib_xrcd {
544544
struct ib_xrcd ibxrcd;
545545
u32 xrcdn;
546-
u16 uid;
547546
};
548547

549548
enum mlx5_ib_mtt_access_flags {

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
775775
__be64 *pas;
776776
void *qpc;
777777
int err;
778+
u16 uid;
778779

779780
err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd));
780781
if (err) {
@@ -836,7 +837,8 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
836837
goto err_umem;
837838
}
838839

839-
MLX5_SET(create_qp_in, *in, uid, to_mpd(pd)->uid);
840+
uid = (attr->qp_type != IB_QPT_XRC_TGT) ? to_mpd(pd)->uid : 0;
841+
MLX5_SET(create_qp_in, *in, uid, uid);
840842
pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas);
841843
if (ubuffer->umem)
842844
mlx5_ib_populate_pas(dev, ubuffer->umem, page_shift, pas, 0);
@@ -5514,7 +5516,6 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
55145516
struct mlx5_ib_dev *dev = to_mdev(ibdev);
55155517
struct mlx5_ib_xrcd *xrcd;
55165518
int err;
5517-
u16 uid;
55185519

55195520
if (!MLX5_CAP_GEN(dev->mdev, xrc))
55205521
return ERR_PTR(-ENOSYS);
@@ -5523,25 +5524,22 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
55235524
if (!xrcd)
55245525
return ERR_PTR(-ENOMEM);
55255526

5526-
uid = context ? to_mucontext(context)->devx_uid : 0;
5527-
err = mlx5_cmd_xrcd_alloc(dev->mdev, &xrcd->xrcdn, uid);
5527+
err = mlx5_cmd_xrcd_alloc(dev->mdev, &xrcd->xrcdn, 0);
55285528
if (err) {
55295529
kfree(xrcd);
55305530
return ERR_PTR(-ENOMEM);
55315531
}
55325532

5533-
xrcd->uid = uid;
55345533
return &xrcd->ibxrcd;
55355534
}
55365535

55375536
int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd)
55385537
{
55395538
struct mlx5_ib_dev *dev = to_mdev(xrcd->device);
55405539
u32 xrcdn = to_mxrcd(xrcd)->xrcdn;
5541-
u16 uid = to_mxrcd(xrcd)->uid;
55425540
int err;
55435541

5544-
err = mlx5_cmd_xrcd_dealloc(dev->mdev, xrcdn, uid);
5542+
err = mlx5_cmd_xrcd_dealloc(dev->mdev, xrcdn, 0);
55455543
if (err)
55465544
mlx5_ib_warn(dev, "failed to dealloc xrcdn 0x%x\n", xrcdn);
55475545

drivers/infiniband/hw/mlx5/srq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
113113

114114
in->log_page_size = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
115115
in->page_offset = offset;
116-
in->uid = to_mpd(pd)->uid;
116+
in->uid = (in->type != IB_SRQT_XRC) ? to_mpd(pd)->uid : 0;
117117
if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 &&
118118
in->type != IB_SRQT_BASIC)
119119
in->user_index = uidx;

0 commit comments

Comments
 (0)