Commit 02d89b87 authored by Roland Dreier's avatar Roland Dreier

IB/mlx4: Don't allocate RQ doorbell if using SRQ

If a QP is attached to a shared receive queue (SRQ), then it doesn't
have a receive queue (RQ).  So don't allocate an RQ doorbell (or map a
doorbell from userspace for userspace QPs) for that QP.
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 8aee74c8
...@@ -319,20 +319,24 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, ...@@ -319,20 +319,24 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
if (err) if (err)
goto err_mtt; goto err_mtt;
err = mlx4_ib_db_map_user(to_mucontext(pd->uobject->context), if (!init_attr->srq) {
ucmd.db_addr, &qp->db); err = mlx4_ib_db_map_user(to_mucontext(pd->uobject->context),
if (err) ucmd.db_addr, &qp->db);
goto err_mtt; if (err)
goto err_mtt;
}
} else { } else {
err = set_kernel_sq_size(dev, &init_attr->cap, init_attr->qp_type, qp); err = set_kernel_sq_size(dev, &init_attr->cap, init_attr->qp_type, qp);
if (err) if (err)
goto err; goto err;
err = mlx4_ib_db_alloc(dev, &qp->db, 0); if (!init_attr->srq) {
if (err) err = mlx4_ib_db_alloc(dev, &qp->db, 0);
goto err; if (err)
goto err;
*qp->db.db = 0; *qp->db.db = 0;
}
if (mlx4_buf_alloc(dev->dev, qp->buf_size, PAGE_SIZE * 2, &qp->buf)) { if (mlx4_buf_alloc(dev->dev, qp->buf_size, PAGE_SIZE * 2, &qp->buf)) {
err = -ENOMEM; err = -ENOMEM;
...@@ -386,7 +390,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, ...@@ -386,7 +390,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
return 0; return 0;
err_wrid: err_wrid:
if (pd->uobject) if (pd->uobject && !init_attr->srq)
mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &qp->db); mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &qp->db);
else { else {
kfree(qp->sq.wrid); kfree(qp->sq.wrid);
...@@ -403,7 +407,7 @@ err_buf: ...@@ -403,7 +407,7 @@ err_buf:
mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf); mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf);
err_db: err_db:
if (!pd->uobject) if (!pd->uobject && !init_attr->srq)
mlx4_ib_db_free(dev, &qp->db); mlx4_ib_db_free(dev, &qp->db);
err: err:
...@@ -481,14 +485,16 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp, ...@@ -481,14 +485,16 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
mlx4_mtt_cleanup(dev->dev, &qp->mtt); mlx4_mtt_cleanup(dev->dev, &qp->mtt);
if (is_user) { if (is_user) {
mlx4_ib_db_unmap_user(to_mucontext(qp->ibqp.uobject->context), if (!qp->ibqp.srq)
&qp->db); mlx4_ib_db_unmap_user(to_mucontext(qp->ibqp.uobject->context),
&qp->db);
ib_umem_release(qp->umem); ib_umem_release(qp->umem);
} else { } else {
kfree(qp->sq.wrid); kfree(qp->sq.wrid);
kfree(qp->rq.wrid); kfree(qp->rq.wrid);
mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf); mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf);
mlx4_ib_db_free(dev, &qp->db); if (!qp->ibqp.srq)
mlx4_ib_db_free(dev, &qp->db);
} }
} }
...@@ -852,7 +858,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp, ...@@ -852,7 +858,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
if (ibqp->srq) if (ibqp->srq)
context->srqn = cpu_to_be32(1 << 24 | to_msrq(ibqp->srq)->msrq.srqn); context->srqn = cpu_to_be32(1 << 24 | to_msrq(ibqp->srq)->msrq.srqn);
if (cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) if (!ibqp->srq && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT)
context->db_rec_addr = cpu_to_be64(qp->db.dma); context->db_rec_addr = cpu_to_be64(qp->db.dma);
if (cur_state == IB_QPS_INIT && if (cur_state == IB_QPS_INIT &&
...@@ -919,7 +925,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp, ...@@ -919,7 +925,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
qp->rq.tail = 0; qp->rq.tail = 0;
qp->sq.head = 0; qp->sq.head = 0;
qp->sq.tail = 0; qp->sq.tail = 0;
*qp->db.db = 0; if (!ibqp->srq)
*qp->db.db = 0;
} }
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment