Skip to content

Commit ff23dfa

Browse files
srabinovjgunthorpe
authored andcommitted
IB: Pass only ib_udata in function prototypes
Now when ib_udata is passed to all the driver's object create/destroy APIs the ib_udata will carry the ib_ucontext for every user command. There is no need to also pass the ib_ucontext via the functions prototypes. Make ib_udata the only argument psssed. Signed-off-by: Shamir Rabinovitch <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent bdeacab commit ff23dfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+271
-328
lines changed

drivers/infiniband/core/cq.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private,
147147
struct ib_cq *cq;
148148
int ret = -ENOMEM;
149149

150-
cq = dev->ops.create_cq(dev, &cq_attr, NULL, NULL);
150+
cq = dev->ops.create_cq(dev, &cq_attr, NULL);
151151
if (IS_ERR(cq))
152152
return cq;
153153

drivers/infiniband/core/uverbs_cmd.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs)
423423
atomic_set(&pd->usecnt, 0);
424424
pd->res.type = RDMA_RESTRACK_PD;
425425

426-
ret = ib_dev->ops.alloc_pd(pd, uobj->context, &attrs->driver_udata);
426+
ret = ib_dev->ops.alloc_pd(pd, &attrs->driver_udata);
427427
if (ret)
428428
goto err_alloc;
429429

@@ -594,8 +594,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs)
594594
}
595595

