Skip to content

Commit 590b3cc

Browse files
Leon Romanovskygregkh
authored andcommitted
RDMA/core: Delete function indirection for alloc/free kernel CQ
[ Upstream commit 7e3c66c ] The ib_alloc_cq*() and ib_free_cq*() are solely kernel verbs to manage CQs and doesn't need extra indirection just to call same functions with constant parameter NULL as udata. Link: https://lore.kernel.org/r/20200907120921.476363-6-leon@kernel.org Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent be4c05d commit 590b3cc

2 files changed

Lines changed: 18 additions & 71 deletions

File tree

drivers/infiniband/core/cq.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,24 +197,22 @@ static void ib_cq_completion_workqueue(struct ib_cq *cq, void *private)
197197
}
198198

199199
/**
200-
* __ib_alloc_cq_user - allocate a completion queue
200+
* __ib_alloc_cq allocate a completion queue
201201
* @dev: device to allocate the CQ for
202202
* @private: driver private data, accessible from cq->cq_context
203203
* @nr_cqe: number of CQEs to allocate
204204
* @comp_vector: HCA completion vectors for this CQ
205205
* @poll_ctx: context to poll the CQ from.
206206
* @caller: module owner name.
207-
* @udata: Valid user data or NULL for kernel object
208207
*
209208
* This is the proper interface to allocate a CQ for in-kernel users. A
210209
* CQ allocated with this interface will automatically be polled from the
211210
* specified context. The ULP must use wr->wr_cqe instead of wr->wr_id
212211
* to use this CQ abstraction.
213212
*/
214-
struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private,
215-
int nr_cqe, int comp_vector,
216-
enum ib_poll_context poll_ctx,
217-
const char *caller, struct ib_udata *udata)
213+
struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private, int nr_cqe,
214+
int comp_vector, enum ib_poll_context poll_ctx,
215+
const char *caller)
218216
{
219217
struct ib_cq_init_attr cq_attr = {
220218
.cqe = nr_cqe,
@@ -277,15 +275,15 @@ struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private,
277275
out_destroy_cq:
278276
rdma_dim_destroy(cq);
279277
rdma_restrack_del(&cq->res);
280-
cq->device->ops.destroy_cq(cq, udata);
278+
cq->device->ops.destroy_cq(cq, NULL);
281279
out_free_wc:
282280
kfree(cq->wc);
283281
out_free_cq:
284282
kfree(cq);
285283
trace_cq_alloc_error(nr_cqe, comp_vector, poll_ctx, ret);
286284
return ERR_PTR(ret);
287285
}
288-
EXPORT_SYMBOL(__ib_alloc_cq_user);
286+
EXPORT_SYMBOL(__ib_alloc_cq);
289287

290288
/**
291289
* __ib_alloc_cq_any - allocate a completion queue
@@ -310,17 +308,16 @@ struct ib_cq *__ib_alloc_cq_any(struct ib_device *dev, void *private,
310308
atomic_inc_return(&counter) %
311309
min_t(int, dev->num_comp_vectors, num_online_cpus());
312310

313-
return __ib_alloc_cq_user(dev, private, nr_cqe, comp_vector, poll_ctx,
314-
caller, NULL);
311+
return __ib_alloc_cq(dev, private, nr_cqe, comp_vector, poll_ctx,
312+
caller);
315313
}
316314
EXPORT_SYMBOL(__ib_alloc_cq_any);
317315

318316
/**
319-
* ib_free_cq_user - free a completion queue
317+
* ib_free_cq - free a completion queue
320318
* @cq: completion queue to free.
321-
* @udata: User data or NULL for kernel object
322319
*/
323-
void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata)
320+
void ib_free_cq(struct ib_cq *cq)
324321
{
325322
if (WARN_ON_ONCE(atomic_read(&cq->usecnt)))
326323
return;
@@ -344,11 +341,11 @@ void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata)
344341
rdma_dim_destroy(cq);
345342
trace_cq_free(cq);
346343
rdma_restrack_del(&cq->res);
347-
cq->device->ops.destroy_cq(cq, udata);
344+
cq->device->ops.destroy_cq(cq, NULL);
348345
kfree(cq->wc);
349346
kfree(cq);
350347
}
351-
EXPORT_SYMBOL(ib_free_cq_user);
348+
EXPORT_SYMBOL(ib_free_cq);
352349

