Re: [PATCH for-next v2 3/3] IB/{hw,sw}: remove 'uobject->context' dependency in object creation APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 28, 2019 at 12:13:12PM +0200, Shamir Rabinovitch wrote:
> Now when we have the udata passed to all the ib_xxx object creation APIs
> and the additional macro 'rdma_udata_to_drv_context' to get the ib_ucontext
> from ib_udata stored in uverbs_attr_bundle, we can finally start to remove
> the dependency of the drivers in the ib_xxx->uobject->context.
> 
> Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@xxxxxxxxxx>
>  drivers/infiniband/hw/bnxt_re/ib_verbs.c     | 29 +++----
>  drivers/infiniband/hw/cxgb3/iwch_provider.c  |  3 +-
>  drivers/infiniband/hw/cxgb4/qp.c             | 10 ++-
>  drivers/infiniband/hw/hns/hns_roce_qp.c      | 24 +++---
>  drivers/infiniband/hw/i40iw/i40iw_verbs.c    | 11 ++-
>  drivers/infiniband/hw/mlx4/mr.c              | 11 ++-
>  drivers/infiniband/hw/mlx4/qp.c              | 81 +++++++++++---------
>  drivers/infiniband/hw/mlx4/srq.c             | 18 +++--
>  drivers/infiniband/hw/mlx5/qp.c              | 57 +++++++++-----
>  drivers/infiniband/hw/mlx5/srq.c             | 10 ++-
>  drivers/infiniband/hw/mthca/mthca_provider.c | 35 +++++----
>  drivers/infiniband/hw/mthca/mthca_qp.c       | 14 +++-
>  drivers/infiniband/hw/mthca/mthca_srq.c      | 23 ++++--
>  drivers/infiniband/hw/nes/nes_verbs.c        | 11 ++-
>  drivers/infiniband/hw/qedr/verbs.c           |  7 +-
>  drivers/infiniband/hw/usnic/usnic_ib_verbs.c |  4 +-
>  drivers/infiniband/sw/rdmavt/qp.c            | 14 +++-
>  drivers/infiniband/sw/rdmavt/srq.c           | 14 +++-
>  drivers/infiniband/sw/rxe/rxe_qp.c           |  9 ++-
>  drivers/infiniband/sw/rxe/rxe_verbs.c        |  9 ++-
>  20 files changed, 237 insertions(+), 157 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index 9bc637e49faa..dbce0084d1b2 100644
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -668,6 +668,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd,
>  				u32 flags,
>  				struct ib_udata *udata)
>  {
> +	struct bnxt_re_ucontext *uctx;
>  	struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
>  	struct bnxt_re_dev *rdev = pd->rdev;
>  	struct bnxt_re_ah *ah;
> @@ -675,6 +676,9 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd,
>  	int rc;
>  	u8 nw_type;
>  
> +	uctx = rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext,
> +					 ib_uctx);

These should all just be written as initializers..

struct bnxt_re_ucontext *uctx = rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext,
					 ib_uctx);

And I think you should arrange it so uctx == NULL if there is no
ucontext, never IS_ERR.

> -	if (udata &&
> +	if (uctx &&

So that stuff like this looks sane to the reader.

> diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
> index 03f4c66c2659..f7366c38c2f5 100644
> +++ b/drivers/infiniband/hw/cxgb4/qp.c
> @@ -2170,7 +2170,8 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
>  	if (sqsize < 8)
>  		sqsize = 8;
>  
> -	ucontext = udata ? to_c4iw_ucontext(pd->uobject->context) : NULL;
> +	ucontext = rdma_udata_to_drv_context(udata, struct c4iw_ucontext,
> +					     ibucontext);
>  
>  	qhp = kzalloc(sizeof(*qhp), GFP_KERNEL);
>  	if (!qhp)
> @@ -2240,7 +2241,7 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
>  	if (ret)
>  		goto err_destroy_qp;
>  
> -	if (udata && ucontext) {
> +	if (ucontext) {

This change sure makes a lot of this read nicer..

Also please use git send-email otherwise patchworks doesn't thread
your series properly.

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux