diff options
author | Ralph Campbell <ralph.campbell@qlogic.com> | 2008-05-13 14:41:29 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-05-13 14:41:29 -0400 |
commit | e509be898d8937634437caa474b57ac12795e5bc (patch) | |
tree | f99b0e3965ee0eaf89acccdba382689719881a29 /drivers/infiniband/hw/ipath/ipath_uc.c | |
parent | 53dc1ca194c062aa9771e194047f27ec1ca592df (diff) |
IB/ipath: Fix many locking issues when switching to error state
The send DMA hardware queue voided a number of prior assumptions about
when a send is complete which led to completions being generated out of
order. There were also a number of locking issues when switching the QP
to the error or reset states, and we implement the IB_QPS_SQD state.
Signed-off-by: Ralph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_uc.c')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_uc.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_uc.c b/drivers/infiniband/hw/ipath/ipath_uc.c index bfe8926b551..7fd18e83390 100644 --- a/drivers/infiniband/hw/ipath/ipath_uc.c +++ b/drivers/infiniband/hw/ipath/ipath_uc.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. | 2 | * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved. |
3 | * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. | 3 | * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. |
4 | * | 4 | * |
5 | * This software is available to you under a choice of one of two | 5 | * This software is available to you under a choice of one of two |
@@ -47,14 +47,30 @@ int ipath_make_uc_req(struct ipath_qp *qp) | |||
47 | { | 47 | { |
48 | struct ipath_other_headers *ohdr; | 48 | struct ipath_other_headers *ohdr; |
49 | struct ipath_swqe *wqe; | 49 | struct ipath_swqe *wqe; |
50 | unsigned long flags; | ||
50 | u32 hwords; | 51 | u32 hwords; |
51 | u32 bth0; | 52 | u32 bth0; |
52 | u32 len; | 53 | u32 len; |
53 | u32 pmtu = ib_mtu_enum_to_int(qp->path_mtu); | 54 | u32 pmtu = ib_mtu_enum_to_int(qp->path_mtu); |
54 | int ret = 0; | 55 | int ret = 0; |
55 | 56 | ||
56 | if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)) | 57 | spin_lock_irqsave(&qp->s_lock, flags); |
58 | |||
59 | if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)) { | ||
60 | if (!(ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND)) | ||
61 | goto bail; | ||
62 | /* We are in the error state, flush the work request. */ | ||
63 | if (qp->s_last == qp->s_head) | ||
64 | goto bail; | ||
65 | /* If DMAs are in progress, we can't flush immediately. */ | ||
66 | if (atomic_read(&qp->s_dma_busy)) { | ||
67 | qp->s_flags |= IPATH_S_WAIT_DMA; | ||
68 | goto bail; | ||
69 | } | ||
70 | wqe = get_swqe_ptr(qp, qp->s_last); | ||
71 | ipath_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR); | ||
57 | goto done; | 72 | goto done; |
73 | } | ||
58 | 74 | ||
59 | ohdr = &qp->s_hdr.u.oth; | 75 | ohdr = &qp->s_hdr.u.oth; |
60 | if (qp->remote_ah_attr.ah_flags & IB_AH_GRH) | 76 | if (qp->remote_ah_attr.ah_flags & IB_AH_GRH) |
@@ -69,9 +85,12 @@ int ipath_make_uc_req(struct ipath_qp *qp) | |||
69 | qp->s_wqe = NULL; | 85 | qp->s_wqe = NULL; |
70 | switch (qp->s_state) { | 86 | switch (qp->s_state) { |
71 | default: | 87 | default: |
88 | if (!(ib_ipath_state_ops[qp->state] & | ||
89 | IPATH_PROCESS_NEXT_SEND_OK)) | ||
90 | goto bail; | ||
72 | /* Check if send work queue is empty. */ | 91 | /* Check if send work queue is empty. */ |
73 | if (qp->s_cur == qp->s_head) | 92 | if (qp->s_cur == qp->s_head) |
74 | goto done; | 93 | goto bail; |
75 | /* | 94 | /* |
76 | * Start a new request. | 95 | * Start a new request. |
77 | */ | 96 | */ |
@@ -134,7 +153,7 @@ int ipath_make_uc_req(struct ipath_qp *qp) | |||
134 | break; | 153 | break; |
135 | 154 | ||
136 | default: | 155 | default: |
137 | goto done; | 156 | goto bail; |
138 | } | 157 | } |
139 | break; | 158 | break; |
140 | 159 | ||
@@ -194,9 +213,14 @@ int ipath_make_uc_req(struct ipath_qp *qp) | |||
194 | ipath_make_ruc_header(to_idev(qp->ibqp.device), | 213 | ipath_make_ruc_header(to_idev(qp->ibqp.device), |
195 | qp, ohdr, bth0 | (qp->s_state << 24), | 214 | qp, ohdr, bth0 | (qp->s_state << 24), |
196 | qp->s_next_psn++ & IPATH_PSN_MASK); | 215 | qp->s_next_psn++ & IPATH_PSN_MASK); |
216 | done: | ||
197 | ret = 1; | 217 | ret = 1; |
218 | goto unlock; | ||
198 | 219 | ||
199 | done: | 220 | bail: |
221 | qp->s_flags &= ~IPATH_S_BUSY; | ||
222 | unlock: | ||
223 | spin_unlock_irqrestore(&qp->s_lock, flags); | ||
200 | return ret; | 224 | return ret; |
201 | } | 225 | } |
202 | 226 | ||
@@ -258,8 +282,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | |||
258 | */ | 282 | */ |
259 | opcode = be32_to_cpu(ohdr->bth[0]) >> 24; | 283 | opcode = be32_to_cpu(ohdr->bth[0]) >> 24; |
260 | 284 | ||
261 | wc.imm_data = 0; | 285 | memset(&wc, 0, sizeof wc); |
262 | wc.wc_flags = 0; | ||
263 | 286 | ||
264 | /* Compare the PSN verses the expected PSN. */ | 287 | /* Compare the PSN verses the expected PSN. */ |
265 | if (unlikely(ipath_cmp24(psn, qp->r_psn) != 0)) { | 288 | if (unlikely(ipath_cmp24(psn, qp->r_psn) != 0)) { |
@@ -322,8 +345,8 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | |||
322 | case OP(SEND_ONLY): | 345 | case OP(SEND_ONLY): |
323 | case OP(SEND_ONLY_WITH_IMMEDIATE): | 346 | case OP(SEND_ONLY_WITH_IMMEDIATE): |
324 | send_first: | 347 | send_first: |
325 | if (qp->r_reuse_sge) { | 348 | if (qp->r_flags & IPATH_R_REUSE_SGE) { |
326 | qp->r_reuse_sge = 0; | 349 | qp->r_flags &= ~IPATH_R_REUSE_SGE; |
327 | qp->r_sge = qp->s_rdma_read_sge; | 350 | qp->r_sge = qp->s_rdma_read_sge; |
328 | } else if (!ipath_get_rwqe(qp, 0)) { | 351 | } else if (!ipath_get_rwqe(qp, 0)) { |
329 | dev->n_pkt_drops++; | 352 | dev->n_pkt_drops++; |
@@ -340,13 +363,13 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | |||
340 | case OP(SEND_MIDDLE): | 363 | case OP(SEND_MIDDLE): |
341 | /* Check for invalid length PMTU or posted rwqe len. */ | 364 | /* Check for invalid length PMTU or posted rwqe len. */ |
342 | if (unlikely(tlen != (hdrsize + pmtu + 4))) { | 365 | if (unlikely(tlen != (hdrsize + pmtu + 4))) { |
343 | qp->r_reuse_sge = 1; | 366 | qp->r_flags |= IPATH_R_REUSE_SGE; |
344 | dev->n_pkt_drops++; | 367 | dev->n_pkt_drops++; |
345 | goto done; | 368 | goto done; |
346 | } | 369 | } |
347 | qp->r_rcv_len += pmtu; | 370 | qp->r_rcv_len += pmtu; |
348 | if (unlikely(qp->r_rcv_len > qp->r_len)) { | 371 | if (unlikely(qp->r_rcv_len > qp->r_len)) { |
349 | qp->r_reuse_sge = 1; | 372 | qp->r_flags |= IPATH_R_REUSE_SGE; |
350 | dev->n_pkt_drops++; | 373 | dev->n_pkt_drops++; |
351 | goto done; | 374 | goto done; |
352 | } | 375 | } |
@@ -372,7 +395,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | |||
372 | /* Check for invalid length. */ | 395 | /* Check for invalid length. */ |
373 | /* XXX LAST len should be >= 1 */ | 396 | /* XXX LAST len should be >= 1 */ |
374 | if (unlikely(tlen < (hdrsize + pad + 4))) { | 397 | if (unlikely(tlen < (hdrsize + pad + 4))) { |
375 | qp->r_reuse_sge = 1; | 398 | qp->r_flags |= IPATH_R_REUSE_SGE; |
376 | dev->n_pkt_drops++; | 399 | dev->n_pkt_drops++; |
377 | goto done; | 400 | goto done; |
378 | } | 401 | } |
@@ -380,7 +403,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | |||
380 | tlen -= (hdrsize + pad + 4); | 403 | tlen -= (hdrsize + pad + 4); |
381 | wc.byte_len = tlen + qp->r_rcv_len; | 404 | wc.byte_len = tlen + qp->r_rcv_len; |
382 | if (unlikely(wc.byte_len > qp->r_len)) { | 405 | if (unlikely(wc.byte_len > qp->r_len)) { |
383 | qp->r_reuse_sge = 1; | 406 | qp->r_flags |= IPATH_R_REUSE_SGE; |
384 | dev->n_pkt_drops++; | 407 | dev->n_pkt_drops++; |
385 | goto done; | 408 | goto done; |
386 | } | 409 | } |
@@ -390,14 +413,10 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | |||
390 | wc.wr_id = qp->r_wr_id; | 413 | wc.wr_id = qp->r_wr_id; |
391 | wc.status = IB_WC_SUCCESS; | 414 | wc.status = IB_WC_SUCCESS; |
392 | wc.opcode = IB_WC_RECV; | 415 | wc.opcode = IB_WC_RECV; |
393 | wc.vendor_err = 0; | ||
394 | wc.qp = &qp->ibqp; | 416 | wc.qp = &qp->ibqp; |
395 | wc.src_qp = qp->remote_qpn; | 417 | wc.src_qp = qp->remote_qpn; |
396 | wc.pkey_index = 0; | ||
397 | wc.slid = qp->remote_ah_attr.dlid; | 418 | wc.slid = qp->remote_ah_attr.dlid; |
398 | wc.sl = qp->remote_ah_attr.sl; | 419 | wc.sl = qp->remote_ah_attr.sl; |
399 | wc.dlid_path_bits = 0; | ||
400 | wc.port_num = 0; | ||
401 | /* Signal completion event if the solicited bit is set. */ | 420 | /* Signal completion event if the solicited bit is set. */ |
402 | ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, | 421 | ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, |
403 | (ohdr->bth[0] & | 422 | (ohdr->bth[0] & |
@@ -488,8 +507,8 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | |||
488 | dev->n_pkt_drops++; | 507 | dev->n_pkt_drops++; |
489 | goto done; | 508 | goto done; |
490 | } | 509 | } |
491 | if (qp->r_reuse_sge) | 510 | if (qp->r_flags & IPATH_R_REUSE_SGE) |
492 | qp->r_reuse_sge = 0; | 511 | qp->r_flags &= ~IPATH_R_REUSE_SGE; |
493 | else if (!ipath_get_rwqe(qp, 1)) { | 512 | else if (!ipath_get_rwqe(qp, 1)) { |
494 | dev->n_pkt_drops++; | 513 | dev->n_pkt_drops++; |
495 | goto done; | 514 | goto done; |