From patchwork Sun Mar 23 20:18:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 3880661 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C8B91BF540 for ; Sun, 23 Mar 2014 20:18:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED18320220 for ; Sun, 23 Mar 2014 20:18:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F4DD20263 for ; Sun, 23 Mar 2014 20:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbaCWUSp (ORCPT ); Sun, 23 Mar 2014 16:18:45 -0400 Received: from mga11.intel.com ([192.55.52.93]:10324 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbaCWUSd (ORCPT ); Sun, 23 Mar 2014 16:18:33 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 23 Mar 2014 13:18:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,715,1389772800"; d="scan'208";a="505038301" Received: from cst-linux.jf.intel.com ([10.23.221.72]) by fmsmga002.fm.intel.com with ESMTP; 23 Mar 2014 13:18:32 -0700 From: sean.hefty@intel.com To: sean.hefty@intel.com, ira.weiny@intel.com, kaike.wan@intel.com, john.fleck@intel.com, linux-rdma@vger.kernel.org Subject: [PATCH 7/9] ibacm: Reset endpoint state on error Date: Sun, 23 Mar 2014 13:18:19 -0700 Message-Id: <1395605901-9080-8-git-send-email-sean.hefty@intel.com> X-Mailer: git-send-email 1.7.3 In-Reply-To: <1395605901-9080-1-git-send-email-sean.hefty@intel.com> References: <1395605901-9080-1-git-send-email-sean.hefty@intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Hefty An endpoint will be set to the ACM_READY state after joining its multicast group. If we later receive a reregister event or port down followed by port up and try to join the group again but fail, we will leave the endpoint state as READY, rather than reset it back to INIT. To fix, always set the mc_dest state to ACM_INIT on any failure. Signed-off-by: Sean Hefty --- src/acm.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/acm.c b/src/acm.c index a8a1fb9..eba027d 100644 --- a/src/acm.c +++ b/src/acm.c @@ -750,21 +750,21 @@ static void acm_process_join_resp(struct acm_ep *ep, struct ib_user_mad *umad) mad = (struct ib_sa_mad *) umad->data; acm_log(1, "response status: 0x%x, mad status: 0x%x\n", umad->status, mad->status); + lock_acquire(&ep->lock); if (umad->status) { acm_log(0, "ERROR - send join failed 0x%x\n", umad->status); - return; + goto err1; } if (mad->status) { acm_log(0, "ERROR - join response status 0x%x\n", mad->status); - return; + goto err1; } mc_rec = (struct ib_mc_member_rec *) mad->data; - lock_acquire(&ep->lock); index = acm_mc_index(ep, &mc_rec->mgid); if (index < 0) { acm_log(0, "ERROR - MGID in join response not found\n"); - goto out; + goto err1; } dest = &ep->mc_dest[index]; @@ -776,19 +776,25 @@ static void acm_process_join_resp(struct acm_ep *ep, struct ib_user_mad *umad) dest->ah = ibv_create_ah(ep->port->dev->pd, &dest->av); if (!dest->ah) { acm_log(0, "ERROR - unable to create ah\n"); - goto out; + goto err1; } ret = ibv_attach_mcast(ep->qp, &mc_rec->mgid, mc_rec->mlid); if (ret) { acm_log(0, "ERROR - unable to attach QP to multicast group\n"); - goto out; + goto err2; } } atomic_set(&dest->refcnt, 1); dest->state = ACM_READY; acm_log(1, "join successful\n"); -out: + lock_release(&ep->lock); + return; +err2: + ibv_destroy_ah(dest->ah); + dest->ah = NULL; +err1: + dest->state = ACM_INIT; lock_release(&ep->lock); }