linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-rc] RDMA/iw_cxgb4: initiate CLOSE when entering TERM
@ 2020-02-04  9:12 Krishnamraju Eraparaju
  2020-02-11 18:30 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Krishnamraju Eraparaju @ 2020-02-04  9:12 UTC (permalink / raw)
  To: jgg, dledford; +Cc: linux-rdma, bharat, nirranjan, krishna2

- As per draft-hilland-iwarp-verbs-v1.0, sec 6.2.3,
  always initiate a CLOSE when entering into TERM state.

- In c4iw_modify_qp(), disconnect operation should only be performed
  when the modify_qp call is invoked from ib_core. And all other
  internal modify_qp calls(invoked within iw_cxgb4) that needs
  'disconnect' should call c4iw_ep_disconnect() explicitly
  after modify_qp. Otherwise, deadlocks like below can occur:

 Call Trace:
  schedule+0x2f/0xa0
  schedule_preempt_disabled+0xa/0x10
  __mutex_lock.isra.5+0x2d0/0x4a0
  c4iw_ep_disconnect+0x39/0x430    => tries to reacquire ep lock again
  c4iw_modify_qp+0x468/0x10d0
  rx_data+0x218/0x570              => acquires ep lock
  process_work+0x5f/0x70
  process_one_work+0x1a7/0x3b0
  worker_thread+0x30/0x390
  kthread+0x112/0x130
  ret_from_fork+0x35/0x40

Fixes: d2c33370ae73 ("RDMA/iw_cxgb4: Always disconnect when QP is
transitioning to TERMINATE state")
Signed-off-by: Krishnamraju Eraparaju <krishna2@chelsio.com>
---
 drivers/infiniband/hw/cxgb4/cm.c | 4 ++++
 drivers/infiniband/hw/cxgb4/qp.c | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index ee1182f9b627..d69dece3b1d5 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -3036,6 +3036,10 @@ static int terminate(struct c4iw_dev *dev, struct sk_buff *skb)
 				       C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
 		}
 
+		/* As per draft-hilland-iwarp-verbs-v1.0, sec 6.2.3,
+		 * when entering the TERM state the RNIC MUST initiate a CLOSE.
+		 */
+		c4iw_ep_disconnect(ep, 1, GFP_KERNEL);
 		c4iw_put_ep(&ep->com);
 	} else
 		pr_warn("TERM received tid %u no ep/qp\n", tid);
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index bbcac539777a..89ac2f9ae6dd 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -1948,10 +1948,10 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_qp *qhp,
 			qhp->attr.layer_etype = attrs->layer_etype;
 			qhp->attr.ecode = attrs->ecode;
 			ep = qhp->ep;
-			c4iw_get_ep(&ep->com);
-			disconnect = 1;
 			if (!internal) {
+				c4iw_get_ep(&ep->com);
 				terminate = 1;
+				disconnect = 1;
 			} else {
 				terminate = qhp->attr.send_term;
 				ret = rdma_fini(rhp, qhp, ep);
-- 
2.23.0.rc0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH for-rc] RDMA/iw_cxgb4: initiate CLOSE when entering TERM
  2020-02-04  9:12 [PATCH for-rc] RDMA/iw_cxgb4: initiate CLOSE when entering TERM Krishnamraju Eraparaju
@ 2020-02-11 18:30 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2020-02-11 18:30 UTC (permalink / raw)
  To: Krishnamraju Eraparaju; +Cc: dledford, linux-rdma, bharat, nirranjan

On Tue, Feb 04, 2020 at 02:42:30PM +0530, Krishnamraju Eraparaju wrote:
> - As per draft-hilland-iwarp-verbs-v1.0, sec 6.2.3,
>   always initiate a CLOSE when entering into TERM state.
> 
> - In c4iw_modify_qp(), disconnect operation should only be performed
>   when the modify_qp call is invoked from ib_core. And all other
>   internal modify_qp calls(invoked within iw_cxgb4) that needs
>   'disconnect' should call c4iw_ep_disconnect() explicitly
>   after modify_qp. Otherwise, deadlocks like below can occur:
> 
>  Call Trace:
>   schedule+0x2f/0xa0
>   schedule_preempt_disabled+0xa/0x10
>   __mutex_lock.isra.5+0x2d0/0x4a0
>   c4iw_ep_disconnect+0x39/0x430    => tries to reacquire ep lock again
>   c4iw_modify_qp+0x468/0x10d0
>   rx_data+0x218/0x570              => acquires ep lock
>   process_work+0x5f/0x70
>   process_one_work+0x1a7/0x3b0
>   worker_thread+0x30/0x390
>   kthread+0x112/0x130
>   ret_from_fork+0x35/0x40
> 
> Fixes: d2c33370ae73 ("RDMA/iw_cxgb4: Always disconnect when QP is
> transitioning to TERMINATE state")
> Signed-off-by: Krishnamraju Eraparaju <krishna2@chelsio.com>
> ---
>  drivers/infiniband/hw/cxgb4/cm.c | 4 ++++
>  drivers/infiniband/hw/cxgb4/qp.c | 4 ++--
>  2 files changed, 6 insertions(+), 2 deletions(-)

Applied to for-rc, thanks

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-11 18:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04  9:12 [PATCH for-rc] RDMA/iw_cxgb4: initiate CLOSE when entering TERM Krishnamraju Eraparaju
2020-02-11 18:30 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).