Skip to content

Commit 8da7e7a

Browse files
Steve Wiserolandd
authored andcommitted
RDMA/cxgb4: Couple of abort fixes
- fix a race where the driver could end up sending a close_con_req after an abort_rpl. In c4iw_ep_disconnect(), send abort or close request with the ep mutex held. - fix a hang where driver fails to wake up when a connection is reset during a normal close. Wake up any waiters in the interrupt path, and correctly cleanup after rdma_fini() failures. Signed-off-by: Steve Wise <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 301c2c3 commit 8da7e7a

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

drivers/infiniband/hw/cxgb4/cm.c

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,9 +1463,9 @@ static int peer_close(struct c4iw_dev *dev, struct sk_buff *skb)
14631463
struct c4iw_qp_attributes attrs;
14641464
int disconnect = 1;
14651465
int release = 0;
1466-
int abort = 0;
14671466
struct tid_info *t = dev->rdev.lldi.tids;
14681467
unsigned int tid = GET_TID(hdr);
1468+
int ret;
14691469

14701470
ep = lookup_tid(t, tid);
14711471
PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
@@ -1501,10 +1501,12 @@ static int peer_close(struct c4iw_dev *dev, struct sk_buff *skb)
15011501
start_ep_timer(ep);
15021502
__state_set(&ep->com, CLOSING);
15031503
attrs.next_state = C4IW_QP_STATE_CLOSING;
1504-
abort = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
1504+
ret = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
15051505
C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
1506-
peer_close_upcall(ep);
1507-
disconnect = 1;
1506+
if (ret != -ECONNRESET) {
1507+
peer_close_upcall(ep);
1508+
disconnect = 1;
1509+
}
15081510
break;
15091511
case ABORTING:
15101512
disconnect = 0;
@@ -2109,15 +2111,16 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
21092111
break;
21102112
}
21112113

2112-
mutex_unlock(&ep->com.mutex);
21132114
if (close) {
2114-
if (abrupt)
2115-
ret = abort_connection(ep, NULL, gfp);
2116-
else
2115+
if (abrupt) {
2116+
close_complete_upcall(ep);
2117+
ret = send_abort(ep, NULL, gfp);
2118+
} else
21172119
ret = send_halfclose(ep, gfp);
21182120
if (ret)
21192121
fatal = 1;
21202122
}
2123+
mutex_unlock(&ep->com.mutex);
21212124
if (fatal)
21222125
release_ep_resources(ep);
21232126
return ret;
@@ -2301,6 +2304,31 @@ static int fw6_msg(struct c4iw_dev *dev, struct sk_buff *skb)
23012304
return 0;
23022305
}
23032306

2307+
static int peer_abort_intr(struct c4iw_dev *dev, struct sk_buff *skb)
2308+
{
2309+
struct cpl_abort_req_rss *req = cplhdr(skb);
2310+
struct c4iw_ep *ep;
2311+
struct tid_info *t = dev->rdev.lldi.tids;
2312+
unsigned int tid = GET_TID(req);
2313+
2314+
ep = lookup_tid(t, tid);
2315+
if (is_neg_adv_abort(req->status)) {
2316+
PDBG("%s neg_adv_abort ep %p tid %u\n", __func__, ep,
2317+
ep->hwtid);
2318+
kfree_skb(skb);
2319+
return 0;
2320+
}
2321+
PDBG("%s ep %p tid %u state %u\n", __func__, ep, ep->hwtid,
2322+
ep->com.state);
2323+
2324+
/*
2325+
* Wake up any threads in rdma_init() or rdma_fini().
2326+
*/
2327+
c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET);
2328+
sched(dev, skb);
2329+
return 0;
2330+
}
2331+
23042332
/*
23052333
* Most upcalls from the T4 Core go to sched() to
23062334
* schedule the processing on a work queue.
@@ -2317,7 +2345,7 @@ c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS] = {
23172345
[CPL_PASS_ESTABLISH] = sched,
23182346
[CPL_PEER_CLOSE] = sched,
23192347
[CPL_CLOSE_CON_RPL] = sched,
2320-
[CPL_ABORT_REQ_RSS] = sched,
2348+
[CPL_ABORT_REQ_RSS] = peer_abort_intr,
23212349
[CPL_RDMA_TERMINATE] = sched,
23222350
[CPL_FW4_ACK] = sched,
23232351
[CPL_SET_TCB_RPL] = set_tcb_rpl,

drivers/infiniband/hw/cxgb4/qp.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,11 +1207,8 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_qp *qhp,
12071207
c4iw_get_ep(&qhp->ep->com);
12081208
}
12091209
ret = rdma_fini(rhp, qhp, ep);
1210-
if (ret) {
1211-
if (internal)
1212-
c4iw_get_ep(&qhp->ep->com);
1210+
if (ret)
12131211
goto err;
1214-
}
12151212
break;
12161213
case C4IW_QP_STATE_TERMINATE:
12171214
set_state(qhp, C4IW_QP_STATE_TERMINATE);

0 commit comments

Comments
 (0)