From b352aa33d478e53fb6fd5c81989e7ca156372758 Mon Sep 17 00:00:00 2001 From: Mukesh Kacker Date: Tue, 22 Sep 2015 01:31:31 -0700 Subject: [PATCH] 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 --- drivers/infiniband/core/uverbs_cmd.c | 3 ++- drivers/infiniband/hw/mlx4/main.c | 9 ++++++++- include/rdma/ib_verbs.h | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 10fa5b846673..12b766512ade 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 76afca050e0a..4feb311d4eae 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 f4264cce2077..302d5e9b6726 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, -- 2.50.1