596596
if (!xrcd) {
597-
xrcd = ib_dev->ops.alloc_xrcd(ib_dev, obj->uobject.context,
598-
&attrs->driver_udata);
597+
xrcd = ib_dev->ops.alloc_xrcd(ib_dev, &attrs->driver_udata);
599598
if (IS_ERR(xrcd)) {
600599
ret = PTR_ERR(xrcd);
601600
goto err;
@@ -1009,8 +1008,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
10091008
attr.comp_vector = cmd->comp_vector;
10101009
attr.flags = cmd->flags;
10111010

1012-
cq = ib_dev->ops.create_cq(ib_dev, &attr, obj->uobject.context,
1013-
&attrs->driver_udata);
1011+
cq = ib_dev->ops.create_cq(ib_dev, &attr, &attrs->driver_udata);
10141012
if (IS_ERR(cq)) {
10151013
ret = PTR_ERR(cq);
10161014
goto err_file;

drivers/infiniband/core/uverbs_std_types_cq.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
111111
INIT_LIST_HEAD(&obj->comp_list);
112112
INIT_LIST_HEAD(&obj->async_list);
113113

114-
cq = ib_dev->ops.create_cq(ib_dev, &attr, obj->uobject.context,
115-
&attrs->driver_udata);
114+
cq = ib_dev->ops.create_cq(ib_dev, &attr, &attrs->driver_udata);
116115
if (IS_ERR(cq)) {
117116
ret = PTR_ERR(cq);
118117
goto err_event_file;

drivers/infiniband/core/verbs.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags,
269269
pd->res.type = RDMA_RESTRACK_PD;
270270
rdma_restrack_set_task(&pd->res, caller);
271271

272-
ret = device->ops.alloc_pd(pd, NULL, NULL);
272+
ret = device->ops.alloc_pd(pd, NULL);
273273
if (ret) {
274274
kfree(pd);
275275
return ERR_PTR(ret);
@@ -1911,7 +1911,7 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
19111911
{
19121912
struct ib_cq *cq;
19131913

1914-
cq = device->ops.create_cq(device, cq_attr, NULL, NULL);
1914+
cq = device->ops.create_cq(device, cq_attr, NULL);
19151915

19161916
if (!IS_ERR(cq)) {
19171917
cq->device = device;
@@ -2142,7 +2142,7 @@ struct ib_xrcd *__ib_alloc_xrcd(struct ib_device *device, const char *caller)
21422142
if (!device->ops.alloc_xrcd)
21432143
return ERR_PTR(-EOPNOTSUPP);
21442144

2145-
xrcd = device->ops.alloc_xrcd(device, NULL, NULL);
2145+
xrcd = device->ops.alloc_xrcd(device, NULL);
21462146
if (!IS_ERR(xrcd)) {
21472147
xrcd->device = device;
21482148
xrcd->inode = NULL;

drivers/infiniband/hw/bnxt_re/ib_verbs.c

+8-13
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,12 @@ void bnxt_re_dealloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata)
576576
&pd->qplib_pd);
577577
}
578578

579-
int bnxt_re_alloc_pd(struct ib_pd *ibpd, struct ib_ucontext *ucontext,
580-
struct ib_udata *udata)
579+
int bnxt_re_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
581580
{
582581
struct ib_device *ibdev = ibpd->device;
583582
struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
584-
struct bnxt_re_ucontext *ucntx = container_of(ucontext,
585-
struct bnxt_re_ucontext,
586-
ib_uctx);
583+
struct bnxt_re_ucontext *ucntx = rdma_udata_to_drv_context(
584+
udata, struct bnxt_re_ucontext, ib_uctx);
587585
struct bnxt_re_pd *pd = container_of(ibpd, struct bnxt_re_pd, ib_pd);
588586
int rc;
589587

@@ -2589,7 +2587,6 @@ int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
25892587

25902588
struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
25912589
const struct ib_cq_init_attr *attr,
2592-
struct ib_ucontext *context,
25932590
struct ib_udata *udata)
25942591
{
25952592
struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
@@ -2616,12 +2613,10 @@ struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
26162613
if (entries > dev_attr->max_cq_wqes + 1)
26172614
entries = dev_attr->max_cq_wqes + 1;
26182615

2619-
if (context) {
2616+
if (udata) {
26202617
struct bnxt_re_cq_req req;
2621-
struct bnxt_re_ucontext *uctx = container_of
2622-
(context,
2623-
struct bnxt_re_ucontext,
2624-
ib_uctx);
2618+
struct bnxt_re_ucontext *uctx = rdma_udata_to_drv_context(
2619+
udata, struct bnxt_re_ucontext, ib_uctx);
26252620
if (ib_copy_from_udata(&req, udata, sizeof(req))) {
26262621
rc = -EFAULT;
26272622
goto fail;
@@ -2672,7 +2667,7 @@ struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
26722667
atomic_inc(&rdev->cq_count);
26732668
spin_lock_init(&cq->cq_lock);
26742669

2675-
if (context) {
2670+
if (udata) {
26762671
struct bnxt_re_cq_resp resp;
26772672

26782673
resp.cqid = cq->qplib_cq.id;
@@ -2690,7 +2685,7 @@ struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
26902685
return &cq->ib_cq;
26912686

26922687
c2fail:
2693-
if (context)
2688+
if (udata)
26942689
ib_umem_release(cq->umem);
26952690
fail:
26962691
kfree(cq->cql);

drivers/infiniband/hw/bnxt_re/ib_verbs.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ int bnxt_re_query_gid(struct ib_device *ibdev, u8 port_num,
163163
int index, union ib_gid *gid);
164164
enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev,
165165
u8 port_num);
166-
int bnxt_re_alloc_pd(struct ib_pd *pd, struct ib_ucontext *context,
167-
struct ib_udata *udata);
166+
int bnxt_re_alloc_pd(struct ib_pd *pd, struct ib_udata *udata);
168167
void bnxt_re_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
169168
struct ib_ah *bnxt_re_create_ah(struct ib_pd *pd,
170169
struct rdma_ah_attr *ah_attr,
@@ -197,7 +196,6 @@ int bnxt_re_post_recv(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
197196
const struct ib_recv_wr **bad_recv_wr);
198197
struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
199198
const struct ib_cq_init_attr *attr,
200-
struct ib_ucontext *context,
201199
struct ib_udata *udata);
202200
int bnxt_re_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
203201
int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc);

drivers/infiniband/hw/cxgb3/iwch_provider.c

+7-9
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,13 @@ static int iwch_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
106106

107107
static struct ib_cq *iwch_create_cq(struct ib_device *ibdev,
108108
const struct ib_cq_init_attr *attr,
109-
struct ib_ucontext *ib_context,
110109
struct ib_udata *udata)
111110
{
112111
int entries = attr->cqe;
113112
struct iwch_dev *rhp;
114113
struct iwch_cq *chp;
115114
struct iwch_create_cq_resp uresp;
116115
struct iwch_create_cq_req ureq;
117-
struct iwch_ucontext *ucontext = NULL;
118116
static int warned;
119117
size_t resplen;
120118

@@ -127,8 +125,7 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev,
127125
if (!chp)
128126
return ERR_PTR(-ENOMEM);
129127

130-
if (ib_context) {
131-
ucontext = to_iwch_ucontext(ib_context);
128+
if (udata) {
132129
if (!t3a_device(rhp)) {
133130
if (ib_copy_from_udata(&ureq, udata, sizeof (ureq))) {
134131
kfree(chp);
@@ -154,7 +151,7 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev,
154151
entries = roundup_pow_of_two(entries);
155152
chp->cq.size_log2 = ilog2(entries);
156153

157-
if (cxio_create_cq(&rhp->rdev, &chp->cq, !ucontext)) {
154+
if (cxio_create_cq(&rhp->rdev, &chp->cq, !udata)) {
158155
kfree(chp);
159156
return ERR_PTR(-ENOMEM);
160157
}
@@ -170,8 +167,10 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev,
170167
return ERR_PTR(-ENOMEM);
171168
}
172169

173-
if (ucontext) {
170+
if (udata) {
174171
struct iwch_mm_entry *mm;
172+
struct iwch_ucontext *ucontext = rdma_udata_to_drv_context(
173+
udata, struct iwch_ucontext, ibucontext);
175174

176175
mm = kmalloc(sizeof *mm, GFP_KERNEL);
177176
if (!mm) {
@@ -378,8 +377,7 @@ static void iwch_deallocate_pd(struct ib_pd *pd, struct ib_udata *udata)
378377
cxio_hal_put_pdid(rhp->rdev.rscp, php->pdid);
379378
}
380379

381-
static int iwch_allocate_pd(struct ib_pd *pd, struct ib_ucontext *context,
382-
struct ib_udata *udata)
380+
static int iwch_allocate_pd(struct ib_pd *pd, struct ib_udata *udata)
383381
{
384382
struct iwch_pd *php = to_iwch_pd(pd);
385383
struct ib_device *ibdev = pd->device;
@@ -394,7 +392,7 @@ static int iwch_allocate_pd(struct ib_pd *pd, struct ib_ucontext *context,
394392

395393
php->pdid = pdid;
396394
php->rhp = rhp;
397-
if (context) {
395+
if (udata) {
398396
struct iwch_alloc_pd_resp resp = {.pdid = php->pdid};
399397

400398
if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {

drivers/infiniband/hw/cxgb4/cq.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,6 @@ int c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
994994

995995
struct ib_cq *c4iw_create_cq(struct ib_device *ibdev,
996996
const struct ib_cq_init_attr *attr,
997-
struct ib_ucontext *ib_context,
998997
struct ib_udata *udata)
999998
{
1000999
int entries = attr->cqe;
@@ -1003,10 +1002,11 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev,
10031002
struct c4iw_cq *chp;
10041003
struct c4iw_create_cq ucmd;
10051004
struct c4iw_create_cq_resp uresp;
1006-
struct c4iw_ucontext *ucontext = NULL;
10071005
int ret, wr_len;
10081006
size_t memsize, hwentries;
10091007
struct c4iw_mm_entry *mm, *mm2;
1008+
struct c4iw_ucontext *ucontext = rdma_udata_to_drv_context(
1009+
udata, struct c4iw_ucontext, ibucontext);
10101010

10111011
pr_debug("ib_dev %p entries %d\n", ibdev, entries);
10121012
if (attr->flags)
@@ -1017,8 +1017,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev,
10171017
if (vector >= rhp->rdev.lldi.nciq)
10181018
return ERR_PTR(-EINVAL);
10191019

1020-
if (ib_context) {
1021-
ucontext = to_c4iw_ucontext(ib_context);
1020+
if (udata) {
10221021
if (udata->inlen < sizeof(ucmd))
10231022
ucontext->is_32b_cqe = 1;
10241023
}
@@ -1070,7 +1069,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev,
10701069
/*
10711070
* memsize must be a multiple of the page size if its a user cq.
10721071
*/
1073-
if (ucontext)
1072+
if (udata)
10741073
memsize = roundup(memsize, PAGE_SIZE);
10751074

10761075
chp->cq.size = hwentries;

drivers/infiniband/hw/cxgb4/iw_cxgb4.h

-1
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,6 @@ int c4iw_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata);
995995
int c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata);
996996
struct ib_cq *c4iw_create_cq(struct ib_device *ibdev,
997997
const struct ib_cq_init_attr *attr,
998-
struct ib_ucontext *ib_context,
999998
struct ib_udata *udata);
1000999
int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
10011000
int c4iw_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *attr,

drivers/infiniband/hw/cxgb4/provider.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ static void c4iw_deallocate_pd(struct ib_pd *pd, struct ib_udata *udata)
204204
mutex_unlock(&rhp->rdev.stats.lock);
205205
}
206206

207-
static int c4iw_allocate_pd(struct ib_pd *pd, struct ib_ucontext *context,
208-
struct ib_udata *udata)
207+
static int c4iw_allocate_pd(struct ib_pd *pd, struct ib_udata *udata)
209208
{
210209
struct c4iw_pd *php = to_c4iw_pd(pd);
211210
struct ib_device *ibdev = pd->device;
@@ -220,7 +219,7 @@ static int c4iw_allocate_pd(struct ib_pd *pd, struct ib_ucontext *context,
220219

221220
php->pdid = pdid;
222221
php->rhp = rhp;
223-
if (context) {
222+
if (udata) {
224223
struct c4iw_alloc_pd_resp uresp = {.pdid = php->pdid};
225224

226225
if (ib_copy_to_udata(udata, &uresp, sizeof(uresp))) {

drivers/infiniband/hw/hns/hns_roce_cq.c

+11-12
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ static void hns_roce_ib_free_cq_buf(struct hns_roce_dev *hr_dev,
302302

303303
struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
304304
const struct ib_cq_init_attr *attr,
305-
struct ib_ucontext *context,
306305
struct ib_udata *udata)
307306
{
308307
struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);
@@ -314,6 +313,8 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
314313
int vector = attr->comp_vector;
315314
int cq_entries = attr->cqe;
316315
int ret;
316+
struct hns_roce_ucontext *context = rdma_udata_to_drv_context(
317+
udata, struct hns_roce_ucontext, ibucontext);
317318

318319
if (cq_entries < 1 || cq_entries > hr_dev->caps.max_cqes) {
319320
dev_err(dev, "Creat CQ failed. entries=%d, max=%d\n",
@@ -332,7 +333,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
332333
hr_cq->ib_cq.cqe = cq_entries - 1;
333334
spin_lock_init(&hr_cq->lock);
334335

335-
if (context) {
336+
if (udata) {
336337
if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
337338
dev_err(dev, "Failed to copy_from_udata.\n");
338339
ret = -EFAULT;
@@ -350,8 +351,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
350351

351352
if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
352353
(udata->outlen >= sizeof(resp))) {
353-
ret = hns_roce_db_map_user(to_hr_ucontext(context),
354-
udata, ucmd.db_addr,
354+
ret = hns_roce_db_map_user(context, udata, ucmd.db_addr,
355355
&hr_cq->db);
356356
if (ret) {
357357
dev_err(dev, "cq record doorbell map failed!\n");
@@ -362,7 +362,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
362362
}
363363

364364
/* Get user space parameters */
365-
uar = &to_hr_ucontext(context)->uar;
365+
uar = &context->uar;
366366
} else {
367367
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) {
368368
ret = hns_roce_alloc_db(hr_dev, &hr_cq->db, 1);
@@ -401,15 +401,15 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
401401
* problems if tptr is set to zero here, so we initialze it in user
402402
* space.
403403
*/
404-
if (!context && hr_cq->tptr_addr)
404+
if (!udata && hr_cq->tptr_addr)
405405
*hr_cq->tptr_addr = 0;
406406

407407
/* Get created cq handler and carry out event */
408408
hr_cq->comp = hns_roce_ib_cq_comp;
409409
hr_cq->event = hns_roce_ib_cq_event;
410410
hr_cq->cq_depth = cq_entries;
411411

412-
if (context) {
412+
if (udata) {
413413
resp.cqn = hr_cq->cqn;
414414
ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
415415
if (ret)
@@ -422,21 +422,20 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
422422
hns_roce_free_cq(hr_dev, hr_cq);
423423

424424
err_dbmap:
425-
if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
425+
if (udata && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
426426
(udata->outlen >= sizeof(resp)))
427-
hns_roce_db_unmap_user(to_hr_ucontext(context),
428-
&hr_cq->db);
427+
hns_roce_db_unmap_user(context, &hr_cq->db);
429428

430429
err_mtt:
431430
hns_roce_mtt_cleanup(hr_dev, &hr_cq->hr_buf.hr_mtt);
432-
if (context)
431+
if (udata)
433432
ib_umem_release(hr_cq->umem);
434433
else
435434
hns_roce_ib_free_cq_buf(hr_dev, &hr_cq->hr_buf,
436435
hr_cq->ib_cq.cqe);
437436

438437
err_db:
439-
if (!context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB))
438+
if (!udata && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB))
440439
hns_roce_free_db(hr_dev, &hr_cq->db);
441440

442441
err_cq:

drivers/infiniband/hw/hns/hns_roce_device.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,7 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *pd,
11121112
int hns_roce_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr);
11131113
int hns_roce_destroy_ah(struct ib_ah *ah, u32 flags, struct ib_udata *udata);
11141114

1115-
int hns_roce_alloc_pd(struct ib_pd *pd, struct ib_ucontext *context,
1116-
struct ib_udata *udata);
1115+
int hns_roce_alloc_pd(struct ib_pd *pd, struct ib_udata *udata);
11171116
void hns_roce_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
11181117

11191118
struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc);
@@ -1177,7 +1176,6 @@ int to_hr_qp_type(int qp_type);
11771176

11781177
struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
11791178
const struct ib_cq_init_attr *attr,
1180-
struct ib_ucontext *context,
11811179
struct ib_udata *udata);
11821180

11831181
int hns_roce_ib_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata);

0 commit comments

Comments
 (0)