From f113e75412fb77295ed5806215fb7b1f6a873d89 Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 31 Jan 2007 10:39:51 -0800 Subject: [PATCH] Revert "The ibv_cmd_* create functions need to set context" This reverts commit 5eaee85aec025be16e5aeeaac64abc6d8d9c191c. This breaks ibv_destroy_ah() with libmthca, and isn't really appropriate for the stable branch. Signed-off-by: Roland Dreier --- src/cmd.c | 21 +++++++-------------- src/verbs.c | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index 77a137a..2f17765 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -208,8 +208,7 @@ int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd, VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - pd->handle = resp->pd_handle; - pd->context = context; + pd->handle = resp->pd_handle; return 0; } @@ -250,7 +249,6 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length, mr->handle = resp.mr_handle; mr->lkey = resp.lkey; mr->rkey = resp.rkey; - mr->context = pd->context; return 0; } @@ -290,9 +288,8 @@ static int ibv_cmd_create_cq_v2(struct ibv_context *context, int cqe, VALGRIND_MAKE_MEM_DEFINED(resp, sizeof resp_size); - cq->handle = resp->cq_handle; - cq->cqe = resp->cqe; - cq->context = context; + cq->handle = resp->cq_handle; + cq->cqe = resp->cqe; return 0; } @@ -319,9 +316,8 @@ int ibv_cmd_create_cq(struct ibv_context *context, int cqe, VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - cq->handle = resp->cq_handle; - cq->cqe = resp->cqe; - cq->context = context; + cq->handle = resp->cq_handle; + cq->cqe = resp->cqe; return 0; } @@ -461,8 +457,7 @@ int ibv_cmd_create_srq(struct ibv_pd *pd, VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - srq->handle = resp->srq_handle; - srq->context = pd->context; + srq->handle = resp->srq_handle; if (abi_ver > 5) { attr->attr.max_wr = resp->max_wr; @@ -611,7 +606,6 @@ int ibv_cmd_create_qp(struct ibv_pd *pd, qp->handle = resp->qp_handle; qp->qp_num = resp->qpn; - qp->context = pd->context; if (abi_ver > 3) { attr->cap.max_recv_sge = resp->max_recv_sge; @@ -1030,8 +1024,7 @@ int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah, VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); - ah->handle = resp.handle; - ah->context = pd->context; + ah->handle = resp.handle; return 0; } diff --git a/src/verbs.c b/src/verbs.c index 964ca0f..706b2b0 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -133,7 +133,13 @@ int ibv_query_pkey(struct ibv_context *context, uint8_t port_num, struct ibv_pd *ibv_alloc_pd(struct ibv_context *context) { - return context->ops.alloc_pd(context); + struct ibv_pd *pd; + + pd = context->ops.alloc_pd(context); + if (pd) + pd->context = context; + + return pd; } int ibv_dealloc_pd(struct ibv_pd *pd) @@ -148,6 +154,7 @@ struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr, mr = pd->context->ops.reg_mr(pd, addr, length, access); if (mr) { + mr->context = pd->context; mr->pd = pd; } @@ -226,6 +233,7 @@ struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe, void *cq_cont comp_vector); if (cq) { + cq->context = context; cq->cq_context = cq_context; cq->comp_events_completed = 0; cq->async_events_completed = 0; @@ -285,6 +293,7 @@ struct ibv_srq *ibv_create_srq(struct ibv_pd *pd, srq = pd->context->ops.create_srq(pd, srq_init_attr); if (srq) { + srq->context = pd->context; srq->srq_context = srq_init_attr->srq_context; srq->pd = pd; srq->events_completed = 0; @@ -318,6 +327,7 @@ struct ibv_qp *ibv_create_qp(struct ibv_pd *pd, struct ibv_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr); if (qp) { + qp->context = pd->context; qp->qp_context = qp_init_attr->qp_context; qp->pd = pd; qp->send_cq = qp_init_attr->send_cq; @@ -372,8 +382,10 @@ struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) { struct ibv_ah *ah = pd->context->ops.create_ah(pd, attr); - if (ah) + if (ah) { + ah->context = pd->context; ah->pd = pd; + } return ah; } -- 2.46.0