353350
void ib_cq_pool_init(struct ib_device *dev)
354351
{

include/rdma/ib_verbs.h

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,46 +3817,15 @@ static inline int ib_post_recv(struct ib_qp *qp,
38173817
return qp->device->ops.post_recv(qp, recv_wr, bad_recv_wr ? : &dummy);
38183818
}
38193819

3820-
struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private,
3821-
int nr_cqe, int comp_vector,
3822-
enum ib_poll_context poll_ctx,
3823-
const char *caller, struct ib_udata *udata);
3824-
3825-
/**
3826-
* ib_alloc_cq_user: Allocate kernel/user CQ
3827-
* @dev: The IB device
3828-
* @private: Private data attached to the CQE
3829-
* @nr_cqe: Number of CQEs in the CQ
3830-
* @comp_vector: Completion vector used for the IRQs
3831-
* @poll_ctx: Context used for polling the CQ
3832-
* @udata: Valid user data or NULL for kernel objects
3833-
*/
3834-
static inline struct ib_cq *ib_alloc_cq_user(struct ib_device *dev,
3835-
void *private, int nr_cqe,
3836-
int comp_vector,
3837-
enum ib_poll_context poll_ctx,
3838-
struct ib_udata *udata)
3839-
{
3840-
return __ib_alloc_cq_user(dev, private, nr_cqe, comp_vector, poll_ctx,
3841-
KBUILD_MODNAME, udata);
3842-
}
3843-
3844-
/**
3845-
* ib_alloc_cq: Allocate kernel CQ
3846-
* @dev: The IB device
3847-
* @private: Private data attached to the CQE
3848-
* @nr_cqe: Number of CQEs in the CQ
3849-
* @comp_vector: Completion vector used for the IRQs
3850-
* @poll_ctx: Context used for polling the CQ
3851-
*
3852-
* NOTE: for user cq use ib_alloc_cq_user with valid udata!
3853-
*/
3820+
struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private, int nr_cqe,
3821+
int comp_vector, enum ib_poll_context poll_ctx,
3822+
const char *caller);
38543823
static inline struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private,
38553824
int nr_cqe, int comp_vector,
38563825
enum ib_poll_context poll_ctx)
38573826
{
3858-
return ib_alloc_cq_user(dev, private, nr_cqe, comp_vector, poll_ctx,
3859-
NULL);
3827+
return __ib_alloc_cq(dev, private, nr_cqe, comp_vector, poll_ctx,
3828+
KBUILD_MODNAME);
38603829
}
38613830

38623831
struct ib_cq *__ib_alloc_cq_any(struct ib_device *dev, void *private,
@@ -3878,26 +3847,7 @@ static inline struct ib_cq *ib_alloc_cq_any(struct ib_device *dev,
38783847
KBUILD_MODNAME);
38793848
}
38803849

3881-
/**
3882-
* ib_free_cq_user - Free kernel/user CQ
3883-
* @cq: The CQ to free
3884-
* @udata: Valid user data or NULL for kernel objects
3885-
*
3886-
* NOTE: This function shouldn't be called on shared CQs.
3887-
*/
3888-
void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata);
3889-
3890-
/**
3891-
* ib_free_cq - Free kernel CQ
3892-
* @cq: The CQ to free
3893-
*
3894-
* NOTE: for user cq use ib_free_cq_user with valid udata!
3895-
*/
3896-
static inline void ib_free_cq(struct ib_cq *cq)
3897-
{
3898-
ib_free_cq_user(cq, NULL);
3899-
}
3900-
3850+
void ib_free_cq(struct ib_cq *cq);
39013851
int ib_process_cq_direct(struct ib_cq *cq, int budget);
39023852

39033853
/**

0 commit comments

Comments
 (0)