Commit 300c0d7c authored by Ram Amrani's avatar Ram Amrani Committed by David S. Miller

qed: Don't free a QP more than once

If QP is in reset state then there are no resources to free so avoid
freeing any.
Signed-off-by: default avatarRam Amrani <Ram.Amrani@cavium.com>
Signed-off-by: default avatarYuval Mintz <Yuval.Mintz@cavium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5212b94
...@@ -1849,6 +1849,7 @@ static int qed_roce_query_qp(struct qed_hwfn *p_hwfn, ...@@ -1849,6 +1849,7 @@ static int qed_roce_query_qp(struct qed_hwfn *p_hwfn,
static int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp) static int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp)
{ {
struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info;
u32 num_invalidated_mw = 0; u32 num_invalidated_mw = 0;
u32 num_bound_mw = 0; u32 num_bound_mw = 0;
u32 start_cid; u32 start_cid;
...@@ -1863,35 +1864,39 @@ static int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp) ...@@ -1863,35 +1864,39 @@ static int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp)
return -EINVAL; return -EINVAL;
} }
rc = qed_roce_sp_destroy_qp_responder(p_hwfn, qp, &num_invalidated_mw); if (qp->cur_state != QED_ROCE_QP_STATE_RESET) {
if (rc) rc = qed_roce_sp_destroy_qp_responder(p_hwfn, qp,
return rc; &num_invalidated_mw);
if (rc)
return rc;
/* Send destroy requester ramrod */ /* Send destroy requester ramrod */
rc = qed_roce_sp_destroy_qp_requester(p_hwfn, qp, &num_bound_mw); rc = qed_roce_sp_destroy_qp_requester(p_hwfn, qp,
if (rc) &num_bound_mw);
return rc; if (rc)
return rc;
if (num_invalidated_mw != num_bound_mw) { if (num_invalidated_mw != num_bound_mw) {
DP_NOTICE(p_hwfn, DP_NOTICE(p_hwfn,
"number of invalidate memory windows is different from bounded ones\n"); "number of invalidate memory windows is different from bounded ones\n");
return -EINVAL; return -EINVAL;
} }
spin_lock_bh(&p_hwfn->p_rdma_info->lock); spin_lock_bh(&p_rdma_info->lock);
start_cid = qed_cxt_get_proto_cid_start(p_hwfn, start_cid = qed_cxt_get_proto_cid_start(p_hwfn,
p_hwfn->p_rdma_info->proto); p_rdma_info->proto);
/* Release responder's icid */ /* Release responder's icid */
qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->cid_map, qed_bmap_release_id(p_hwfn, &p_rdma_info->cid_map,
qp->icid - start_cid); qp->icid - start_cid);
/* Release requester's icid */ /* Release requester's icid */
qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->cid_map, qed_bmap_release_id(p_hwfn, &p_rdma_info->cid_map,
qp->icid + 1 - start_cid); qp->icid + 1 - start_cid);
spin_unlock_bh(&p_hwfn->p_rdma_info->lock); spin_unlock_bh(&p_rdma_info->lock);
}
return 0; return 0;
} }
......
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