Message ID | 20181031124242.24239-6-shamir.rabinovitch@oracle.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | figure uverbs/kernel ib_pd w/o using ib_pd uobject | expand |
On Wed, Oct 31, 2018 at 02:42:42PM +0200, Shamir Rabinovitch wrote: > Now we have the ability to tell from ib_pd if ib_pd was > created by user/kernel verbs. Stop using the ib_pd->uobject > pointer for this. This patch prepare the ib_pb uobject pointer > removal that will happen in another patch. > > Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com> > drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++-- > drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 2 +- > drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- > drivers/infiniband/hw/hns/hns_roce_qp.c | 17 +++++++++-------- > drivers/infiniband/hw/i40iw/i40iw_verbs.c | 2 +- > drivers/infiniband/hw/mlx4/qp.c | 11 ++++++----- > drivers/infiniband/hw/mlx4/srq.c | 10 +++++----- > drivers/infiniband/hw/mlx5/qp.c | 4 ++-- > drivers/infiniband/hw/mlx5/srq.c | 8 ++++---- > drivers/infiniband/hw/mthca/mthca_provider.c | 10 +++++----- > drivers/infiniband/hw/mthca/mthca_qp.c | 7 ++++--- > drivers/infiniband/hw/mthca/mthca_srq.c | 8 ++++---- > drivers/infiniband/hw/nes/nes_verbs.c | 7 ++++--- > drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- > drivers/infiniband/hw/qedr/verbs.c | 4 ++-- > drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 2 +- > drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c | 2 +- > drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++- > 18 files changed, 56 insertions(+), 50 deletions(-) > > diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > index 54fdd4c..d2d2630 100644 > +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > @@ -698,7 +698,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, > ah->qplib_ah.flow_label = grh->flow_label; > ah->qplib_ah.hop_limit = grh->hop_limit; > ah->qplib_ah.sl = rdma_ah_get_sl(ah_attr); > - if (ib_pd->uobject && > + if (rdma_is_user_pd(ib_pd) && > !rdma_is_multicast_addr((struct in6_addr *) > grh->dgid.raw) && > !rdma_link_local_addr((struct in6_addr *) I have no idea why this if is here, but looks like it should be 'if (udata)' ? > @@ -729,7 +729,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, > } > > /* Write AVID to shared page. */ > - if (ib_pd->uobject) { > + if (rdma_is_user_pd(ib_pd)) { > struct ib_ucontext *ib_uctx = ib_pd->uobject->context; > struct bnxt_re_ucontext *uctx; > unsigned long flag; This should be 'if (udata) {.. ib_utx = get_uctx_from_udata(..);..' > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > index 00170aa..a6c581a 100644 > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > @@ -3926,7 +3926,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) > struct hns_roce_qp_work *qp_work; > struct hns_roce_v1_priv *priv; > struct hns_roce_cq *send_cq, *recv_cq; > - bool is_user = ibqp->pd->uobject; > + bool is_user = rdma_is_user_pd(ibqp->pd); > int is_timeout = 0; > int ret; ibqp->uboject > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > index a4c62ae..8c659c1 100644 > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > @@ -4096,7 +4096,8 @@ static int hns_roce_v2_destroy_qp(struct ib_qp *ibqp) > struct hns_roce_qp *hr_qp = to_hr_qp(ibqp); > int ret; > > - ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, !!ibqp->pd->uobject); > + ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, rdma_is_user_pd(ibqp->pd)); ibqp->uboject > diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c > index 5ebf481..2b0c20f 100644 > +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c > @@ -562,7 +562,8 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > else > hr_qp->sq_signal_bits = cpu_to_le32(IB_SIGNAL_REQ_WR); > > - ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, !!ib_pd->uobject, > + ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, > + rdma_is_user_pd(ib_pd), > !!init_attr->srq, hr_qp); probably if udata > if (ret) { > dev_err(dev, "hns_roce_set_rq_size failed\n"); > @@ -599,7 +600,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > init_attr->cap.max_recv_sge]; > } > > - if (ib_pd->uobject) { > + if (rdma_is_user_pd(ib_pd)) { > if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) { > dev_err(dev, "ib_copy_from_udata error for create qp\n"); > ret = -EFAULT; certainly if udata > @@ -784,7 +785,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > else > hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn); > > - if (ib_pd->uobject && (udata->outlen >= sizeof(resp)) && > + if (rdma_is_user_pd(ib_pd) && (udata->outlen >= sizeof(resp)) && > (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) { certainly if udata > /* indicate kernel supports rq record db */ > @@ -811,7 +812,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > hns_roce_release_range_qp(hr_dev, qpn, 1); > > err_wrid: > - if (ib_pd->uobject) { > + if (rdma_is_user_pd(ib_pd)) { > if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) && > (udata->outlen >= sizeof(resp)) && > hns_roce_qp_has_rq(init_attr)) if udata > @@ -824,7 +825,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > } > > err_sq_dbmap: > - if (ib_pd->uobject) > + if (rdma_is_user_pd(ib_pd)) > if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SQ_RECORD_DB) && > (udata->inlen >= sizeof(ucmd)) && > (udata->outlen >= sizeof(resp)) && if udata > @@ -837,13 +838,13 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > hns_roce_mtt_cleanup(hr_dev, &hr_qp->mtt); > > err_buf: > - if (ib_pd->uobject) > + if (rdma_is_user_pd(ib_pd)) > ib_umem_release(hr_qp->umem); > else > hns_roce_buf_free(hr_dev, hr_qp->buff_size, &hr_qp->hr_buf); maybe if umem? > err_db: > - if (!ib_pd->uobject && hns_roce_qp_has_rq(init_attr) && > + if (!rdma_is_user_pd(ib_pd) && hns_roce_qp_has_rq(init_attr) && > (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) > hns_roce_free_db(hr_dev, &hr_qp->rdb); if udata? > @@ -889,7 +890,7 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd, > } > case IB_QPT_GSI: { > /* Userspace is not allowed to create special QPs: */ > - if (pd->uobject) { > + if (rdma_is_user_pd(pd)) { > dev_err(dev, "not support usr space GSI\n"); > return ERR_PTR(-EINVAL); > } This one looks sensible > diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c > index 9d3178d..d60d883 100644 > +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c > @@ -2090,7 +2090,7 @@ static int i40iw_dereg_mr(struct ib_mr *ib_mr) > ib_umem_release(iwmr->region); > > if (iwmr->type != IW_MEMREG_TYPE_MEM) { > - if (ibpd->uobject) { > + if (rdma_is_user_pd(ibpd)) { > struct i40iw_ucontext *ucontext; > > ucontext = to_ucontext(ibpd->uobject->context); maybe if (iwmr->umem) ? > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c > index c783539..af07eb0 100644 > +++ b/drivers/infiniband/hw/mlx4/qp.c > @@ -942,7 +942,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE); > > > - if (pd->uobject) { > + if (rdma_is_user_pd(pd)) { > union { > struct mlx4_ib_create_qp qp; > struct mlx4_ib_create_wq wq; if udata (the next lines access udata) > @@ -991,7 +991,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > qp->flags |= MLX4_IB_QP_SCATTER_FCS; > } > > - err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, > + err = set_rq_size(dev, &init_attr->cap, rdma_is_user_pd(pd), > qp_has_rq(init_attr), qp, qp->inl_recv_sz); > if (er > goto err; if udata > @@ -1043,7 +1043,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > } > qp->mqp.usage = MLX4_RES_USAGE_USER_VERBS; > } else { > - err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, > + err = set_rq_size(dev, &init_attr->cap, rdma_is_user_pd(pd), > qp_has_rq(init_attr), qp, 0); > if (err) > goto err; if udata > @@ -1207,7 +1207,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf); > > err_db: > - if (!pd->uobject && qp_has_rq(init_attr)) > + if (rdma_is_user_pd(pd) && qp_has_rq(init_attr)) > mlx4_db_free(dev->dev, &qp->db); if udata > err: > @@ -1612,7 +1612,8 @@ static int _mlx4_ib_destroy_qp(struct ib_qp *qp) > struct mlx4_ib_pd *pd; > > pd = get_pd(mqp); > - destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, !!pd->ibpd.uobject); > + destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, > + rdma_is_user_pd(&pd->ibpd)); > } if qp->uobject > if (is_sqp(dev, mqp)) > diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c > index 3731b31..b821a08 100644 > +++ b/drivers/infiniband/hw/mlx4/srq.c > @@ -105,7 +105,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > buf_size = srq->msrq.max * desc_size; > > - if (pd->uobject) { > + if (rdma_is_user_pd(pd)) { > struct mlx4_ib_create_srq ucmd; > > if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { if udata > @@ -191,7 +191,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > srq->msrq.event = mlx4_ib_srq_event; > srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; > > - if (pd->uobject) > + if (rdma_is_user_pd(pd)) > if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof (__u32))) { > err = -EFAULT; > goto err_wrid; if udata > @@ -202,7 +202,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > return &srq->ibsrq; > > err_wrid: > - if (pd->uobject) > + if (rdma_is_user_pd(pd)) > mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db); > else > kvfree(srq->wrid); if srq->uobject > @@ -211,13 +211,13 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > mlx4_mtt_cleanup(dev->dev, &srq->mtt); > > err_buf: > - if (pd->uobject) > + if (rdma_is_user_pd(pd)) > ib_umem_release(srq->umem); > else > mlx4_buf_free(dev->dev, buf_size, &srq->buf); if srq->uobject? srq->umem? > err_db: > - if (!pd->uobject) > + if (!rdma_is_user_pd(pd)) > mlx4_db_free(dev->dev, &srq->db); if srq->uobject > err_srq: > diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c > index 87e1675..c3ad24d 100644 > +++ b/drivers/infiniband/hw/mlx5/qp.c > @@ -1955,7 +1955,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, > } > > if (pd) { > - if (pd->uobject) { > + if (rdma_is_user_pd(pd)) { > __u32 max_wqes = > 1 << MLX5_CAP_GEN(mdev, log_max_qp_sz); > mlx5_ib_dbg(dev, "requested sq_wqe_count (%d)\n", ucmd.sq_wqe_count); if udata ? > @@ -2465,7 +2465,7 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, > dev = to_mdev(pd->device); > > if (init_attr->qp_type == IB_QPT_RAW_PACKET) { > - if (!pd->uobject) { > + if (!rdma_is_user_pd(pd)) { > mlx5_ib_dbg(dev, "Raw Packet QP is not supported for kernel consumers\n"); > return ERR_PTR(-EINVAL); > } else if (!to_mucontext(pd->uobject->context)->cqe_version) { if udata > diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c > index d012e7d..c5eb189 100644 > +++ b/drivers/infiniband/hw/mlx5/srq.c > @@ -287,14 +287,14 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > } > in.type = init_attr->srq_type; > > - if (pd->uobject) > + if (rdma_is_user_pd(pd)) > err = create_srq_user(pd, srq, &in, udata, buf_size); > else > err = create_srq_kernel(dev, srq, &in, buf_size); if udata > if (err) { > mlx5_ib_warn(dev, "create srq %s failed, err %d\n", > - pd->uobject ? "user" : "kernel", err); > + rdma_is_user_pd(pd) ? "user" : "kernel", err); > goto err_srq; > } if udata > @@ -339,7 +339,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > srq->msrq.event = mlx5_ib_srq_event; > srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; > > - if (pd->uobject) > + if (rdma_is_user_pd(pd)) > if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) { > mlx5_ib_dbg(dev, "copy to user failed\n"); > err = -EFAULT; if udata > @@ -354,7 +354,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > mlx5_core_destroy_srq(dev->mdev, &srq->msrq); > > err_usr_kern_srq: > - if (pd->uobject) > + if (rdma_is_user_pd(pd)) > destroy_srq_user(pd, srq); > else > destroy_srq_kernel(dev, srq); if srq->uobject > diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c > index 691c6f0..683eaa6 100644 > +++ b/drivers/infiniband/hw/mthca/mthca_provider.c > @@ -455,7 +455,7 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, > if (!srq) > return ERR_PTR(-ENOMEM); > > - if (pd->uobject) { > + if (rdma_is_user_pd(pd)) { > context = to_mucontext(pd->uobject->context); if udata > if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { > @@ -477,7 +477,7 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, > err = mthca_alloc_srq(to_mdev(pd->device), to_mpd(pd), > &init_attr->attr, srq); > > - if (err && pd->uobject) > + if (err && rdma_is_user_pd(pd)) > mthca_unmap_user_db(to_mdev(pd->device), &context->uar, > context->db_tab, ucmd.db_index); if udata > @@ -537,7 +537,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > if (!qp) > return ERR_PTR(-ENOMEM); > > - if (pd->uobject) { > + if (rdma_is_user_pd(pd)) { > context = to_mucontext(pd->uobject->context); > > if (ib_copy_from_udata(&ucmd, udata, sizeof > ucmd)) { if udata > @@ -576,7 +576,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > init_attr->qp_type, init_attr->sq_sig_type, > &init_attr->cap, qp); > > - if (err && pd->uobject) { > + if (err && rdma_is_user_pd(pd)) { > context = to_mucontext(pd->uobject->context); > > mthca_unmap_user_db(to_mdev(pd->device), if udata > @@ -596,7 +596,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > case IB_QPT_GSI: > { > /* Don't allow userspace to create special QPs */ > - if (pd->uobject) > + if (rdma_is_user_pd(pd)) > return ERR_PTR(-EINVAL); > > qp = kmalloc(sizeof (struct mthca_sqp), GFP_KERNEL); Fine > diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c > index 9d178ee..ffa4526 100644 > +++ b/drivers/infiniband/hw/mthca/mthca_qp.c > @@ -951,7 +951,8 @@ static int mthca_max_data_size(struct mthca_dev *dev, struct mthca_qp *qp, int d > static inline int mthca_max_inline_data(struct mthca_pd *pd, int max_data_size) > { > /* We don't support inline data for kernel QPs (yet). */ > - return pd->ibpd.uobject ? max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; > + return rdma_is_user_pd(&pd->ibpd) ? > + max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; > } Sigh, fine, that is annoying to fix > static void mthca_adjust_qp_caps(struct mthca_dev *dev, > @@ -1048,7 +1049,7 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, > * allocate anything. All we need is to calculate the WQE > * sizes and the send_wqe_offset, so we're done now. > */ > - if (pd->ibpd.uobject) > + if (rdma_is_user_pd(&pd->ibpd)) > return 0; should be udata, but fine :\ > size = PAGE_ALIGN(qp->send_wqe_offset + > @@ -1191,7 +1192,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev, > * will be allocated and buffers will be initialized in > * userspace. > */ > - if (pd->ibpd.uobject) > + if (rdma_is_user_pd(&pd->ibpd)) > return 0; Same > ret = mthca_alloc_memfree(dev, qp); > diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c > index 9a3fc6f..4e206d4 100644 > +++ b/drivers/infiniband/hw/mthca/mthca_srq.c > @@ -152,7 +152,7 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd, > int err; > int i; > > - if (pd->ibpd.uobject) > + if (rdma_is_user_pd(&pd->ibpd)) > return 0; Same > srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL); > @@ -235,7 +235,7 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, > if (err) > goto err_out; > > - if (!pd->ibpd.uobject) { > + if (!rdma_is_user_pd(&pd->ibpd)) { > srq->db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SRQ, > srq->srqn, &srq->db); > if (srq->db_index < 0) { Same > @@ -297,14 +297,14 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, > mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err); > > err_out_free_buf: > - if (!pd->ibpd.uobject) > + if (!rdma_is_user_pd(&pd->ibpd)) > mthca_free_srq_buf(dev, srq); > > err_out_mailbox: > mthca_free_mailbox(dev, mailbox); > > err_out_db: > - if (!pd->ibpd.uobject && mthca_is_memfree(dev)) > + if (!rdma_is_user_pd(&pd->ibpd) && mthca_is_memfree(dev)) > mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index); > > err_out_icm: Same > diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c > index 92d1cad..fc0100c 100644 > +++ b/drivers/infiniband/hw/nes/nes_verbs.c > @@ -733,7 +733,7 @@ static int nes_dealloc_pd(struct ib_pd *ibpd) > struct nes_device *nesdev = nesvnic->nesdev; > struct nes_adapter *nesadapter = nesdev->nesadapter; > > - if ((ibpd->uobject) && (ibpd->uobject->context)) { > + if (rdma_is_user_pd(ibpd) && (ibpd->uobject->context)) { > nesucontext = to_nesucontext(ibpd->uobject->context); > nes_debug(NES_DBG_PD, "Clearing bit %u from allocated doorbells\n", > nespd->mmap_db_index); Fine > @@ -1066,7 +1066,8 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, > } > if (req.user_qp_buffer) > nesqp->nesuqp_addr = req.user_qp_buffer; > - if ((ibpd->uobject) && (ibpd->uobject->context)) { > + if (rdma_is_user_pd(ibpd) && > + (ibpd->uobject->context)) { > nesqp->user_mode = 1; > nes_ucontext = to_nesucontext(ibpd->uobject->context); > if (virt_wqs) { just if udata > @@ -1257,7 +1258,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, > > nes_put_cqp_request(nesdev, cqp_request); > > - if (ibpd->uobject) { > + if (rdma_is_user_pd(ibpd)) { > uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index; > uresp.mmap_rq_db_index = 0; > uresp.actual_sq_size = sq_size; if udata > diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > index 06d2a7f..d70ebd1 100644 > +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > @@ -1217,7 +1217,7 @@ static int ocrdma_check_qp_params(struct ib_pd *ibpd, struct ocrdma_dev *dev, > return -EINVAL; > } > /* unprivileged user space cannot create special QP */ > - if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { > + if (rdma_is_user_pd(ibpd) && attrs->qp_type == IB_QPT_GSI) { > pr_err > ("%s(%d) Userspace can't create special QPs of type=0x%x\n", > __func__, dev->id, attrs->qp_type); if udata > diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c > index 82ee4b4..cf4785a 100644 > +++ b/drivers/infiniband/hw/qedr/verbs.c > @@ -1189,7 +1189,7 @@ static int qedr_check_qp_attrs(struct ib_pd *ibpd, struct qedr_dev *dev, > } > > /* Unprivileged user space cannot create special QP */ > - if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { > + if (rdma_is_user_pd(ibpd) && attrs->qp_type == IB_QPT_GSI) { > DP_ERR(dev, > "create qp: userspace can't create special QPs of type=0x%x\n", > attrs->qp_type); if udata > @@ -1552,7 +1552,7 @@ int qedr_destroy_srq(struct ib_srq *ibsrq) > in_params.srq_id = srq->srq_id; > dev->ops->rdma_destroy_srq(dev->rdma_ctx, &in_params); > > - if (ibsrq->pd->uobject) > + if (rdma_is_user_pd(ibsrq->pd)) > qedr_free_srq_user_params(srq); > else > qedr_free_srq_kernel_params(srq); if ibsrq->uobject > diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c > index cf22f57..1a013e2d 100644 > +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c > @@ -249,7 +249,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, > init_completion(&qp->free); > > qp->state = IB_QPS_RESET; > - qp->is_kernel = !(pd->uobject && udata); > + qp->is_kernel = !(rdma_is_user_pd(pd) && udata); > > if (!qp->is_kernel) { > dev_dbg(&dev->pdev->dev, just udata > diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c > index dc0ce87..0b290f6 100644 > +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c > @@ -111,7 +111,7 @@ struct ib_srq *pvrdma_create_srq(struct ib_pd *pd, > unsigned long flags; > int ret; > > - if (!(pd->uobject && udata)) { > + if (!(rdma_is_user_pd(pd) && udata)) { > /* No support for kernel clients. */ > dev_warn(&dev->pdev->dev, > "no shared receive queue support for kernel client\n"); if udata > diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c > index b971090..0bceded 100644 > +++ b/drivers/infiniband/sw/rxe/rxe_qp.c > @@ -342,7 +342,8 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, > struct rxe_cq *rcq = to_rcq(init->recv_cq); > struct rxe_cq *scq = to_rcq(init->send_cq); > struct rxe_srq *srq = init->srq ? to_rsrq(init->srq) : NULL; > - struct ib_ucontext *context = ibpd->uobject ? ibpd->uobject->context : NULL; > + struct ib_ucontext *context = rdma_is_user_pd(ibpd) ? > + ibpd->uobject->context : NULL; > > rxe_add_ref(pd); > rxe_add_ref(rcq); Should be udata, need to pass udata. Jason
On Wed, Oct 31, 2018 at 11:55:15AM -0600, Jason Gunthorpe wrote: > On Wed, Oct 31, 2018 at 02:42:42PM +0200, Shamir Rabinovitch wrote: > > Now we have the ability to tell from ib_pd if ib_pd was > > created by user/kernel verbs. Stop using the ib_pd->uobject > > pointer for this. This patch prepare the ib_pb uobject pointer > > removal that will happen in another patch. > > > > Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com> > > drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++-- > > drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 2 +- > > drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- > > drivers/infiniband/hw/hns/hns_roce_qp.c | 17 +++++++++-------- > > drivers/infiniband/hw/i40iw/i40iw_verbs.c | 2 +- > > drivers/infiniband/hw/mlx4/qp.c | 11 ++++++----- > > drivers/infiniband/hw/mlx4/srq.c | 10 +++++----- > > drivers/infiniband/hw/mlx5/qp.c | 4 ++-- > > drivers/infiniband/hw/mlx5/srq.c | 8 ++++---- > > drivers/infiniband/hw/mthca/mthca_provider.c | 10 +++++----- > > drivers/infiniband/hw/mthca/mthca_qp.c | 7 ++++--- > > drivers/infiniband/hw/mthca/mthca_srq.c | 8 ++++---- > > drivers/infiniband/hw/nes/nes_verbs.c | 7 ++++--- > > drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- > > drivers/infiniband/hw/qedr/verbs.c | 4 ++-- > > drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 2 +- > > drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c | 2 +- > > drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++- > > 18 files changed, 56 insertions(+), 50 deletions(-) > > > > diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > > index 54fdd4c..d2d2630 100644 > > +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > > @@ -698,7 +698,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, > > ah->qplib_ah.flow_label = grh->flow_label; > > ah->qplib_ah.hop_limit = grh->hop_limit; > > ah->qplib_ah.sl = rdma_ah_get_sl(ah_attr); > > - if (ib_pd->uobject && > > + if (rdma_is_user_pd(ib_pd) && > > !rdma_is_multicast_addr((struct in6_addr *) > > grh->dgid.raw) && > > !rdma_link_local_addr((struct in6_addr *) > > I have no idea why this if is here, but looks like it should be 'if > (udata)' ? > > > @@ -729,7 +729,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, > > } > > > > /* Write AVID to shared page. */ > > - if (ib_pd->uobject) { > > + if (rdma_is_user_pd(ib_pd)) { > > struct ib_ucontext *ib_uctx = ib_pd->uobject->context; > > struct bnxt_re_ucontext *uctx; > > unsigned long flag; > > This should be 'if (udata) {.. ib_utx = get_uctx_from_udata(..);..' > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > > index 00170aa..a6c581a 100644 > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > > @@ -3926,7 +3926,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) > > struct hns_roce_qp_work *qp_work; > > struct hns_roce_v1_priv *priv; > > struct hns_roce_cq *send_cq, *recv_cq; > > - bool is_user = ibqp->pd->uobject; > > + bool is_user = rdma_is_user_pd(ibqp->pd); > > int is_timeout = 0; > > int ret; > > ibqp->uboject This assume that qp will never be shared? I thought we try to avoid having ib_x uobject pointer. Do you still prefer this rather then just ask rdma_is_user_pd which does not involve ib_qp uobject pointer? > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > index a4c62ae..8c659c1 100644 > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > @@ -4096,7 +4096,8 @@ static int hns_roce_v2_destroy_qp(struct ib_qp *ibqp) > > struct hns_roce_qp *hr_qp = to_hr_qp(ibqp); > > int ret; > > > > - ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, !!ibqp->pd->uobject); > > + ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, rdma_is_user_pd(ibqp->pd)); > > ibqp->uboject Same question as above > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c > > index 5ebf481..2b0c20f 100644 > > +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c > > @@ -562,7 +562,8 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > else > > hr_qp->sq_signal_bits = cpu_to_le32(IB_SIGNAL_REQ_WR); > > > > - ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, !!ib_pd->uobject, > > + ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, > > + rdma_is_user_pd(ib_pd), > > !!init_attr->srq, hr_qp); > > probably if udata > > > if (ret) { > > dev_err(dev, "hns_roce_set_rq_size failed\n"); > > @@ -599,7 +600,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > init_attr->cap.max_recv_sge]; > > } > > > > - if (ib_pd->uobject) { > > + if (rdma_is_user_pd(ib_pd)) { > > if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) { > > dev_err(dev, "ib_copy_from_udata error for create qp\n"); > > ret = -EFAULT; > > certainly if udata > > > @@ -784,7 +785,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > else > > hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn); > > > > - if (ib_pd->uobject && (udata->outlen >= sizeof(resp)) && > > + if (rdma_is_user_pd(ib_pd) && (udata->outlen >= sizeof(resp)) && > > (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) { > > certainly if udata > > > /* indicate kernel supports rq record db */ > > @@ -811,7 +812,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > hns_roce_release_range_qp(hr_dev, qpn, 1); > > > > err_wrid: > > - if (ib_pd->uobject) { > > + if (rdma_is_user_pd(ib_pd)) { > > if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) && > > (udata->outlen >= sizeof(resp)) && > > hns_roce_qp_has_rq(init_attr)) > > if udata > > > @@ -824,7 +825,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > } > > > > err_sq_dbmap: > > - if (ib_pd->uobject) > > + if (rdma_is_user_pd(ib_pd)) > > if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SQ_RECORD_DB) && > > (udata->inlen >= sizeof(ucmd)) && > > (udata->outlen >= sizeof(resp)) && > > if udata > > > @@ -837,13 +838,13 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > hns_roce_mtt_cleanup(hr_dev, &hr_qp->mtt); > > > > err_buf: > > - if (ib_pd->uobject) > > + if (rdma_is_user_pd(ib_pd)) > > ib_umem_release(hr_qp->umem); > > else > > hns_roce_buf_free(hr_dev, hr_qp->buff_size, &hr_qp->hr_buf); > > maybe if umem? > > > err_db: > > - if (!ib_pd->uobject && hns_roce_qp_has_rq(init_attr) && > > + if (!rdma_is_user_pd(ib_pd) && hns_roce_qp_has_rq(init_attr) && > > (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) > > hns_roce_free_db(hr_dev, &hr_qp->rdb); > > if udata? > > > @@ -889,7 +890,7 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd, > > } > > case IB_QPT_GSI: { > > /* Userspace is not allowed to create special QPs: */ > > - if (pd->uobject) { > > + if (rdma_is_user_pd(pd)) { > > dev_err(dev, "not support usr space GSI\n"); > > return ERR_PTR(-EINVAL); > > } > > This one looks sensible > > > diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c > > index 9d3178d..d60d883 100644 > > +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c > > @@ -2090,7 +2090,7 @@ static int i40iw_dereg_mr(struct ib_mr *ib_mr) > > ib_umem_release(iwmr->region); > > > > if (iwmr->type != IW_MEMREG_TYPE_MEM) { > > - if (ibpd->uobject) { > > + if (rdma_is_user_pd(ibpd)) { > > struct i40iw_ucontext *ucontext; > > > > ucontext = to_ucontext(ibpd->uobject->context); > > maybe if (iwmr->umem) ? > > > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c > > index c783539..af07eb0 100644 > > +++ b/drivers/infiniband/hw/mlx4/qp.c > > @@ -942,7 +942,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > > qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE); > > > > > > - if (pd->uobject) { > > + if (rdma_is_user_pd(pd)) { > > union { > > struct mlx4_ib_create_qp qp; > > struct mlx4_ib_create_wq wq; > > if udata (the next lines access udata) > > > @@ -991,7 +991,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > > qp->flags |= MLX4_IB_QP_SCATTER_FCS; > > } > > > > - err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, > > + err = set_rq_size(dev, &init_attr->cap, rdma_is_user_pd(pd), > > qp_has_rq(init_attr), qp, qp->inl_recv_sz); > > if (er > > goto err; > > if udata > > > @@ -1043,7 +1043,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > > } > > qp->mqp.usage = MLX4_RES_USAGE_USER_VERBS; > > } else { > > - err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, > > + err = set_rq_size(dev, &init_attr->cap, rdma_is_user_pd(pd), > > qp_has_rq(init_attr), qp, 0); > > if (err) > > goto err; > > if udata > > > @@ -1207,7 +1207,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > > mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf); > > > > err_db: > > - if (!pd->uobject && qp_has_rq(init_attr)) > > + if (rdma_is_user_pd(pd) && qp_has_rq(init_attr)) > > mlx4_db_free(dev->dev, &qp->db); > > if udata > > > err: > > @@ -1612,7 +1612,8 @@ static int _mlx4_ib_destroy_qp(struct ib_qp *qp) > > struct mlx4_ib_pd *pd; > > > > pd = get_pd(mqp); > > - destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, !!pd->ibpd.uobject); > > + destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, > > + rdma_is_user_pd(&pd->ibpd)); > > } > > if qp->uobject > > > if (is_sqp(dev, mqp)) > > diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c > > index 3731b31..b821a08 100644 > > +++ b/drivers/infiniband/hw/mlx4/srq.c > > @@ -105,7 +105,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > > > buf_size = srq->msrq.max * desc_size; > > > > - if (pd->uobject) { > > + if (rdma_is_user_pd(pd)) { > > struct mlx4_ib_create_srq ucmd; > > > > if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { > > if udata > > > @@ -191,7 +191,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > srq->msrq.event = mlx4_ib_srq_event; > > srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; > > > > - if (pd->uobject) > > + if (rdma_is_user_pd(pd)) > > if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof (__u32))) { > > err = -EFAULT; > > goto err_wrid; > > if udata > > > @@ -202,7 +202,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > return &srq->ibsrq; > > > > err_wrid: > > - if (pd->uobject) > > + if (rdma_is_user_pd(pd)) > > mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db); > > else > > kvfree(srq->wrid); > > if srq->uobject > > > @@ -211,13 +211,13 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > mlx4_mtt_cleanup(dev->dev, &srq->mtt); > > > > err_buf: > > - if (pd->uobject) > > + if (rdma_is_user_pd(pd)) > > ib_umem_release(srq->umem); > > else > > mlx4_buf_free(dev->dev, buf_size, &srq->buf); > > if srq->uobject? srq->umem? > > > err_db: > > - if (!pd->uobject) > > + if (!rdma_is_user_pd(pd)) > > mlx4_db_free(dev->dev, &srq->db); > > if srq->uobject > > > err_srq: > > diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c > > index 87e1675..c3ad24d 100644 > > +++ b/drivers/infiniband/hw/mlx5/qp.c > > @@ -1955,7 +1955,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, > > } > > > > if (pd) { > > - if (pd->uobject) { > > + if (rdma_is_user_pd(pd)) { > > __u32 max_wqes = > > 1 << MLX5_CAP_GEN(mdev, log_max_qp_sz); > > mlx5_ib_dbg(dev, "requested sq_wqe_count (%d)\n", ucmd.sq_wqe_count); > > if udata ? > > > @@ -2465,7 +2465,7 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, > > dev = to_mdev(pd->device); > > > > if (init_attr->qp_type == IB_QPT_RAW_PACKET) { > > - if (!pd->uobject) { > > + if (!rdma_is_user_pd(pd)) { > > mlx5_ib_dbg(dev, "Raw Packet QP is not supported for kernel consumers\n"); > > return ERR_PTR(-EINVAL); > > } else if (!to_mucontext(pd->uobject->context)->cqe_version) { > > if udata > > > diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c > > index d012e7d..c5eb189 100644 > > +++ b/drivers/infiniband/hw/mlx5/srq.c > > @@ -287,14 +287,14 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > > } > > in.type = init_attr->srq_type; > > > > - if (pd->uobject) > > + if (rdma_is_user_pd(pd)) > > err = create_srq_user(pd, srq, &in, udata, buf_size); > > else > > err = create_srq_kernel(dev, srq, &in, buf_size); > > if udata > > > if (err) { > > mlx5_ib_warn(dev, "create srq %s failed, err %d\n", > > - pd->uobject ? "user" : "kernel", err); > > + rdma_is_user_pd(pd) ? "user" : "kernel", err); > > goto err_srq; > > } > > if udata > > > @@ -339,7 +339,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > > srq->msrq.event = mlx5_ib_srq_event; > > srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; > > > > - if (pd->uobject) > > + if (rdma_is_user_pd(pd)) > > if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) { > > mlx5_ib_dbg(dev, "copy to user failed\n"); > > err = -EFAULT; > > if udata > > > @@ -354,7 +354,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > > mlx5_core_destroy_srq(dev->mdev, &srq->msrq); > > > > err_usr_kern_srq: > > - if (pd->uobject) > > + if (rdma_is_user_pd(pd)) > > destroy_srq_user(pd, srq); > > else > > destroy_srq_kernel(dev, srq); > > if srq->uobject > > > diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c > > index 691c6f0..683eaa6 100644 > > +++ b/drivers/infiniband/hw/mthca/mthca_provider.c > > @@ -455,7 +455,7 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, > > if (!srq) > > return ERR_PTR(-ENOMEM); > > > > - if (pd->uobject) { > > + if (rdma_is_user_pd(pd)) { > > context = to_mucontext(pd->uobject->context); > > if udata > > > if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { > > @@ -477,7 +477,7 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, > > err = mthca_alloc_srq(to_mdev(pd->device), to_mpd(pd), > > &init_attr->attr, srq); > > > > - if (err && pd->uobject) > > + if (err && rdma_is_user_pd(pd)) > > mthca_unmap_user_db(to_mdev(pd->device), &context->uar, > > context->db_tab, ucmd.db_index); > > if udata > > > @@ -537,7 +537,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > > if (!qp) > > return ERR_PTR(-ENOMEM); > > > > - if (pd->uobject) { > > + if (rdma_is_user_pd(pd)) { > > context = to_mucontext(pd->uobject->context); > > > > if (ib_copy_from_udata(&ucmd, udata, sizeof > > ucmd)) { > > if udata > > > @@ -576,7 +576,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > > init_attr->qp_type, init_attr->sq_sig_type, > > &init_attr->cap, qp); > > > > - if (err && pd->uobject) { > > + if (err && rdma_is_user_pd(pd)) { > > context = to_mucontext(pd->uobject->context); > > > > mthca_unmap_user_db(to_mdev(pd->device), > > if udata > > > @@ -596,7 +596,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > > case IB_QPT_GSI: > > { > > /* Don't allow userspace to create special QPs */ > > - if (pd->uobject) > > + if (rdma_is_user_pd(pd)) > > return ERR_PTR(-EINVAL); > > > > qp = kmalloc(sizeof (struct mthca_sqp), GFP_KERNEL); > > Fine > > > diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c > > index 9d178ee..ffa4526 100644 > > +++ b/drivers/infiniband/hw/mthca/mthca_qp.c > > @@ -951,7 +951,8 @@ static int mthca_max_data_size(struct mthca_dev *dev, struct mthca_qp *qp, int d > > static inline int mthca_max_inline_data(struct mthca_pd *pd, int max_data_size) > > { > > /* We don't support inline data for kernel QPs (yet). */ > > - return pd->ibpd.uobject ? max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; > > + return rdma_is_user_pd(&pd->ibpd) ? > > + max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; > > } > > Sigh, fine, that is annoying to fix > > > static void mthca_adjust_qp_caps(struct mthca_dev *dev, > > @@ -1048,7 +1049,7 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, > > * allocate anything. All we need is to calculate the WQE > > * sizes and the send_wqe_offset, so we're done now. > > */ > > - if (pd->ibpd.uobject) > > + if (rdma_is_user_pd(&pd->ibpd)) > > return 0; > > should be udata, but fine :\ Will fix this and the below. Thanks! > > > size = PAGE_ALIGN(qp->send_wqe_offset + > > @@ -1191,7 +1192,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev, > > * will be allocated and buffers will be initialized in > > * userspace. > > */ > > - if (pd->ibpd.uobject) > > + if (rdma_is_user_pd(&pd->ibpd)) > > return 0; > > Same > > > ret = mthca_alloc_memfree(dev, qp); > > diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c > > index 9a3fc6f..4e206d4 100644 > > +++ b/drivers/infiniband/hw/mthca/mthca_srq.c > > @@ -152,7 +152,7 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd, > > int err; > > int i; > > > > - if (pd->ibpd.uobject) > > + if (rdma_is_user_pd(&pd->ibpd)) > > return 0; > > Same > > > srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL); > > @@ -235,7 +235,7 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, > > if (err) > > goto err_out; > > > > - if (!pd->ibpd.uobject) { > > + if (!rdma_is_user_pd(&pd->ibpd)) { > > srq->db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SRQ, > > srq->srqn, &srq->db); > > if (srq->db_index < 0) { > > Same > > > @@ -297,14 +297,14 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, > > mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err); > > > > err_out_free_buf: > > - if (!pd->ibpd.uobject) > > + if (!rdma_is_user_pd(&pd->ibpd)) > > mthca_free_srq_buf(dev, srq); > > > > err_out_mailbox: > > mthca_free_mailbox(dev, mailbox); > > > > err_out_db: > > - if (!pd->ibpd.uobject && mthca_is_memfree(dev)) > > + if (!rdma_is_user_pd(&pd->ibpd) && mthca_is_memfree(dev)) > > mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index); > > > > err_out_icm: > > Same > > > diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c > > index 92d1cad..fc0100c 100644 > > +++ b/drivers/infiniband/hw/nes/nes_verbs.c > > @@ -733,7 +733,7 @@ static int nes_dealloc_pd(struct ib_pd *ibpd) > > struct nes_device *nesdev = nesvnic->nesdev; > > struct nes_adapter *nesadapter = nesdev->nesadapter; > > > > - if ((ibpd->uobject) && (ibpd->uobject->context)) { > > + if (rdma_is_user_pd(ibpd) && (ibpd->uobject->context)) { > > nesucontext = to_nesucontext(ibpd->uobject->context); > > nes_debug(NES_DBG_PD, "Clearing bit %u from allocated doorbells\n", > > nespd->mmap_db_index); > > Fine > > > @@ -1066,7 +1066,8 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, > > } > > if (req.user_qp_buffer) > > nesqp->nesuqp_addr = req.user_qp_buffer; > > - if ((ibpd->uobject) && (ibpd->uobject->context)) { > > + if (rdma_is_user_pd(ibpd) && > > + (ibpd->uobject->context)) { > > nesqp->user_mode = 1; > > nes_ucontext = to_nesucontext(ibpd->uobject->context); > > if (virt_wqs) { > > just if udata > > > @@ -1257,7 +1258,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, > > > > nes_put_cqp_request(nesdev, cqp_request); > > > > - if (ibpd->uobject) { > > + if (rdma_is_user_pd(ibpd)) { > > uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index; > > uresp.mmap_rq_db_index = 0; > > uresp.actual_sq_size = sq_size; > > if udata > > > diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > > index 06d2a7f..d70ebd1 100644 > > +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > > @@ -1217,7 +1217,7 @@ static int ocrdma_check_qp_params(struct ib_pd *ibpd, struct ocrdma_dev *dev, > > return -EINVAL; > > } > > /* unprivileged user space cannot create special QP */ > > - if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { > > + if (rdma_is_user_pd(ibpd) && attrs->qp_type == IB_QPT_GSI) { > > pr_err > > ("%s(%d) Userspace can't create special QPs of type=0x%x\n", > > __func__, dev->id, attrs->qp_type); > > if udata > > > diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c > > index 82ee4b4..cf4785a 100644 > > +++ b/drivers/infiniband/hw/qedr/verbs.c > > @@ -1189,7 +1189,7 @@ static int qedr_check_qp_attrs(struct ib_pd *ibpd, struct qedr_dev *dev, > > } > > > > /* Unprivileged user space cannot create special QP */ > > - if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { > > + if (rdma_is_user_pd(ibpd) && attrs->qp_type == IB_QPT_GSI) { > > DP_ERR(dev, > > "create qp: userspace can't create special QPs of type=0x%x\n", > > attrs->qp_type); > > if udata > > > @@ -1552,7 +1552,7 @@ int qedr_destroy_srq(struct ib_srq *ibsrq) > > in_params.srq_id = srq->srq_id; > > dev->ops->rdma_destroy_srq(dev->rdma_ctx, &in_params); > > > > - if (ibsrq->pd->uobject) > > + if (rdma_is_user_pd(ibsrq->pd)) > > qedr_free_srq_user_params(srq); > > else > > qedr_free_srq_kernel_params(srq); > > if ibsrq->uobject Same question as above. Do you assume that srq will never be shared? Any good reason to introduce new check on ib_x uobject rather then just use rdma_is_user_pd here? > > > diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c > > index cf22f57..1a013e2d 100644 > > +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c > > @@ -249,7 +249,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, > > init_completion(&qp->free); > > > > qp->state = IB_QPS_RESET; > > - qp->is_kernel = !(pd->uobject && udata); > > + qp->is_kernel = !(rdma_is_user_pd(pd) && udata); > > > > if (!qp->is_kernel) { > > dev_dbg(&dev->pdev->dev, > > just udata > > > diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c > > index dc0ce87..0b290f6 100644 > > +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c > > @@ -111,7 +111,7 @@ struct ib_srq *pvrdma_create_srq(struct ib_pd *pd, > > unsigned long flags; > > int ret; > > > > - if (!(pd->uobject && udata)) { > > + if (!(rdma_is_user_pd(pd) && udata)) { > > /* No support for kernel clients. */ > > dev_warn(&dev->pdev->dev, > > "no shared receive queue support for kernel client\n"); > > if udata > > > diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c > > index b971090..0bceded 100644 > > +++ b/drivers/infiniband/sw/rxe/rxe_qp.c > > @@ -342,7 +342,8 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, > > struct rxe_cq *rcq = to_rcq(init->recv_cq); > > struct rxe_cq *scq = to_rcq(init->send_cq); > > struct rxe_srq *srq = init->srq ? to_rsrq(init->srq) : NULL; > > - struct ib_ucontext *context = ibpd->uobject ? ibpd->uobject->context : NULL; > > + struct ib_ucontext *context = rdma_is_user_pd(ibpd) ? > > + ibpd->uobject->context : NULL; > > > > rxe_add_ref(pd); > > rxe_add_ref(rcq); > > Should be udata, need to pass udata. > > Jason
On Sun, Nov 04, 2018 at 10:36:32AM +0200, Shamir Rabinovitch wrote: > On Wed, Oct 31, 2018 at 11:55:15AM -0600, Jason Gunthorpe wrote: > > On Wed, Oct 31, 2018 at 02:42:42PM +0200, Shamir Rabinovitch wrote: > > > Now we have the ability to tell from ib_pd if ib_pd was > > > created by user/kernel verbs. Stop using the ib_pd->uobject > > > pointer for this. This patch prepare the ib_pb uobject pointer > > > removal that will happen in another patch. > > > > > > Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com> > > > drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++-- > > > drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 2 +- > > > drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- > > > drivers/infiniband/hw/hns/hns_roce_qp.c | 17 +++++++++-------- > > > drivers/infiniband/hw/i40iw/i40iw_verbs.c | 2 +- > > > drivers/infiniband/hw/mlx4/qp.c | 11 ++++++----- > > > drivers/infiniband/hw/mlx4/srq.c | 10 +++++----- > > > drivers/infiniband/hw/mlx5/qp.c | 4 ++-- > > > drivers/infiniband/hw/mlx5/srq.c | 8 ++++---- > > > drivers/infiniband/hw/mthca/mthca_provider.c | 10 +++++----- > > > drivers/infiniband/hw/mthca/mthca_qp.c | 7 ++++--- > > > drivers/infiniband/hw/mthca/mthca_srq.c | 8 ++++---- > > > drivers/infiniband/hw/nes/nes_verbs.c | 7 ++++--- > > > drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- > > > drivers/infiniband/hw/qedr/verbs.c | 4 ++-- > > > drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 2 +- > > > drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c | 2 +- > > > drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++- > > > 18 files changed, 56 insertions(+), 50 deletions(-) > > > > > > diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > > > index 54fdd4c..d2d2630 100644 > > > +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > > > @@ -698,7 +698,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, > > > ah->qplib_ah.flow_label = grh->flow_label; > > > ah->qplib_ah.hop_limit = grh->hop_limit; > > > ah->qplib_ah.sl = rdma_ah_get_sl(ah_attr); > > > - if (ib_pd->uobject && > > > + if (rdma_is_user_pd(ib_pd) && > > > !rdma_is_multicast_addr((struct in6_addr *) > > > grh->dgid.raw) && > > > !rdma_link_local_addr((struct in6_addr *) > > > > I have no idea why this if is here, but looks like it should be 'if > > (udata)' ? > > > > > @@ -729,7 +729,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, > > > } > > > > > > /* Write AVID to shared page. */ > > > - if (ib_pd->uobject) { > > > + if (rdma_is_user_pd(ib_pd)) { > > > struct ib_ucontext *ib_uctx = ib_pd->uobject->context; > > > struct bnxt_re_ucontext *uctx; > > > unsigned long flag; > > > > This should be 'if (udata) {.. ib_utx = get_uctx_from_udata(..);..' > > > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > > > index 00170aa..a6c581a 100644 > > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > > > @@ -3926,7 +3926,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) > > > struct hns_roce_qp_work *qp_work; > > > struct hns_roce_v1_priv *priv; > > > struct hns_roce_cq *send_cq, *recv_cq; > > > - bool is_user = ibqp->pd->uobject; > > > + bool is_user = rdma_is_user_pd(ibqp->pd); > > > int is_timeout = 0; > > > int ret; > > > > ibqp->uboject > > This assume that qp will never be shared? I thought we try to > avoid having ib_x uobject pointer. Do you still prefer this rather then > just ask rdma_is_user_pd which does not involve ib_qp uobject pointer? > > > > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > > index a4c62ae..8c659c1 100644 > > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > > @@ -4096,7 +4096,8 @@ static int hns_roce_v2_destroy_qp(struct ib_qp *ibqp) > > > struct hns_roce_qp *hr_qp = to_hr_qp(ibqp); > > > int ret; > > > > > > - ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, !!ibqp->pd->uobject); > > > + ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, rdma_is_user_pd(ibqp->pd)); > > > > ibqp->uboject > > Same question as above > > > > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c > > > index 5ebf481..2b0c20f 100644 > > > +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c > > > @@ -562,7 +562,8 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > > else > > > hr_qp->sq_signal_bits = cpu_to_le32(IB_SIGNAL_REQ_WR); > > > > > > - ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, !!ib_pd->uobject, > > > + ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, > > > + rdma_is_user_pd(ib_pd), > > > !!init_attr->srq, hr_qp); > > > > probably if udata > > > > > if (ret) { > > > dev_err(dev, "hns_roce_set_rq_size failed\n"); > > > @@ -599,7 +600,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > > init_attr->cap.max_recv_sge]; > > > } > > > > > > - if (ib_pd->uobject) { > > > + if (rdma_is_user_pd(ib_pd)) { > > > if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) { > > > dev_err(dev, "ib_copy_from_udata error for create qp\n"); > > > ret = -EFAULT; > > > > certainly if udata > > > > > @@ -784,7 +785,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > > else > > > hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn); > > > > > > - if (ib_pd->uobject && (udata->outlen >= sizeof(resp)) && > > > + if (rdma_is_user_pd(ib_pd) && (udata->outlen >= sizeof(resp)) && > > > (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) { > > > > certainly if udata > > > > > /* indicate kernel supports rq record db */ > > > @@ -811,7 +812,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > > hns_roce_release_range_qp(hr_dev, qpn, 1); > > > > > > err_wrid: > > > - if (ib_pd->uobject) { > > > + if (rdma_is_user_pd(ib_pd)) { > > > if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) && > > > (udata->outlen >= sizeof(resp)) && > > > hns_roce_qp_has_rq(init_attr)) > > > > if udata > > > > > @@ -824,7 +825,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > > } > > > > > > err_sq_dbmap: > > > - if (ib_pd->uobject) > > > + if (rdma_is_user_pd(ib_pd)) > > > if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SQ_RECORD_DB) && > > > (udata->inlen >= sizeof(ucmd)) && > > > (udata->outlen >= sizeof(resp)) && > > > > if udata > > > > > @@ -837,13 +838,13 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, > > > hns_roce_mtt_cleanup(hr_dev, &hr_qp->mtt); > > > > > > err_buf: > > > - if (ib_pd->uobject) > > > + if (rdma_is_user_pd(ib_pd)) > > > ib_umem_release(hr_qp->umem); > > > else > > > hns_roce_buf_free(hr_dev, hr_qp->buff_size, &hr_qp->hr_buf); > > > > maybe if umem? > > > > > err_db: > > > - if (!ib_pd->uobject && hns_roce_qp_has_rq(init_attr) && > > > + if (!rdma_is_user_pd(ib_pd) && hns_roce_qp_has_rq(init_attr) && > > > (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) > > > hns_roce_free_db(hr_dev, &hr_qp->rdb); > > > > if udata? > > > > > @@ -889,7 +890,7 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd, > > > } > > > case IB_QPT_GSI: { > > > /* Userspace is not allowed to create special QPs: */ > > > - if (pd->uobject) { > > > + if (rdma_is_user_pd(pd)) { > > > dev_err(dev, "not support usr space GSI\n"); > > > return ERR_PTR(-EINVAL); > > > } > > > > This one looks sensible > > > > > diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c > > > index 9d3178d..d60d883 100644 > > > +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c > > > @@ -2090,7 +2090,7 @@ static int i40iw_dereg_mr(struct ib_mr *ib_mr) > > > ib_umem_release(iwmr->region); > > > > > > if (iwmr->type != IW_MEMREG_TYPE_MEM) { > > > - if (ibpd->uobject) { > > > + if (rdma_is_user_pd(ibpd)) { > > > struct i40iw_ucontext *ucontext; > > > > > > ucontext = to_ucontext(ibpd->uobject->context); > > > > maybe if (iwmr->umem) ? > > > > > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c > > > index c783539..af07eb0 100644 > > > +++ b/drivers/infiniband/hw/mlx4/qp.c > > > @@ -942,7 +942,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > > > qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE); > > > > > > > > > - if (pd->uobject) { > > > + if (rdma_is_user_pd(pd)) { > > > union { > > > struct mlx4_ib_create_qp qp; > > > struct mlx4_ib_create_wq wq; > > > > if udata (the next lines access udata) > > > > > @@ -991,7 +991,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > > > qp->flags |= MLX4_IB_QP_SCATTER_FCS; > > > } > > > > > > - err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, > > > + err = set_rq_size(dev, &init_attr->cap, rdma_is_user_pd(pd), > > > qp_has_rq(init_attr), qp, qp->inl_recv_sz); > > > if (er > > > goto err; > > > > if udata > > > > > @@ -1043,7 +1043,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > > > } > > > qp->mqp.usage = MLX4_RES_USAGE_USER_VERBS; > > > } else { > > > - err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, > > > + err = set_rq_size(dev, &init_attr->cap, rdma_is_user_pd(pd), > > > qp_has_rq(init_attr), qp, 0); > > > if (err) > > > goto err; > > > > if udata > > > > > @@ -1207,7 +1207,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, > > > mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf); > > > > > > err_db: > > > - if (!pd->uobject && qp_has_rq(init_attr)) > > > + if (rdma_is_user_pd(pd) && qp_has_rq(init_attr)) > > > mlx4_db_free(dev->dev, &qp->db); > > > > if udata > > > > > err: > > > @@ -1612,7 +1612,8 @@ static int _mlx4_ib_destroy_qp(struct ib_qp *qp) > > > struct mlx4_ib_pd *pd; > > > > > > pd = get_pd(mqp); > > > - destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, !!pd->ibpd.uobject); > > > + destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, > > > + rdma_is_user_pd(&pd->ibpd)); > > > } > > > > if qp->uobject Same question as above > > > > > if (is_sqp(dev, mqp)) > > > diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c > > > index 3731b31..b821a08 100644 > > > +++ b/drivers/infiniband/hw/mlx4/srq.c > > > @@ -105,7 +105,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > > > > > buf_size = srq->msrq.max * desc_size; > > > > > > - if (pd->uobject) { > > > + if (rdma_is_user_pd(pd)) { > > > struct mlx4_ib_create_srq ucmd; > > > > > > if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { > > > > if udata > > > > > @@ -191,7 +191,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > > srq->msrq.event = mlx4_ib_srq_event; > > > srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; > > > > > > - if (pd->uobject) > > > + if (rdma_is_user_pd(pd)) > > > if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof (__u32))) { > > > err = -EFAULT; > > > goto err_wrid; > > > > if udata > > > > > @@ -202,7 +202,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > > return &srq->ibsrq; > > > > > > err_wrid: > > > - if (pd->uobject) > > > + if (rdma_is_user_pd(pd)) > > > mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db); > > > else > > > kvfree(srq->wrid); > > > > if srq->uobject Same question as above > > > > > @@ -211,13 +211,13 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > > mlx4_mtt_cleanup(dev->dev, &srq->mtt); > > > > > > err_buf: > > > - if (pd->uobject) > > > + if (rdma_is_user_pd(pd)) > > > ib_umem_release(srq->umem); > > > else > > > mlx4_buf_free(dev->dev, buf_size, &srq->buf); > > > > if srq->uobject? srq->umem? > > > > > err_db: > > > - if (!pd->uobject) > > > + if (!rdma_is_user_pd(pd)) > > > mlx4_db_free(dev->dev, &srq->db); > > > > if srq->uobject Same question as above > > > > > err_srq: > > > diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c > > > index 87e1675..c3ad24d 100644 > > > +++ b/drivers/infiniband/hw/mlx5/qp.c > > > @@ -1955,7 +1955,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, > > > } > > > > > > if (pd) { > > > - if (pd->uobject) { > > > + if (rdma_is_user_pd(pd)) { > > > __u32 max_wqes = > > > 1 << MLX5_CAP_GEN(mdev, log_max_qp_sz); > > > mlx5_ib_dbg(dev, "requested sq_wqe_count (%d)\n", ucmd.sq_wqe_count); > > > > if udata ? > > > > > @@ -2465,7 +2465,7 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, > > > dev = to_mdev(pd->device); > > > > > > if (init_attr->qp_type == IB_QPT_RAW_PACKET) { > > > - if (!pd->uobject) { > > > + if (!rdma_is_user_pd(pd)) { > > > mlx5_ib_dbg(dev, "Raw Packet QP is not supported for kernel consumers\n"); > > > return ERR_PTR(-EINVAL); > > > } else if (!to_mucontext(pd->uobject->context)->cqe_version) { > > > > if udata > > > > > diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c > > > index d012e7d..c5eb189 100644 > > > +++ b/drivers/infiniband/hw/mlx5/srq.c > > > @@ -287,14 +287,14 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > > > } > > > in.type = init_attr->srq_type; > > > > > > - if (pd->uobject) > > > + if (rdma_is_user_pd(pd)) > > > err = create_srq_user(pd, srq, &in, udata, buf_size); > > > else > > > err = create_srq_kernel(dev, srq, &in, buf_size); > > > > if udata > > > > > if (err) { > > > mlx5_ib_warn(dev, "create srq %s failed, err %d\n", > > > - pd->uobject ? "user" : "kernel", err); > > > + rdma_is_user_pd(pd) ? "user" : "kernel", err); > > > goto err_srq; > > > } > > > > if udata > > > > > @@ -339,7 +339,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > > > srq->msrq.event = mlx5_ib_srq_event; > > > srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; > > > > > > - if (pd->uobject) > > > + if (rdma_is_user_pd(pd)) > > > if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) { > > > mlx5_ib_dbg(dev, "copy to user failed\n"); > > > err = -EFAULT; > > > > if udata > > > > > @@ -354,7 +354,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > > > mlx5_core_destroy_srq(dev->mdev, &srq->msrq); > > > > > > err_usr_kern_srq: > > > - if (pd->uobject) > > > + if (rdma_is_user_pd(pd)) > > > destroy_srq_user(pd, srq); > > > else > > > destroy_srq_kernel(dev, srq); > > > > if srq->uobject Same question as above > > > > > diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c > > > index 691c6f0..683eaa6 100644 > > > +++ b/drivers/infiniband/hw/mthca/mthca_provider.c > > > @@ -455,7 +455,7 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, > > > if (!srq) > > > return ERR_PTR(-ENOMEM); > > > > > > - if (pd->uobject) { > > > + if (rdma_is_user_pd(pd)) { > > > context = to_mucontext(pd->uobject->context); > > > > if udata > > > > > if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { > > > @@ -477,7 +477,7 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, > > > err = mthca_alloc_srq(to_mdev(pd->device), to_mpd(pd), > > > &init_attr->attr, srq); > > > > > > - if (err && pd->uobject) > > > + if (err && rdma_is_user_pd(pd)) > > > mthca_unmap_user_db(to_mdev(pd->device), &context->uar, > > > context->db_tab, ucmd.db_index); > > > > if udata > > > > > @@ -537,7 +537,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > > > if (!qp) > > > return ERR_PTR(-ENOMEM); > > > > > > - if (pd->uobject) { > > > + if (rdma_is_user_pd(pd)) { > > > context = to_mucontext(pd->uobject->context); > > > > > > if (ib_copy_from_udata(&ucmd, udata, sizeof > > > ucmd)) { > > > > if udata > > > > > @@ -576,7 +576,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > > > init_attr->qp_type, init_attr->sq_sig_type, > > > &init_attr->cap, qp); > > > > > > - if (err && pd->uobject) { > > > + if (err && rdma_is_user_pd(pd)) { > > > context = to_mucontext(pd->uobject->context); > > > > > > mthca_unmap_user_db(to_mdev(pd->device), > > > > if udata > > > > > @@ -596,7 +596,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, > > > case IB_QPT_GSI: > > > { > > > /* Don't allow userspace to create special QPs */ > > > - if (pd->uobject) > > > + if (rdma_is_user_pd(pd)) > > > return ERR_PTR(-EINVAL); > > > > > > qp = kmalloc(sizeof (struct mthca_sqp), GFP_KERNEL); > > > > Fine > > > > > diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c > > > index 9d178ee..ffa4526 100644 > > > +++ b/drivers/infiniband/hw/mthca/mthca_qp.c > > > @@ -951,7 +951,8 @@ static int mthca_max_data_size(struct mthca_dev *dev, struct mthca_qp *qp, int d > > > static inline int mthca_max_inline_data(struct mthca_pd *pd, int max_data_size) > > > { > > > /* We don't support inline data for kernel QPs (yet). */ > > > - return pd->ibpd.uobject ? max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; > > > + return rdma_is_user_pd(&pd->ibpd) ? > > > + max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; > > > } > > > > Sigh, fine, that is annoying to fix > > > > > static void mthca_adjust_qp_caps(struct mthca_dev *dev, > > > @@ -1048,7 +1049,7 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, > > > * allocate anything. All we need is to calculate the WQE > > > * sizes and the send_wqe_offset, so we're done now. > > > */ > > > - if (pd->ibpd.uobject) > > > + if (rdma_is_user_pd(&pd->ibpd)) > > > return 0; > > > > should be udata, but fine :\ > > Will fix this and the below. Thanks! > > > > > > size = PAGE_ALIGN(qp->send_wqe_offset + > > > @@ -1191,7 +1192,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev, > > > * will be allocated and buffers will be initialized in > > > * userspace. > > > */ > > > - if (pd->ibpd.uobject) > > > + if (rdma_is_user_pd(&pd->ibpd)) > > > return 0; > > > > Same Sigh. No udata here. Maybe 'if (qp->mr.umem)' ? > > > > > ret = mthca_alloc_memfree(dev, qp); > > > diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c > > > index 9a3fc6f..4e206d4 100644 > > > +++ b/drivers/infiniband/hw/mthca/mthca_srq.c > > > @@ -152,7 +152,7 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd, > > > int err; > > > int i; > > > > > > - if (pd->ibpd.uobject) > > > + if (rdma_is_user_pd(&pd->ibpd)) > > > return 0; > > > > Same Sigh. No udata here. Maybe 'if (srq->mr.umem)' ? > > > > > srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL); > > > @@ -235,7 +235,7 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, > > > if (err) > > > goto err_out; > > > > > > - if (!pd->ibpd.uobject) { > > > + if (!rdma_is_user_pd(&pd->ibpd)) { > > > srq->db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SRQ, > > > srq->srqn, &srq->db); > > > if (srq->db_index < 0) { > > > > Same Sigh. No udata here. Maybe 'if (srq->mr.umem)' ? > > > > > @@ -297,14 +297,14 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, > > > mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err); > > > > > > err_out_free_buf: > > > - if (!pd->ibpd.uobject) > > > + if (!rdma_is_user_pd(&pd->ibpd)) > > > mthca_free_srq_buf(dev, srq); > > > > > > err_out_mailbox: > > > mthca_free_mailbox(dev, mailbox); > > > > > > err_out_db: > > > - if (!pd->ibpd.uobject && mthca_is_memfree(dev)) > > > + if (!rdma_is_user_pd(&pd->ibpd) && mthca_is_memfree(dev)) > > > mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index); > > > > > > err_out_icm: > > > > Same Sigh. No udata here. Maybe pass udata from mthca_create_srq ? > > > > > diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c > > > index 92d1cad..fc0100c 100644 > > > +++ b/drivers/infiniband/hw/nes/nes_verbs.c > > > @@ -733,7 +733,7 @@ static int nes_dealloc_pd(struct ib_pd *ibpd) > > > struct nes_device *nesdev = nesvnic->nesdev; > > > struct nes_adapter *nesadapter = nesdev->nesadapter; > > > > > > - if ((ibpd->uobject) && (ibpd->uobject->context)) { > > > + if (rdma_is_user_pd(ibpd) && (ibpd->uobject->context)) { > > > nesucontext = to_nesucontext(ibpd->uobject->context); > > > nes_debug(NES_DBG_PD, "Clearing bit %u from allocated doorbells\n", > > > nespd->mmap_db_index); > > > > Fine > > > > > @@ -1066,7 +1066,8 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, > > > } > > > if (req.user_qp_buffer) > > > nesqp->nesuqp_addr = req.user_qp_buffer; > > > - if ((ibpd->uobject) && (ibpd->uobject->context)) { > > > + if (rdma_is_user_pd(ibpd) && > > > + (ibpd->uobject->context)) { > > > nesqp->user_mode = 1; > > > nes_ucontext = to_nesucontext(ibpd->uobject->context); > > > if (virt_wqs) { > > > > just if udata > > > > > @@ -1257,7 +1258,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, > > > > > > nes_put_cqp_request(nesdev, cqp_request); > > > > > > - if (ibpd->uobject) { > > > + if (rdma_is_user_pd(ibpd)) { > > > uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index; > > > uresp.mmap_rq_db_index = 0; > > > uresp.actual_sq_size = sq_size; > > > > if udata > > > > > diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > > > index 06d2a7f..d70ebd1 100644 > > > +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > > > @@ -1217,7 +1217,7 @@ static int ocrdma_check_qp_params(struct ib_pd *ibpd, struct ocrdma_dev *dev, > > > return -EINVAL; > > > } > > > /* unprivileged user space cannot create special QP */ > > > - if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { > > > + if (rdma_is_user_pd(ibpd) && attrs->qp_type == IB_QPT_GSI) { > > > pr_err > > > ("%s(%d) Userspace can't create special QPs of type=0x%x\n", > > > __func__, dev->id, attrs->qp_type); > > > > if udata > > > > > diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c > > > index 82ee4b4..cf4785a 100644 > > > +++ b/drivers/infiniband/hw/qedr/verbs.c > > > @@ -1189,7 +1189,7 @@ static int qedr_check_qp_attrs(struct ib_pd *ibpd, struct qedr_dev *dev, > > > } > > > > > > /* Unprivileged user space cannot create special QP */ > > > - if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { > > > + if (rdma_is_user_pd(ibpd) && attrs->qp_type == IB_QPT_GSI) { > > > DP_ERR(dev, > > > "create qp: userspace can't create special QPs of type=0x%x\n", > > > attrs->qp_type); > > > > if udata > > > > > @@ -1552,7 +1552,7 @@ int qedr_destroy_srq(struct ib_srq *ibsrq) > > > in_params.srq_id = srq->srq_id; > > > dev->ops->rdma_destroy_srq(dev->rdma_ctx, &in_params); > > > > > > - if (ibsrq->pd->uobject) > > > + if (rdma_is_user_pd(ibsrq->pd)) > > > qedr_free_srq_user_params(srq); > > > else > > > qedr_free_srq_kernel_params(srq); > > > > if ibsrq->uobject > > Same question as above. Do you assume that srq will never be shared? > Any good reason to introduce new check on ib_x uobject rather then just > use rdma_is_user_pd here? > > > > > > diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c > > > index cf22f57..1a013e2d 100644 > > > +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c > > > @@ -249,7 +249,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, > > > init_completion(&qp->free); > > > > > > qp->state = IB_QPS_RESET; > > > - qp->is_kernel = !(pd->uobject && udata); > > > + qp->is_kernel = !(rdma_is_user_pd(pd) && udata); > > > > > > if (!qp->is_kernel) { > > > dev_dbg(&dev->pdev->dev, > > > > just udata > > > > > diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c > > > index dc0ce87..0b290f6 100644 > > > +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c > > > @@ -111,7 +111,7 @@ struct ib_srq *pvrdma_create_srq(struct ib_pd *pd, > > > unsigned long flags; > > > int ret; > > > > > > - if (!(pd->uobject && udata)) { > > > + if (!(rdma_is_user_pd(pd) && udata)) { > > > /* No support for kernel clients. */ > > > dev_warn(&dev->pdev->dev, > > > "no shared receive queue support for kernel client\n"); > > > > if udata > > > > > diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c > > > index b971090..0bceded 100644 > > > +++ b/drivers/infiniband/sw/rxe/rxe_qp.c > > > @@ -342,7 +342,8 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, > > > struct rxe_cq *rcq = to_rcq(init->recv_cq); > > > struct rxe_cq *scq = to_rcq(init->send_cq); > > > struct rxe_srq *srq = init->srq ? to_rsrq(init->srq) : NULL; > > > - struct ib_ucontext *context = ibpd->uobject ? ibpd->uobject->context : NULL; > > > + struct ib_ucontext *context = rdma_is_user_pd(ibpd) ? > > > + ibpd->uobject->context : NULL; > > > > > > rxe_add_ref(pd); > > > rxe_add_ref(rcq); > > > > Should be udata, need to pass udata. > > > > Jason
On Sun, Nov 04, 2018 at 02:20:51PM +0200, Shamir Rabinovitch wrote: > On Sun, Nov 04, 2018 at 10:36:32AM +0200, Shamir Rabinovitch wrote: > > On Wed, Oct 31, 2018 at 11:55:15AM -0600, Jason Gunthorpe wrote: > > > On Wed, Oct 31, 2018 at 02:42:42PM +0200, Shamir Rabinovitch wrote: > > > > Now we have the ability to tell from ib_pd if ib_pd was > > > > created by user/kernel verbs. Stop using the ib_pd->uobject > > > > pointer for this. This patch prepare the ib_pb uobject pointer > > > > removal that will happen in another patch. > > > > [...] > > > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > > > > @@ -3926,7 +3926,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) > > > > struct hns_roce_qp_work *qp_work; > > > > struct hns_roce_v1_priv *priv; > > > > struct hns_roce_cq *send_cq, *recv_cq; > > > > - bool is_user = ibqp->pd->uobject; > > > > + bool is_user = rdma_is_user_pd(ibqp->pd); > > > > int is_timeout = 0; > > > > int ret; > > > > > > ibqp->uboject > > > > This assume that qp will never be shared? I thought we try to > > avoid having ib_x uobject pointer. Do you still prefer this rather then > > just ask rdma_is_user_pd which does not involve ib_qp uobject pointer? > > > > > > > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > > > index a4c62ae..8c659c1 100644 > > > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c > > > > @@ -4096,7 +4096,8 @@ static int hns_roce_v2_destroy_qp(struct ib_qp *ibqp) > > > > struct hns_roce_qp *hr_qp = to_hr_qp(ibqp); > > > > int ret; > > > > > > > > - ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, !!ibqp->pd->uobject); > > > > + ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, rdma_is_user_pd(ibqp->pd)); > > > > > > ibqp->uboject > > > > Same question as above > > > > > [...] > > > > @@ -1612,7 +1612,8 @@ static int _mlx4_ib_destroy_qp(struct ib_qp *qp) > > > > struct mlx4_ib_pd *pd; > > > > > > > > pd = get_pd(mqp); > > > > - destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, !!pd->ibpd.uobject); > > > > + destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, > > > > + rdma_is_user_pd(&pd->ibpd)); > > > > } > > > > > > if qp->uobject > > Same question as above > [...] > > > > @@ -202,7 +202,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > > > return &srq->ibsrq; > > > > > > > > err_wrid: > > > > - if (pd->uobject) > > > > + if (rdma_is_user_pd(pd)) > > > > mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db); > > > > else > > > > kvfree(srq->wrid); > > > > > > if srq->uobject > > Same question as above > [...] > > > > @@ -211,13 +211,13 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, > > > > mlx4_mtt_cleanup(dev->dev, &srq->mtt); > > > > > > > > err_buf: > > > > - if (pd->uobject) > > > > + if (rdma_is_user_pd(pd)) > > > > ib_umem_release(srq->umem); > > > > else > > > > mlx4_buf_free(dev->dev, buf_size, &srq->buf); > > > > > > if srq->uobject? srq->umem? I took the 'srq->umem' option... > > > > > > > err_db: > > > > - if (!pd->uobject) > > > > + if (!rdma_is_user_pd(pd)) > > > > mlx4_db_free(dev->dev, &srq->db); > > > > > > if srq->uobject > > Same question as above > [...] > > > > @@ -354,7 +354,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, > > > > mlx5_core_destroy_srq(dev->mdev, &srq->msrq); > > > > > > > > err_usr_kern_srq: > > > > - if (pd->uobject) > > > > + if (rdma_is_user_pd(pd)) > > > > destroy_srq_user(pd, srq); > > > > else > > > > destroy_srq_kernel(dev, srq); > > > > > > if srq->uobject > > Same question as above > Jason, pushing udata to wherever it was missing was not so bad as I thought so this part is OK. I only left with question around your request to use 'ib_x->uobject'. If it is OK with you I'd rather to switch those which only tell user/kernel to rdma_is_user_pd as was in the previous revision. Thanks
On Mon, Nov 05, 2018 at 08:54:22AM +0200, Shamir Rabinovitch wrote: > On Sun, Nov 04, 2018 at 02:20:51PM +0200, Shamir Rabinovitch wrote: > > On Sun, Nov 04, 2018 at 10:36:32AM +0200, Shamir Rabinovitch wrote: > > > On Wed, Oct 31, 2018 at 11:55:15AM -0600, Jason Gunthorpe wrote: > > > > On Wed, Oct 31, 2018 at 02:42:42PM +0200, Shamir Rabinovitch wrote: [...] > > Jason, pushing udata to wherever it was missing was not so bad as I > thought so this part is OK. I only left with question around your > request to use 'ib_x->uobject'. If it is OK with you I'd rather to > switch those which only tell user/kernel to rdma_is_user_pd as was in > the previous revision. > > Thanks Jason, Series #2 (pending on series #1) add ib_udata in ib_device callbacks. I noticed that if I add those patches to series #1 I can use ib_udata in almost all the places as you wanted. I have created and tested this new patch set and it is on my github. I think it can solve some of the issues you had with v3 of the patch set. Please tell me if you like me to post this revised patch set here instead of fixing the current patch set. https://github.com/torvalds/linux/compare/master...srabinov:for-next%23remove-uobj-from-ib_pd.v4.patch-set-1 Thanks
On Sun, Nov 04, 2018 at 10:36:32AM +0200, Shamir Rabinovitch wrote: > On Wed, Oct 31, 2018 at 11:55:15AM -0600, Jason Gunthorpe wrote: > > On Wed, Oct 31, 2018 at 02:42:42PM +0200, Shamir Rabinovitch wrote: > > > Now we have the ability to tell from ib_pd if ib_pd was > > > created by user/kernel verbs. Stop using the ib_pd->uobject > > > pointer for this. This patch prepare the ib_pb uobject pointer > > > removal that will happen in another patch. > > > > > > Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com> > > > drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++-- > > > drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 2 +- > > > drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- > > > drivers/infiniband/hw/hns/hns_roce_qp.c | 17 +++++++++-------- > > > drivers/infiniband/hw/i40iw/i40iw_verbs.c | 2 +- > > > drivers/infiniband/hw/mlx4/qp.c | 11 ++++++----- > > > drivers/infiniband/hw/mlx4/srq.c | 10 +++++----- > > > drivers/infiniband/hw/mlx5/qp.c | 4 ++-- > > > drivers/infiniband/hw/mlx5/srq.c | 8 ++++---- > > > drivers/infiniband/hw/mthca/mthca_provider.c | 10 +++++----- > > > drivers/infiniband/hw/mthca/mthca_qp.c | 7 ++++--- > > > drivers/infiniband/hw/mthca/mthca_srq.c | 8 ++++---- > > > drivers/infiniband/hw/nes/nes_verbs.c | 7 ++++--- > > > drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- > > > drivers/infiniband/hw/qedr/verbs.c | 4 ++-- > > > drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 2 +- > > > drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c | 2 +- > > > drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++- > > > 18 files changed, 56 insertions(+), 50 deletions(-) > > > > > > diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > > > index 54fdd4c..d2d2630 100644 > > > +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > > > @@ -698,7 +698,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, > > > ah->qplib_ah.flow_label = grh->flow_label; > > > ah->qplib_ah.hop_limit = grh->hop_limit; > > > ah->qplib_ah.sl = rdma_ah_get_sl(ah_attr); > > > - if (ib_pd->uobject && > > > + if (rdma_is_user_pd(ib_pd) && > > > !rdma_is_multicast_addr((struct in6_addr *) > > > grh->dgid.raw) && > > > !rdma_link_local_addr((struct in6_addr *) > > > > I have no idea why this if is here, but looks like it should be 'if > > (udata)' ? > > > > > @@ -729,7 +729,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, > > > } > > > > > > /* Write AVID to shared page. */ > > > - if (ib_pd->uobject) { > > > + if (rdma_is_user_pd(ib_pd)) { > > > struct ib_ucontext *ib_uctx = ib_pd->uobject->context; > > > struct bnxt_re_ucontext *uctx; > > > unsigned long flag; > > > > This should be 'if (udata) {.. ib_utx = get_uctx_from_udata(..);..' > > > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > > > index 00170aa..a6c581a 100644 > > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > > > @@ -3926,7 +3926,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) > > > struct hns_roce_qp_work *qp_work; > > > struct hns_roce_v1_priv *priv; > > > struct hns_roce_cq *send_cq, *recv_cq; > > > - bool is_user = ibqp->pd->uobject; > > > + bool is_user = rdma_is_user_pd(ibqp->pd); > > > int is_timeout = 0; > > > int ret; > > > > ibqp->uboject > > This assume that qp will never be shared? I thought we try to > avoid having ib_x uobject pointer. Do you still prefer this rather then > just ask rdma_is_user_pd which does not involve ib_qp uobject pointer? The PD should not be used to infer the user-ness of the QP, that is a mistake in this driver. If we want to drop the qp->uobjec then we need a rdma_is_user_qp() and that would replace this.. > > > @@ -1552,7 +1552,7 @@ int qedr_destroy_srq(struct ib_srq *ibsrq) > > > in_params.srq_id = srq->srq_id; > > > dev->ops->rdma_destroy_srq(dev->rdma_ctx, &in_params); > > > > > > - if (ibsrq->pd->uobject) > > > + if (rdma_is_user_pd(ibsrq->pd)) > > > qedr_free_srq_user_params(srq); > > > else > > > qedr_free_srq_kernel_params(srq); > > > > if ibsrq->uobject > > Same question as above. Do you assume that srq will never be shared? > Any good reason to introduce new check on ib_x uobject rather then just > use rdma_is_user_pd here? same reason - the pd userness should not be used to imply the userness of objects below it... Jason
On Mon, Nov 05, 2018 at 04:27:40PM +0200, Shamir Rabinovitch wrote: > On Mon, Nov 05, 2018 at 08:54:22AM +0200, Shamir Rabinovitch wrote: > > On Sun, Nov 04, 2018 at 02:20:51PM +0200, Shamir Rabinovitch wrote: > > > On Sun, Nov 04, 2018 at 10:36:32AM +0200, Shamir Rabinovitch wrote: > > > > On Wed, Oct 31, 2018 at 11:55:15AM -0600, Jason Gunthorpe wrote: > > > > > On Wed, Oct 31, 2018 at 02:42:42PM +0200, Shamir Rabinovitch wrote: > > [...] > > > > > Jason, pushing udata to wherever it was missing was not so bad as I > > thought so this part is OK. I only left with question around your > > request to use 'ib_x->uobject'. If it is OK with you I'd rather to > > switch those which only tell user/kernel to rdma_is_user_pd as was in > > the previous revision. > > > > Thanks > > Jason, Series #2 (pending on series #1) add ib_udata in ib_device > callbacks. I noticed that if I add those patches to series #1 I can use > ib_udata in almost all the places as you wanted. I have created and > tested this new patch set and it is on my github. I think it can solve > some of the issues you had with v3 of the patch set. Please tell me if > you like me to post this revised patch set here instead of fixing the > current patch set. I don't know if you should add udata to destroy... That is quite weird. It is important to keep things ordered - the userness of an object during creation is tested by the udata parameter, then the userness of that object should be checked by restack's is_user/or uobject for the rest of its lifetime. It is not good to assume udata to non-creation ops like modify or destroy implies anything about the userness of the object in the first place.. Anyhow, it seems fine to drop some of the udata patches into this series if using udata means less uses of is_user_pd... Jason
On Mon, Nov 05, 2018 at 01:56:28PM -0700, Jason Gunthorpe wrote: > On Mon, Nov 05, 2018 at 04:27:40PM +0200, Shamir Rabinovitch wrote: > > On Mon, Nov 05, 2018 at 08:54:22AM +0200, Shamir Rabinovitch wrote: > > > On Sun, Nov 04, 2018 at 02:20:51PM +0200, Shamir Rabinovitch wrote: > > > > On Sun, Nov 04, 2018 at 10:36:32AM +0200, Shamir Rabinovitch wrote: > > > > > On Wed, Oct 31, 2018 at 11:55:15AM -0600, Jason Gunthorpe wrote: > > > > > > On Wed, Oct 31, 2018 at 02:42:42PM +0200, Shamir Rabinovitch wrote: [...] > > > > Jason, Series #2 (pending on series #1) add ib_udata in ib_device > > callbacks. I noticed that if I add those patches to series #1 I can use > > ib_udata in almost all the places as you wanted. I have created and > > tested this new patch set and it is on my github. I think it can solve > > some of the issues you had with v3 of the patch set. Please tell me if > > you like me to post this revised patch set here instead of fixing the > > current patch set. > > I don't know if you should add udata to destroy... That is quite weird. > > It is important to keep things ordered - the userness of an object > during creation is tested by the udata parameter, then the userness of > that object should be checked by restack's is_user/or uobject for the > rest of its lifetime. Jason, Please see below why using uobject is not good option. Please tell me if you think that I need to add those objects (like ib_wq) to the restrack. I thought there was a reason they are not part of the restrack in first place but I might be wrong here. > > It is not good to assume udata to non-creation ops like modify or > destroy implies anything about the userness of the object in the first > place.. > > Anyhow, it seems fine to drop some of the udata patches into this > series if using udata means less uses of is_user_pd... > > Jason Jason, down the road I need to remove uobject pointers from ib_xx objects to allow sharing of those ib_xx objects. I can skip patch like 'IB/verbs: destroy_wq verb need ib_udata' and use the ucontext from the ib_wq->uobject->context but this will not allow sharing of ib_wq. This series is focused in releasing the ib_pd from telling kernel/user on all sort of ib_xx objects. But next series will push the ib_ucontext via the ib_udata to allow me to release the rest of the ib_xx objects from the dependency in the uobject->ucontext they have. Do you still want to skip patches that add udata to destroy/modify ops? Thanks
On Tue, Nov 06, 2018 at 10:54:27AM +0200, Shamir Rabinovitch wrote: > Jason, down the road I need to remove uobject pointers from ib_xx > objects to allow sharing of those ib_xx objects. I can skip patch like > 'IB/verbs: destroy_wq verb need ib_udata' and use the ucontext from the > ib_wq->uobject->context but this will not allow sharing of ib_wq. This > series is focused in releasing the ib_pd from telling kernel/user on all > sort of ib_xx objects. But next series will push the ib_ucontext via the > ib_udata to allow me to release the rest of the ib_xx objects from the > dependency in the uobject->ucontext they have. Most of the other objects have very difficult problems when it comes to sharing (QP, SRQ, WQ, etc) as they have internal state that is hardware specific and hard to share. So I don't really expect patches to make those objects shareable anytime soon, and if we do, then they can use restrack, etc. > Do you still want to skip patches that add udata to destroy/modify ops? Any destroy really shouldn't have a udata without a really good reason - there should not be driver specific data with destroy. Objects, particularly shared objects, should not be storing things in the ucontext, as that mucks up the sharing. That is another reason why QP is very difficult to share as most of the drivers have per QP state in the uncontext.. So I prefer to not worry right now about anything beyond PD and MR. Jason
On 11/6/2018 7:38 AM, Jason Gunthorpe wrote: > On Tue, Nov 06, 2018 at 10:54:27AM +0200, Shamir Rabinovitch wrote: > >> Jason, down the road I need to remove uobject pointers from ib_xx >> objects to allow sharing of those ib_xx objects. I can skip patch like >> 'IB/verbs: destroy_wq verb need ib_udata' and use the ucontext from the >> ib_wq->uobject->context but this will not allow sharing of ib_wq. This >> series is focused in releasing the ib_pd from telling kernel/user on all >> sort of ib_xx objects. But next series will push the ib_ucontext via the >> ib_udata to allow me to release the rest of the ib_xx objects from the >> dependency in the uobject->ucontext they have. > > Most of the other objects have very difficult problems when it comes > to sharing (QP, SRQ, WQ, etc) as they have internal state that is > hardware specific and hard to share. So I don't really expect patches > to make those objects shareable anytime soon, and if we do, then they > can use restrack, etc. > >> Do you still want to skip patches that add udata to destroy/modify ops? > > Any destroy really shouldn't have a udata without a really good reason > - there should not be driver specific data with destroy. > > Objects, particularly shared objects, should not be storing things in > the ucontext, as that mucks up the sharing. > > That is another reason why QP is very difficult to share as most of > the drivers have per QP state in the uncontext.. > > So I prefer to not worry right now about anything beyond PD and MR. > Thanks and indeed this will help instead considering all the objects. PD and MR at least have usecase(s) for sharing. Regards, Santosh
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index 54fdd4c..d2d2630 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -698,7 +698,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, ah->qplib_ah.flow_label = grh->flow_label; ah->qplib_ah.hop_limit = grh->hop_limit; ah->qplib_ah.sl = rdma_ah_get_sl(ah_attr); - if (ib_pd->uobject && + if (rdma_is_user_pd(ib_pd) && !rdma_is_multicast_addr((struct in6_addr *) grh->dgid.raw) && !rdma_link_local_addr((struct in6_addr *) @@ -729,7 +729,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd, } /* Write AVID to shared page. */ - if (ib_pd->uobject) { + if (rdma_is_user_pd(ib_pd)) { struct ib_ucontext *ib_uctx = ib_pd->uobject->context; struct bnxt_re_ucontext *uctx; unsigned long flag; diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c index 00170aa..a6c581a 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c @@ -3926,7 +3926,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) struct hns_roce_qp_work *qp_work; struct hns_roce_v1_priv *priv; struct hns_roce_cq *send_cq, *recv_cq; - bool is_user = ibqp->pd->uobject; + bool is_user = rdma_is_user_pd(ibqp->pd); int is_timeout = 0; int ret; diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index a4c62ae..8c659c1 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -4096,7 +4096,8 @@ static int hns_roce_v2_destroy_qp(struct ib_qp *ibqp) struct hns_roce_qp *hr_qp = to_hr_qp(ibqp); int ret; - ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, !!ibqp->pd->uobject); + ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, + rdma_is_user_pd(ibqp->pd)); if (ret) { dev_err(hr_dev->dev, "Destroy qp failed(%d)\n", ret); return ret; diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c index 5ebf481..2b0c20f 100644 --- a/drivers/infiniband/hw/hns/hns_roce_qp.c +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c @@ -562,7 +562,8 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, else hr_qp->sq_signal_bits = cpu_to_le32(IB_SIGNAL_REQ_WR); - ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, !!ib_pd->uobject, + ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, + rdma_is_user_pd(ib_pd), !!init_attr->srq, hr_qp); if (ret) { dev_err(dev, "hns_roce_set_rq_size failed\n"); @@ -599,7 +600,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, init_attr->cap.max_recv_sge]; } - if (ib_pd->uobject) { + if (rdma_is_user_pd(ib_pd)) { if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) { dev_err(dev, "ib_copy_from_udata error for create qp\n"); ret = -EFAULT; @@ -784,7 +785,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, else hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn); - if (ib_pd->uobject && (udata->outlen >= sizeof(resp)) && + if (rdma_is_user_pd(ib_pd) && (udata->outlen >= sizeof(resp)) && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) { /* indicate kernel supports rq record db */ @@ -811,7 +812,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, hns_roce_release_range_qp(hr_dev, qpn, 1); err_wrid: - if (ib_pd->uobject) { + if (rdma_is_user_pd(ib_pd)) { if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) && (udata->outlen >= sizeof(resp)) && hns_roce_qp_has_rq(init_attr)) @@ -824,7 +825,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, } err_sq_dbmap: - if (ib_pd->uobject) + if (rdma_is_user_pd(ib_pd)) if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SQ_RECORD_DB) && (udata->inlen >= sizeof(ucmd)) && (udata->outlen >= sizeof(resp)) && @@ -837,13 +838,13 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, hns_roce_mtt_cleanup(hr_dev, &hr_qp->mtt); err_buf: - if (ib_pd->uobject) + if (rdma_is_user_pd(ib_pd)) ib_umem_release(hr_qp->umem); else hns_roce_buf_free(hr_dev, hr_qp->buff_size, &hr_qp->hr_buf); err_db: - if (!ib_pd->uobject && hns_roce_qp_has_rq(init_attr) && + if (!rdma_is_user_pd(ib_pd) && hns_roce_qp_has_rq(init_attr) && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) hns_roce_free_db(hr_dev, &hr_qp->rdb); @@ -889,7 +890,7 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd, } case IB_QPT_GSI: { /* Userspace is not allowed to create special QPs: */ - if (pd->uobject) { + if (rdma_is_user_pd(pd)) { dev_err(dev, "not support usr space GSI\n"); return ERR_PTR(-EINVAL); } diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c index 9d3178d..d60d883 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c @@ -2090,7 +2090,7 @@ static int i40iw_dereg_mr(struct ib_mr *ib_mr) ib_umem_release(iwmr->region); if (iwmr->type != IW_MEMREG_TYPE_MEM) { - if (ibpd->uobject) { + if (rdma_is_user_pd(ibpd)) { struct i40iw_ucontext *ucontext; ucontext = to_ucontext(ibpd->uobject->context); diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index c783539..af07eb0 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c @@ -942,7 +942,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE); - if (pd->uobject) { + if (rdma_is_user_pd(pd)) { union { struct mlx4_ib_create_qp qp; struct mlx4_ib_create_wq wq; @@ -991,7 +991,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, qp->flags |= MLX4_IB_QP_SCATTER_FCS; } - err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, + err = set_rq_size(dev, &init_attr->cap, rdma_is_user_pd(pd), qp_has_rq(init_attr), qp, qp->inl_recv_sz); if (err) goto err; @@ -1043,7 +1043,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, } qp->mqp.usage = MLX4_RES_USAGE_USER_VERBS; } else { - err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, + err = set_rq_size(dev, &init_attr->cap, rdma_is_user_pd(pd), qp_has_rq(init_attr), qp, 0); if (err) goto err; @@ -1207,7 +1207,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf); err_db: - if (!pd->uobject && qp_has_rq(init_attr)) + if (rdma_is_user_pd(pd) && qp_has_rq(init_attr)) mlx4_db_free(dev->dev, &qp->db); err: @@ -1612,7 +1612,8 @@ static int _mlx4_ib_destroy_qp(struct ib_qp *qp) struct mlx4_ib_pd *pd; pd = get_pd(mqp); - destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, !!pd->ibpd.uobject); + destroy_qp_common(dev, mqp, MLX4_IB_QP_SRC, + rdma_is_user_pd(&pd->ibpd)); } if (is_sqp(dev, mqp)) diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c index 3731b31..b821a08 100644 --- a/drivers/infiniband/hw/mlx4/srq.c +++ b/drivers/infiniband/hw/mlx4/srq.c @@ -105,7 +105,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, buf_size = srq->msrq.max * desc_size; - if (pd->uobject) { + if (rdma_is_user_pd(pd)) { struct mlx4_ib_create_srq ucmd; if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { @@ -191,7 +191,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, srq->msrq.event = mlx4_ib_srq_event; srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; - if (pd->uobject) + if (rdma_is_user_pd(pd)) if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof (__u32))) { err = -EFAULT; goto err_wrid; @@ -202,7 +202,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, return &srq->ibsrq; err_wrid: - if (pd->uobject) + if (rdma_is_user_pd(pd)) mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db); else kvfree(srq->wrid); @@ -211,13 +211,13 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, mlx4_mtt_cleanup(dev->dev, &srq->mtt); err_buf: - if (pd->uobject) + if (rdma_is_user_pd(pd)) ib_umem_release(srq->umem); else mlx4_buf_free(dev->dev, buf_size, &srq->buf); err_db: - if (!pd->uobject) + if (!rdma_is_user_pd(pd)) mlx4_db_free(dev->dev, &srq->db); err_srq: diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 87e1675..c3ad24d 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -1955,7 +1955,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, } if (pd) { - if (pd->uobject) { + if (rdma_is_user_pd(pd)) { __u32 max_wqes = 1 << MLX5_CAP_GEN(mdev, log_max_qp_sz); mlx5_ib_dbg(dev, "requested sq_wqe_count (%d)\n", ucmd.sq_wqe_count); @@ -2465,7 +2465,7 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, dev = to_mdev(pd->device); if (init_attr->qp_type == IB_QPT_RAW_PACKET) { - if (!pd->uobject) { + if (!rdma_is_user_pd(pd)) { mlx5_ib_dbg(dev, "Raw Packet QP is not supported for kernel consumers\n"); return ERR_PTR(-EINVAL); } else if (!to_mucontext(pd->uobject->context)->cqe_version) { diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c index d012e7d..c5eb189 100644 --- a/drivers/infiniband/hw/mlx5/srq.c +++ b/drivers/infiniband/hw/mlx5/srq.c @@ -287,14 +287,14 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, } in.type = init_attr->srq_type; - if (pd->uobject) + if (rdma_is_user_pd(pd)) err = create_srq_user(pd, srq, &in, udata, buf_size); else err = create_srq_kernel(dev, srq, &in, buf_size); if (err) { mlx5_ib_warn(dev, "create srq %s failed, err %d\n", - pd->uobject ? "user" : "kernel", err); + rdma_is_user_pd(pd) ? "user" : "kernel", err); goto err_srq; } @@ -339,7 +339,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, srq->msrq.event = mlx5_ib_srq_event; srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; - if (pd->uobject) + if (rdma_is_user_pd(pd)) if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) { mlx5_ib_dbg(dev, "copy to user failed\n"); err = -EFAULT; @@ -354,7 +354,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, mlx5_core_destroy_srq(dev->mdev, &srq->msrq); err_usr_kern_srq: - if (pd->uobject) + if (rdma_is_user_pd(pd)) destroy_srq_user(pd, srq); else destroy_srq_kernel(dev, srq); diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 691c6f0..683eaa6 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -455,7 +455,7 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, if (!srq) return ERR_PTR(-ENOMEM); - if (pd->uobject) { + if (rdma_is_user_pd(pd)) { context = to_mucontext(pd->uobject->context); if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { @@ -477,7 +477,7 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, err = mthca_alloc_srq(to_mdev(pd->device), to_mpd(pd), &init_attr->attr, srq); - if (err && pd->uobject) + if (err && rdma_is_user_pd(pd)) mthca_unmap_user_db(to_mdev(pd->device), &context->uar, context->db_tab, ucmd.db_index); @@ -537,7 +537,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, if (!qp) return ERR_PTR(-ENOMEM); - if (pd->uobject) { + if (rdma_is_user_pd(pd)) { context = to_mucontext(pd->uobject->context); if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { @@ -576,7 +576,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, init_attr->qp_type, init_attr->sq_sig_type, &init_attr->cap, qp); - if (err && pd->uobject) { + if (err && rdma_is_user_pd(pd)) { context = to_mucontext(pd->uobject->context); mthca_unmap_user_db(to_mdev(pd->device), @@ -596,7 +596,7 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, case IB_QPT_GSI: { /* Don't allow userspace to create special QPs */ - if (pd->uobject) + if (rdma_is_user_pd(pd)) return ERR_PTR(-EINVAL); qp = kmalloc(sizeof (struct mthca_sqp), GFP_KERNEL); diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 9d178ee..ffa4526 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -951,7 +951,8 @@ static int mthca_max_data_size(struct mthca_dev *dev, struct mthca_qp *qp, int d static inline int mthca_max_inline_data(struct mthca_pd *pd, int max_data_size) { /* We don't support inline data for kernel QPs (yet). */ - return pd->ibpd.uobject ? max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; + return rdma_is_user_pd(&pd->ibpd) ? + max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; } static void mthca_adjust_qp_caps(struct mthca_dev *dev, @@ -1048,7 +1049,7 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, * allocate anything. All we need is to calculate the WQE * sizes and the send_wqe_offset, so we're done now. */ - if (pd->ibpd.uobject) + if (rdma_is_user_pd(&pd->ibpd)) return 0; size = PAGE_ALIGN(qp->send_wqe_offset + @@ -1191,7 +1192,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev, * will be allocated and buffers will be initialized in * userspace. */ - if (pd->ibpd.uobject) + if (rdma_is_user_pd(&pd->ibpd)) return 0; ret = mthca_alloc_memfree(dev, qp); diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c index 9a3fc6f..4e206d4 100644 --- a/drivers/infiniband/hw/mthca/mthca_srq.c +++ b/drivers/infiniband/hw/mthca/mthca_srq.c @@ -152,7 +152,7 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd, int err; int i; - if (pd->ibpd.uobject) + if (rdma_is_user_pd(&pd->ibpd)) return 0; srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL); @@ -235,7 +235,7 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, if (err) goto err_out; - if (!pd->ibpd.uobject) { + if (!rdma_is_user_pd(&pd->ibpd)) { srq->db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SRQ, srq->srqn, &srq->db); if (srq->db_index < 0) { @@ -297,14 +297,14 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err); err_out_free_buf: - if (!pd->ibpd.uobject) + if (!rdma_is_user_pd(&pd->ibpd)) mthca_free_srq_buf(dev, srq); err_out_mailbox: mthca_free_mailbox(dev, mailbox); err_out_db: - if (!pd->ibpd.uobject && mthca_is_memfree(dev)) + if (!rdma_is_user_pd(&pd->ibpd) && mthca_is_memfree(dev)) mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index); err_out_icm: diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index 92d1cad..fc0100c 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c @@ -733,7 +733,7 @@ static int nes_dealloc_pd(struct ib_pd *ibpd) struct nes_device *nesdev = nesvnic->nesdev; struct nes_adapter *nesadapter = nesdev->nesadapter; - if ((ibpd->uobject) && (ibpd->uobject->context)) { + if (rdma_is_user_pd(ibpd) && (ibpd->uobject->context)) { nesucontext = to_nesucontext(ibpd->uobject->context); nes_debug(NES_DBG_PD, "Clearing bit %u from allocated doorbells\n", nespd->mmap_db_index); @@ -1066,7 +1066,8 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, } if (req.user_qp_buffer) nesqp->nesuqp_addr = req.user_qp_buffer; - if ((ibpd->uobject) && (ibpd->uobject->context)) { + if (rdma_is_user_pd(ibpd) && + (ibpd->uobject->context)) { nesqp->user_mode = 1; nes_ucontext = to_nesucontext(ibpd->uobject->context); if (virt_wqs) { @@ -1257,7 +1258,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, nes_put_cqp_request(nesdev, cqp_request); - if (ibpd->uobject) { + if (rdma_is_user_pd(ibpd)) { uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index; uresp.mmap_rq_db_index = 0; uresp.actual_sq_size = sq_size; diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 06d2a7f..d70ebd1 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -1217,7 +1217,7 @@ static int ocrdma_check_qp_params(struct ib_pd *ibpd, struct ocrdma_dev *dev, return -EINVAL; } /* unprivileged user space cannot create special QP */ - if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { + if (rdma_is_user_pd(ibpd) && attrs->qp_type == IB_QPT_GSI) { pr_err ("%s(%d) Userspace can't create special QPs of type=0x%x\n", __func__, dev->id, attrs->qp_type); diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c index 82ee4b4..cf4785a 100644 --- a/drivers/infiniband/hw/qedr/verbs.c +++ b/drivers/infiniband/hw/qedr/verbs.c @@ -1189,7 +1189,7 @@ static int qedr_check_qp_attrs(struct ib_pd *ibpd, struct qedr_dev *dev, } /* Unprivileged user space cannot create special QP */ - if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { + if (rdma_is_user_pd(ibpd) && attrs->qp_type == IB_QPT_GSI) { DP_ERR(dev, "create qp: userspace can't create special QPs of type=0x%x\n", attrs->qp_type); @@ -1552,7 +1552,7 @@ int qedr_destroy_srq(struct ib_srq *ibsrq) in_params.srq_id = srq->srq_id; dev->ops->rdma_destroy_srq(dev->rdma_ctx, &in_params); - if (ibsrq->pd->uobject) + if (rdma_is_user_pd(ibsrq->pd)) qedr_free_srq_user_params(srq); else qedr_free_srq_kernel_params(srq); diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c index cf22f57..1a013e2d 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c @@ -249,7 +249,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, init_completion(&qp->free); qp->state = IB_QPS_RESET; - qp->is_kernel = !(pd->uobject && udata); + qp->is_kernel = !(rdma_is_user_pd(pd) && udata); if (!qp->is_kernel) { dev_dbg(&dev->pdev->dev, diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c index dc0ce87..0b290f6 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c @@ -111,7 +111,7 @@ struct ib_srq *pvrdma_create_srq(struct ib_pd *pd, unsigned long flags; int ret; - if (!(pd->uobject && udata)) { + if (!(rdma_is_user_pd(pd) && udata)) { /* No support for kernel clients. */ dev_warn(&dev->pdev->dev, "no shared receive queue support for kernel client\n"); diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index b971090..0bceded 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -342,7 +342,8 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, struct rxe_cq *rcq = to_rcq(init->recv_cq); struct rxe_cq *scq = to_rcq(init->send_cq); struct rxe_srq *srq = init->srq ? to_rsrq(init->srq) : NULL; - struct ib_ucontext *context = ibpd->uobject ? ibpd->uobject->context : NULL; + struct ib_ucontext *context = rdma_is_user_pd(ibpd) ? + ibpd->uobject->context : NULL; rxe_add_ref(pd); rxe_add_ref(rcq);
Now we have the ability to tell from ib_pd if ib_pd was created by user/kernel verbs. Stop using the ib_pd->uobject pointer for this. This patch prepare the ib_pb uobject pointer removal that will happen in another patch. Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com> --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++-- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 2 +- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- drivers/infiniband/hw/hns/hns_roce_qp.c | 17 +++++++++-------- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 2 +- drivers/infiniband/hw/mlx4/qp.c | 11 ++++++----- drivers/infiniband/hw/mlx4/srq.c | 10 +++++----- drivers/infiniband/hw/mlx5/qp.c | 4 ++-- drivers/infiniband/hw/mlx5/srq.c | 8 ++++---- drivers/infiniband/hw/mthca/mthca_provider.c | 10 +++++----- drivers/infiniband/hw/mthca/mthca_qp.c | 7 ++++--- drivers/infiniband/hw/mthca/mthca_srq.c | 8 ++++---- drivers/infiniband/hw/nes/nes_verbs.c | 7 ++++--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- drivers/infiniband/hw/qedr/verbs.c | 4 ++-- drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 2 +- drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c | 2 +- drivers/infiniband/sw/rxe/rxe_qp.c | 3 ++- 18 files changed, 56 insertions(+), 50 deletions(-)