Commit 6117561e authored by Michal Kalderon's avatar Michal Kalderon Committed by David S. Miller

qed: iWARP - Use READ_ONCE and smp_store_release to access ep->state

Destroy QP waits for it's ep object state to be set to CLOSED
before proceeding. ep->state can be updated from a different
context. Add smp_store_release/READ_ONCE to synchronize.

Fixes: fc4c6065 ("qed: iWARP implement disconnect flows")
Signed-off-by: default avatarAriel Elior <ariel.elior@marvell.com>
Signed-off-by: default avatarMichal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1086ca3a
......@@ -532,7 +532,8 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp)
/* Make sure ep is closed before returning and freeing memory. */
if (ep) {
while (ep->state != QED_IWARP_EP_CLOSED && wait_count++ < 200)
while (READ_ONCE(ep->state) != QED_IWARP_EP_CLOSED &&
wait_count++ < 200)
msleep(100);
if (ep->state != QED_IWARP_EP_CLOSED)
......@@ -1022,8 +1023,6 @@ qed_iwarp_mpa_complete(struct qed_hwfn *p_hwfn,
params.ep_context = ep;
ep->state = QED_IWARP_EP_CLOSED;
switch (fw_return_code) {
case RDMA_RETURN_OK:
ep->qp->max_rd_atomic_req = ep->cm_info.ord;
......@@ -1083,6 +1082,10 @@ qed_iwarp_mpa_complete(struct qed_hwfn *p_hwfn,
break;
}
if (fw_return_code != RDMA_RETURN_OK)
/* paired with READ_ONCE in destroy_qp */
smp_store_release(&ep->state, QED_IWARP_EP_CLOSED);
ep->event_cb(ep->cb_context, &params);
/* on passive side, if there is no associated QP (REJECT) we need to
......@@ -2825,7 +2828,9 @@ static void qed_iwarp_qp_in_error(struct qed_hwfn *p_hwfn,
params.status = (fw_return_code == IWARP_QP_IN_ERROR_GOOD_CLOSE) ?
0 : -ECONNRESET;
ep->state = QED_IWARP_EP_CLOSED;
/* paired with READ_ONCE in destroy_qp */
smp_store_release(&ep->state, QED_IWARP_EP_CLOSED);
spin_lock_bh(&p_hwfn->p_rdma_info->iwarp.iw_lock);
list_del(&ep->list_entry);
spin_unlock_bh(&p_hwfn->p_rdma_info->iwarp.iw_lock);
......@@ -2914,7 +2919,8 @@ qed_iwarp_tcp_connect_unsuccessful(struct qed_hwfn *p_hwfn,
params.event = QED_IWARP_EVENT_ACTIVE_COMPLETE;
params.ep_context = ep;
params.cm_info = &ep->cm_info;
ep->state = QED_IWARP_EP_CLOSED;
/* paired with READ_ONCE in destroy_qp */
smp_store_release(&ep->state, QED_IWARP_EP_CLOSED);
switch (fw_return_code) {
case IWARP_CONN_ERROR_TCP_CONNECT_INVALID_PACKET:
......
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