From: Mukesh Kacker Date: Tue, 22 Sep 2015 08:31:31 +0000 (-0700) Subject: ib_core: Add udata argument to alloc_shpd() X-Git-Tag: v4.1.12-92~215^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b352aa33d478e53fb6fd5c81989e7ca156372758;p=users%2Fjedix%2Flinux-maple.git ib_core: Add udata argument to alloc_shpd() ib_core: Add udata argument to alloc_shpd() Add udata argument to shared pd interface alloc_shpd() consistent with evolution of other similar ib_core interfaces so providers that wish to support it can use it. For providers (like current Mellanox driver code) that do not expect user user data, we assert a warning. Orabug: 21884873 Signed-off-by: Mukesh Kacker Reviewed-by: Yuval Shaia --- diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 10fa5b8466734..12b766512ade3 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -768,7 +768,8 @@ ssize_t ib_uverbs_alloc_shpd(struct ib_uverbs_file *file, down_write(&shuobj->mutex); /* alloc shared pd from device driver */ - shpd = file->device->ib_dev->alloc_shpd(file->device->ib_dev, pd); + shpd = file->device->ib_dev->alloc_shpd(file->device->ib_dev, pd, + &udata); if (IS_ERR(shpd)) { ret = PTR_ERR(shpd); goto err_shobj; diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 76afca050e0ac..4feb311d4eaef 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -766,10 +766,17 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev, } static struct ib_shpd *mlx4_ib_alloc_shpd(struct ib_device *ibdev, - struct ib_pd *pd) + struct ib_pd *pd, + struct ib_udata *udata) { struct mlx4_ib_shpd *shpd; + /* + * Warn if we get udata which is not expected from the + * mellanox provider. + */ + WARN_ON(udata && udata->inlen > 0); + shpd = kzalloc(sizeof(*shpd), GFP_KERNEL); if (!shpd) return ERR_PTR(-ENOMEM); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index f4264cce20779..302d5e9b67268 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1669,7 +1669,12 @@ struct ib_device { int (*check_mr_status)(struct ib_mr *mr, u32 check_mask, struct ib_mr_status *mr_status); struct ib_shpd *(*alloc_shpd)(struct ib_device *ibdev, - struct ib_pd *pd); + struct ib_pd *pd +#ifndef __GENKSYMS__ + , + struct ib_udata *udata +#endif + ); struct ib_pd *(*share_pd)(struct ib_device *ibdev, struct ib_ucontext *context, struct ib_udata *udata,