aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw
diff options
context:
space:
mode:
authorMike Marciniszyn <mike.marciniszyn@qlogic.com>2011-09-23 13:17:00 -0400
committerRoland Dreier <roland@purestorage.com>2011-10-21 12:38:57 -0400
commit9fd5473deb421eb7e5575a5f9d7e43ca67c04fe9 (patch)
treecf4314fee9e1e4f501ac1114ed200c004ebadf91 /drivers/infiniband/hw
parentd0f2faf72d51dacf5c5e8dec7dca22d0395896e2 (diff)
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 <mike.marciniszyn@qlogic.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r--drivers/infiniband/hw/qib/qib_driver.c5
-rw-r--r--drivers/infiniband/hw/qib/qib_rc.c4
-rw-r--r--drivers/infiniband/hw/qib/qib_ruc.c7
-rw-r--r--drivers/infiniband/hw/qib/qib_uc.c7
4 files changed, 8 insertions, 15 deletions
diff --git a/drivers/infiniband/hw/qib/qib_driver.c b/drivers/infiniband/hw/qib/qib_driver.c
index d35c9d38ceee..9a9047f385ae 100644
--- a/drivers/infiniband/hw/qib/qib_driver.c
+++ b/drivers/infiniband/hw/qib/qib_driver.c
@@ -310,7 +310,6 @@ static u32 qib_rcv_hdrerr(struct qib_ctxtdata *rcd, struct qib_pportdata *ppd,
310 u32 opcode; 310 u32 opcode;
311 u32 psn; 311 u32 psn;
312 int diff; 312 int diff;
313 unsigned long flags;
314 313
315 /* Sanity check packet */ 314 /* Sanity check packet */
316 if (tlen < 24) 315 if (tlen < 24)
@@ -365,7 +364,6 @@ static u32 qib_rcv_hdrerr(struct qib_ctxtdata *rcd, struct qib_pportdata *ppd,
365 364
366 switch (qp->ibqp.qp_type) { 365 switch (qp->ibqp.qp_type) {
367 case IB_QPT_RC: 366 case IB_QPT_RC:
368 spin_lock_irqsave(&qp->s_lock, flags);
369 ruc_res = 367 ruc_res =
370 qib_ruc_check_hdr( 368 qib_ruc_check_hdr(
371 ibp, hdr, 369 ibp, hdr,
@@ -373,11 +371,8 @@ static u32 qib_rcv_hdrerr(struct qib_ctxtdata *rcd, struct qib_pportdata *ppd,
373 qp, 371 qp,
374 be32_to_cpu(ohdr->bth[0])); 372 be32_to_cpu(ohdr->bth[0]));
375 if (ruc_res) { 373 if (ruc_res) {
376 spin_unlock_irqrestore(&qp->s_lock,
377 flags);
378 goto unlock; 374 goto unlock;
379 } 375 }
380 spin_unlock_irqrestore(&qp->s_lock, flags);
381 376
382 /* Only deal with RDMA Writes for now */ 377 /* Only deal with RDMA Writes for now */
383 if (opcode < 378 if (opcode <
diff --git a/drivers/infiniband/hw/qib/qib_rc.c b/drivers/infiniband/hw/qib/qib_rc.c
index ecfa087ad45e..afaf4ac79f42 100644
--- a/drivers/infiniband/hw/qib/qib_rc.c
+++ b/drivers/infiniband/hw/qib/qib_rc.c
@@ -1889,10 +1889,8 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
1889 } 1889 }
1890 1890
1891 opcode = be32_to_cpu(ohdr->bth[0]); 1891 opcode = be32_to_cpu(ohdr->bth[0]);
1892 spin_lock_irqsave(&qp->s_lock, flags);
1893 if (qib_ruc_check_hdr(ibp, hdr, has_grh, qp, opcode)) 1892 if (qib_ruc_check_hdr(ibp, hdr, has_grh, qp, opcode))
1894 goto sunlock; 1893 return;
1895 spin_unlock_irqrestore(&qp->s_lock, flags);
1896 1894
1897 psn = be32_to_cpu(ohdr->bth[2]); 1895 psn = be32_to_cpu(ohdr->bth[2]);
1898 opcode >>= 24; 1896 opcode >>= 24;
diff --git a/drivers/infiniband/hw/qib/qib_ruc.c b/drivers/infiniband/hw/qib/qib_ruc.c
index eb78d9367f06..b4b37e47321a 100644
--- a/drivers/infiniband/hw/qib/qib_ruc.c
+++ b/drivers/infiniband/hw/qib/qib_ruc.c
@@ -260,12 +260,15 @@ static int gid_ok(union ib_gid *gid, __be64 gid_prefix, __be64 id)
260 260
261/* 261/*
262 * 262 *
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.
264 */ 266 */
265int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr, 267int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
266 int has_grh, struct qib_qp *qp, u32 bth0) 268 int has_grh, struct qib_qp *qp, u32 bth0)
267{ 269{
268 __be64 guid; 270 __be64 guid;
271 unsigned long flags;
269 272
270 if (qp->s_mig_state == IB_MIG_ARMED && (bth0 & IB_BTH_MIG_REQ)) { 273 if (qp->s_mig_state == IB_MIG_ARMED && (bth0 & IB_BTH_MIG_REQ)) {
271 if (!has_grh) { 274 if (!has_grh) {
@@ -295,7 +298,9 @@ int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
295 if (be16_to_cpu(hdr->lrh[3]) != qp->alt_ah_attr.dlid || 298 if (be16_to_cpu(hdr->lrh[3]) != qp->alt_ah_attr.dlid ||
296 ppd_from_ibp(ibp)->port != qp->alt_ah_attr.port_num) 299 ppd_from_ibp(ibp)->port != qp->alt_ah_attr.port_num)
297 goto err; 300 goto err;
301 spin_lock_irqsave(&qp->s_lock, flags);
298 qib_migrate_qp(qp); 302 qib_migrate_qp(qp);
303 spin_unlock_irqrestore(&qp->s_lock, flags);
299 } else { 304 } else {
300 if (!has_grh) { 305 if (!has_grh) {
301 if (qp->remote_ah_attr.ah_flags & IB_AH_GRH) 306 if (qp->remote_ah_attr.ah_flags & IB_AH_GRH)
diff --git a/drivers/infiniband/hw/qib/qib_uc.c b/drivers/infiniband/hw/qib/qib_uc.c
index 9a4630f8276f..847e7afdfd94 100644
--- a/drivers/infiniband/hw/qib/qib_uc.c
+++ b/drivers/infiniband/hw/qib/qib_uc.c
@@ -243,7 +243,6 @@ void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
243 int has_grh, void *data, u32 tlen, struct qib_qp *qp) 243 int has_grh, void *data, u32 tlen, struct qib_qp *qp)
244{ 244{
245 struct qib_other_headers *ohdr; 245 struct qib_other_headers *ohdr;
246 unsigned long flags;
247 u32 opcode; 246 u32 opcode;
248 u32 hdrsize; 247 u32 hdrsize;
249 u32 psn; 248 u32 psn;
@@ -263,10 +262,8 @@ void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
263 } 262 }
264 263
265 opcode = be32_to_cpu(ohdr->bth[0]); 264 opcode = be32_to_cpu(ohdr->bth[0]);
266 spin_lock_irqsave(&qp->s_lock, flags);
267 if (qib_ruc_check_hdr(ibp, hdr, has_grh, qp, opcode)) 265 if (qib_ruc_check_hdr(ibp, hdr, has_grh, qp, opcode))
268 goto sunlock; 266 return;
269 spin_unlock_irqrestore(&qp->s_lock, flags);
270 267
271 psn = be32_to_cpu(ohdr->bth[2]); 268 psn = be32_to_cpu(ohdr->bth[2]);
272 opcode >>= 24; 269 opcode >>= 24;
@@ -554,6 +551,4 @@ op_err:
554 qib_rc_error(qp, IB_WC_LOC_QP_OP_ERR); 551 qib_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
555 return; 552 return;
556 553
557sunlock:
558 spin_unlock_irqrestore(&qp->s_lock, flags);
559} 554}