Skip to content

Commit 9fd5473

Browse files
Mike Marciniszynrolandd
authored andcommitted
IB/qib: Remove s_lock around header validation
Review of qib_ruc_check_hdr() shows that the s_lock is not required in the normal case. The r_lock is held in all cases, and protects the qp fields that are read. The s_lock will be needed to around the call to qib_migrate_qp() to insure that the send engine sees a consistent set of fields. Signed-off-by: Mike Marciniszyn <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent d0f2faf commit 9fd5473

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

drivers/infiniband/hw/qib/qib_driver.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ static u32 qib_rcv_hdrerr(struct qib_ctxtdata *rcd, struct qib_pportdata *ppd,
310310
u32 opcode;
311311
u32 psn;
312312
int diff;
313-
unsigned long flags;
314313

315314
/* Sanity check packet */
316315
if (tlen < 24)
@@ -365,19 +364,15 @@ static u32 qib_rcv_hdrerr(struct qib_ctxtdata *rcd, struct qib_pportdata *ppd,
365364

366365
switch (qp->ibqp.qp_type) {
367366
case IB_QPT_RC:
368-
spin_lock_irqsave(&qp->s_lock, flags);
369367
ruc_res =
370368
qib_ruc_check_hdr(
371369
ibp, hdr,
372370
lnh == QIB_LRH_GRH,
373371
qp,
374372
be32_to_cpu(ohdr->bth[0]));
375373
if (ruc_res) {
376-
spin_unlock_irqrestore(&qp->s_lock,
377-
flags);
378374
goto unlock;
379375
}
380-
spin_unlock_irqrestore(&qp->s_lock, flags);
381376

382377
/* Only deal with RDMA Writes for now */
383378
if (opcode <

drivers/infiniband/hw/qib/qib_rc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,10 +1889,8 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
18891889
}
18901890

18911891
opcode = be32_to_cpu(ohdr->bth[0]);
1892-
spin_lock_irqsave(&qp->s_lock, flags);
18931892
if (qib_ruc_check_hdr(ibp, hdr, has_grh, qp, opcode))
1894-
goto sunlock;
1895-
spin_unlock_irqrestore(&qp->s_lock, flags);
1893+
return;
18961894

18971895
psn = be32_to_cpu(ohdr->bth[2]);
18981896
opcode >>= 24;

drivers/infiniband/hw/qib/qib_ruc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,15 @@ static int gid_ok(union ib_gid *gid, __be64 gid_prefix, __be64 id)
260260

261261
/*
262262
*
263-
* This should be called with the QP s_lock held.
263+
* This should be called with the QP r_lock held.
264+
*
265+
* The s_lock will be acquired around the qib_migrate_qp() call.
264266
*/
265267
int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
266268
int has_grh, struct qib_qp *qp, u32 bth0)
267269
{
268270
__be64 guid;
271+
unsigned long flags;
269272

270273
if (qp->s_mig_state == IB_MIG_ARMED && (bth0 & IB_BTH_MIG_REQ)) {
271274
if (!has_grh) {
@@ -295,7 +298,9 @@ int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
295298
if (be16_to_cpu(hdr->lrh[3]) != qp->alt_ah_attr.dlid ||
296299
ppd_from_ibp(ibp)->port != qp->alt_ah_attr.port_num)
297300
goto err;
301+
spin_lock_irqsave(&qp->s_lock, flags);
298302
qib_migrate_qp(qp);
303+
spin_unlock_irqrestore(&qp->s_lock, flags);
299304
} else {
300305
if (!has_grh) {
301306
if (qp->remote_ah_attr.ah_flags & IB_AH_GRH)

drivers/infiniband/hw/qib/qib_uc.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
243243
int has_grh, void *data, u32 tlen, struct qib_qp *qp)
244244
{
245245
struct qib_other_headers *ohdr;
246-
unsigned long flags;
247246
u32 opcode;
248247
u32 hdrsize;
249248
u32 psn;
@@ -263,10 +262,8 @@ void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
263262
}
264263

265264
opcode = be32_to_cpu(ohdr->bth[0]);
266-
spin_lock_irqsave(&qp->s_lock, flags);
267265
if (qib_ruc_check_hdr(ibp, hdr, has_grh, qp, opcode))
268-
goto sunlock;
269-
spin_unlock_irqrestore(&qp->s_lock, flags);
266+
return;
270267

271268
psn = be32_to_cpu(ohdr->bth[2]);
272269
opcode >>= 24;
@@ -554,6 +551,4 @@ void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
554551
qib_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
555552
return;
556553

557-
sunlock:
558-
spin_unlock_irqrestore(&qp->s_lock, flags);
559554
}

0 commit comments

Comments
 (0)