From patchwork Thu Mar 17 12:13:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 641331 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2HCBdbG021537 for ; Thu, 17 Mar 2011 12:11:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754076Ab1CQMLe (ORCPT ); Thu, 17 Mar 2011 08:11:34 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:33972 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753846Ab1CQMLe (ORCPT ); Thu, 17 Mar 2011 08:11:34 -0400 Received: by bwz15 with SMTP id 15so2377218bwz.19 for ; Thu, 17 Mar 2011 05:11:30 -0700 (PDT) Received: by 10.204.33.22 with SMTP id f22mr1107324bkd.72.1300363890765; Thu, 17 Mar 2011 05:11:30 -0700 (PDT) Received: from localhost ([82.166.227.17]) by mx.google.com with ESMTPS id q18sm1314782bka.15.2011.03.17.05.11.28 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Mar 2011 05:11:29 -0700 (PDT) Date: Thu, 17 Mar 2011 14:13:42 +0200 From: Eli Cohen To: roland@kernel.org Cc: RDMA list , ronniz@mellanox.co.il Subject: [PATCH] IPoIB: Modify QP to error only if not in reset Message-ID: <20110317121341.GA7985@mtldesk30> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 17 Mar 2011 12:11:39 +0000 (UTC) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 806d029..ceff2bc 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c @@ -806,6 +806,8 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush) unsigned long begin; struct ipoib_tx_buf *tx_req; int i; + struct ib_qp_init_attr qp_init_attr; + int err; if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) napi_disable(&priv->napi); @@ -813,12 +815,24 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush) ipoib_cm_dev_stop(dev); /* + * if we fail to query the QP we continue as if it was in + * a state different than RESET so we carry any cleanup possible + */ + err = ib_query_qp(priv->qp, &qp_attr, IB_QP_CUR_STATE, &qp_init_attr); + if (err) { + ipoib_warn(priv, "Failed to query QP state, err %d\n", err); + qp_attr.cur_qp_state = IB_QPS_INIT; + } + + /* * Move our QP to the error state and then reinitialize in * when all work requests have completed or have been flushed. */ - qp_attr.qp_state = IB_QPS_ERR; - if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE)) - ipoib_warn(priv, "Failed to modify QP to ERROR state\n"); + if (qp_attr.cur_qp_state != IB_QPS_RESET) { + qp_attr.qp_state = IB_QPS_ERR; + if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE)) + ipoib_warn(priv, "Failed to modify QP to ERROR state\n"); + } /* Wait for all sends and receives to complete */ begin = jiffies;