From patchwork Wed Mar 2 15:45:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moni Shoua X-Patchwork-Id: 603121 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 p22FjTfJ004269 for ; Wed, 2 Mar 2011 15:45:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753768Ab1CBPp2 (ORCPT ); Wed, 2 Mar 2011 10:45:28 -0500 Received: from mail.mellanox.co.il ([194.90.237.43]:57190 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752077Ab1CBPp2 (ORCPT ); Wed, 2 Mar 2011 10:45:28 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from monis@mellanox.com) with SMTP; 2 Mar 2011 17:54:08 +0200 Received: from MTRCASDAG01.mtl.com (172.25.0.174) by MTLCAS01.mtl.com (10.0.8.71) with Microsoft SMTP Server (TLS) id 14.1.270.1; Wed, 2 Mar 2011 17:45:22 +0200 Received: from [172.25.1.23] (172.25.1.23) by MTRCASDAG01.mtl.com (172.25.0.174) with Microsoft SMTP Server (TLS) id 14.1.270.1; Wed, 2 Mar 2011 17:45:22 +0200 Message-ID: <4D6E6606.5010900@Voltaire.COM> Date: Wed, 2 Mar 2011 17:45:10 +0200 From: Moni Shoua User-Agent: Thunderbird 1.5.0.12 (X11/20070718) MIME-Version: 1.0 To: Sean Hefty CC: linux-rdma , Subject: [PATCH] IB/rdma_cm: cancel pending lap message when destroying an ID X-Originating-IP: [172.25.1.23] 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]); Wed, 02 Mar 2011 15:45:30 +0000 (UTC) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 64e0903..3c00646 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -210,6 +210,7 @@ struct cm_id_private { atomic_t refcount; struct ib_mad_send_buf *msg; + struct ib_mad_send_buf *lap_msg; struct cm_timewait_info *timewait_info; /* todo: use alternate port on send failure */ struct cm_av av; @@ -839,6 +840,24 @@ static void cm_destroy_id(struct ib_cm_id *cm_id, int err) cm_id_priv = container_of(cm_id, struct cm_id_private, id); retest: spin_lock_irq(&cm_id_priv->lock); + + /* handle lap states first */ + switch (cm_id->lap_state) { + case IB_CM_LAP_UNINIT: + case IB_CM_LAP_IDLE: + break; + case IB_CM_LAP_SENT: + cm_id_priv->id.lap_state = IB_CM_LAP_IDLE; + ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->lap_msg); + cm_id_priv->lap_msg = NULL; + break; + case IB_CM_LAP_RCVD: + case IB_CM_MRA_LAP_SENT: + case IB_CM_MRA_LAP_RCVD: + default: + break; + } + switch (cm_id->state) { case IB_CM_LISTEN: cm_id->state = IB_CM_IDLE; @@ -2615,7 +2634,7 @@ int ib_send_cm_lap(struct ib_cm_id *cm_id, } cm_id->lap_state = IB_CM_LAP_SENT; - cm_id_priv->msg = msg; + cm_id_priv->lap_msg = msg; out: spin_unlock_irqrestore(&cm_id_priv->lock, flags); return ret; @@ -2811,8 +2830,8 @@ static int cm_apr_handler(struct cm_work *work) goto out; } cm_id_priv->id.lap_state = IB_CM_LAP_IDLE; - ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); - cm_id_priv->msg = NULL; + ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->lap_msg); + cm_id_priv->lap_msg = NULL; ret = atomic_inc_and_test(&cm_id_priv->work_count); if (!ret)