Skip to content

Commit

Permalink
libhns: Assign doorbell to zero when allocate it
Browse files Browse the repository at this point in the history
Clear the doorbell when getting it to avoid clearing it in each
function that uses hns_roce_alloc_db()

Signed-off-by: Chengchang Tang <[email protected]>
Signed-off-by: Junxian Huang <[email protected]>
  • Loading branch information
Chengchang Tang authored and Junxian Huang committed Apr 18, 2024
1 parent c71bb6d commit 2af6b0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 2 additions & 0 deletions providers/hns/hns_roce_u_db.c
Expand Up @@ -116,6 +116,8 @@ void *hns_roce_alloc_db(struct hns_roce_context *ctx,

out:
pthread_mutex_unlock((pthread_mutex_t *)&ctx->db_list_mutex);
if (db)
*((unsigned int *)db) = 0;

return db;
}
Expand Down
8 changes: 0 additions & 8 deletions providers/hns/hns_roce_u_verbs.c
Expand Up @@ -371,8 +371,6 @@ static struct ibv_cq_ex *create_cq(struct ibv_context *context,
goto err_db;
}

*cq->db = 0;

ret = exec_cq_create_cmd(context, cq, attr);
if (ret)
goto err_cmd;
Expand Down Expand Up @@ -685,8 +683,6 @@ static struct ibv_srq *create_srq(struct ibv_context *context,
if (!srq->rdb)
goto err_srq_buf;

*srq->rdb = 0;

ret = exec_srq_create_cmd(context, srq, init_attr);
if (ret)
goto err_srq_db;
Expand Down Expand Up @@ -1175,8 +1171,6 @@ static int qp_alloc_db(struct ibv_qp_init_attr_ex *attr, struct hns_roce_qp *qp,
qp->sdb = hns_roce_alloc_db(ctx, HNS_ROCE_QP_TYPE_DB);
if (!qp->sdb)
return -ENOMEM;

*qp->sdb = 0;
}

if (attr->cap.max_recv_sge) {
Expand All @@ -1188,8 +1182,6 @@ static int qp_alloc_db(struct ibv_qp_init_attr_ex *attr, struct hns_roce_qp *qp,

return -ENOMEM;
}

*qp->rdb = 0;
}

return 0;
Expand Down

0 comments on commit 2af6b0f

Please sign in to comment.