int siw_dealloc_ucontext(struct ib_ucontext *ofa_ctx) { struct siw_ucontext *ctx = siw_ctx_ofa2siw(ofa_ctx); atomic_dec(&ctx->sdev->num_ctx); kfree(ctx); return 0; }
int siw_dealloc_ucontext(struct ib_ucontext *ofa_ctx) { struct siw_ucontext *ctx = siw_ctx_ofa2siw(ofa_ctx); struct siw_event_file *file = ctx->event_file; if (file) { spin_lock_irq(&file->lock); file->ctx = NULL; spin_unlock_irq(&file->lock); } atomic_dec(&ctx->sdev->num_ctx); kfree(ctx); return 0; }
/* * siw_create_cq() * * Create CQ of requested size on given device. * * @ofa_dev: OFA device contained in siw device * @size: maximum number of CQE's allowed. * @ib_context: user context. * @udata: used to provide CQ ID back to user. */ static struct ib_cq *do_siw_create_cq(struct ib_device *ofa_dev, const struct ib_cq_init_attr *init_attr, struct ib_ucontext *ib_context, struct ib_udata *udata) { struct siw_ucontext *ctx; struct siw_cq *cq = NULL; struct siw_dev *sdev = siw_dev_ofa2siw(ofa_dev); struct urdma_uresp_create_cq uresp; int rv; if (!ofa_dev) { pr_warn("NO OFA device\n"); rv = -ENODEV; goto err_out; } if (atomic_inc_return(&sdev->num_cq) > SIW_MAX_CQ) { pr_debug(": Out of CQ's\n"); rv = -ENOMEM; goto err_out; } if (init_attr->cqe < 1) { pr_debug(": CQE: %d\n", init_attr->cqe); rv = -EINVAL; goto err_out; } cq = kzalloc(sizeof *cq, GFP_KERNEL); if (!cq) { pr_debug(": kmalloc\n"); rv = -ENOMEM; goto err_out; } cq->ofa_cq.cqe = init_attr->cqe; if (!ib_context) { rv = -EINVAL; goto err_out; } ctx = siw_ctx_ofa2siw(ib_context); rv = siw_cq_add(sdev, cq); if (rv) goto err_out; uresp.cq_id = OBJ_ID(cq); rv = ib_copy_to_udata(udata, &uresp, sizeof uresp); if (rv) goto err_out_idr; return &cq->ofa_cq; err_out_idr: siw_remove_obj(&sdev->idr_lock, &sdev->cq_idr, &cq->hdr); err_out: pr_debug(DBG_OBJ ": CQ creation failed %d", rv); kfree(cq); atomic_dec(&sdev->num_cq); return ERR_PTR(rv); }