From patchwork Wed Mar 5 18:49:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3778411 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C9AC69F383 for ; Wed, 5 Mar 2014 18:49:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D878320219 for ; Wed, 5 Mar 2014 18:49:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D00720212 for ; Wed, 5 Mar 2014 18:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756605AbaCEStO (ORCPT ); Wed, 5 Mar 2014 13:49:14 -0500 Received: from mail-wg0-f47.google.com ([74.125.82.47]:60664 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751573AbaCEStN (ORCPT ); Wed, 5 Mar 2014 13:49:13 -0500 Received: by mail-wg0-f47.google.com with SMTP id x12so1757118wgg.18 for ; Wed, 05 Mar 2014 10:49:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=uWkLtHvjoHXOw6ZZmLTup3h6eGHlBebVxk/Iho9RuPE=; b=ajuJPbRWxI414DEu4p6Bz3vE3Oz8819TuEupskePsjDWnZyolwb8wSu1GX2vPDo4hW i9oDMXenZygcrFnhb5RU25L22y/qOVl0NAhOJKdF8rqvmmFTls5Qk41RwSGWaSpUWzf1 vEJieDSiO9BD5cagWHir8Viibqans1oCTYRSRxdFgMe1PhojQ3Z30ZLNugi2DhZFFOWi SkxMF1J7PKMeFV4yTmtbm96UPYJgADeWjtb9KUncrHat/ilY4Ms28hGgaUOKL5RwXc2v 6AORB3+qP4l/3FPb4LiKngQtwKyT7oF6LVIDSpKKZ3hcm23rdzL1Y6tuak83YrIChRru tZAg== X-Gm-Message-State: ALoCoQkEjxRh2nD6wmC/394VggEnH5oIBXVoLFi6pCP6z8SMJ/o212vVEsepHZersJE/VhHm1STJ X-Received: by 10.194.190.10 with SMTP id gm10mr3296469wjc.55.1394045351565; Wed, 05 Mar 2014 10:49:11 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id dd3sm4192345wjb.9.2014.03.05.10.49.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Mar 2014 10:49:10 -0800 (PST) Message-ID: <531771A3.1090906@dev.mellanox.co.il> Date: Wed, 05 Mar 2014 13:49:07 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Vladimir Koushnir Subject: [PATCH opensm] osm_sm_state_mgr.c: Fix opensm crash after handover Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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: Vladimir Koushnir Date: Mon, 8 Apr 2013 20:09:23 +0300 Signed-off-by: Vladimir Koushnir Signed-off-by: Hal Rosenstock --- opensm/osm_sm_state_mgr.c | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/opensm/osm_sm_state_mgr.c b/opensm/osm_sm_state_mgr.c index 5e4b06a..2c26d38 100644 --- a/opensm/osm_sm_state_mgr.c +++ b/opensm/osm_sm_state_mgr.c @@ -1,6 +1,6 @@ /* + * Copyright (c) 2002-2013 Mellanox Technologies LTD. All rights reserved. * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved. - * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * @@ -297,15 +297,17 @@ ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm, * Update the state of the SM to MASTER */ /* Turn on the first_time_master_sweep flag */ - sm->p_subn->first_time_master_sweep = TRUE; sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER; osm_report_sm_state(sm); /* * Make sure to set the subnet master_sm_base_lid * to the sm_base_lid value */ + CL_PLOCK_EXCL_ACQUIRE(sm->p_lock); + sm->p_subn->first_time_master_sweep = TRUE; sm->p_subn->master_sm_base_lid = sm->p_subn->sm_base_lid; + CL_PLOCK_RELEASE(sm->p_lock) break; case OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED: /* @@ -318,8 +320,9 @@ ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm, * Since another SM is doing the LFT config - we should not * ignore the results of it */ + CL_PLOCK_EXCL_ACQUIRE(sm->p_lock); sm->p_subn->ignore_existing_lfts = FALSE; - + CL_PLOCK_RELEASE(sm->p_lock); sm_state_mgr_start_polling(sm); break; case OSM_SM_SIGNAL_HANDOVER: @@ -351,7 +354,9 @@ ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm, */ sm->p_subn->sm_state = IB_SMINFO_STATE_DISCOVERING; osm_report_sm_state(sm); + CL_PLOCK_EXCL_ACQUIRE(sm->p_lock); sm->p_subn->coming_out_of_standby = TRUE; + CL_PLOCK_RELEASE(sm->p_lock); osm_sm_signal(sm, OSM_SIGNAL_SWEEP); break; case OSM_SM_SIGNAL_DISABLE: @@ -367,6 +372,7 @@ ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm, * OPTIONAL: send ACKNOWLEDGE */ /* Turn on the first_time_master_sweep flag */ + CL_PLOCK_EXCL_ACQUIRE(sm->p_lock); sm->p_subn->first_time_master_sweep = TRUE; /* * Turn on the force_heavy_sweep - we want a @@ -374,15 +380,19 @@ ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm, */ sm->p_subn->force_heavy_sweep = TRUE; - sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER; - osm_report_sm_state(sm); /* * Make sure to set the subnet master_sm_base_lid * to the sm_base_lid value */ sm->p_subn->master_sm_base_lid = sm->p_subn->sm_base_lid; + sm->p_subn->coming_out_of_standby = TRUE; + + CL_PLOCK_RELEASE(sm->p_lock); + + sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER; + osm_report_sm_state(sm); osm_sm_signal(sm, OSM_SIGNAL_SWEEP); break; case OSM_SM_SIGNAL_ACKNOWLEDGE: @@ -448,11 +458,13 @@ ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm, /* Force set_client_rereg_on_sweep, we don't know what the other * SM may have configure/done on the fabric. */ + CL_PLOCK_EXCL_ACQUIRE(sm->p_lock); sm->p_subn->set_client_rereg_on_sweep = TRUE; sm->polling_sm_guid = 0; sm->p_subn->first_time_master_sweep = TRUE; sm->p_subn->coming_out_of_standby = TRUE; sm->p_subn->force_heavy_sweep = TRUE; + CL_PLOCK_RELEASE(sm->p_lock); osm_sm_signal(sm, OSM_SIGNAL_SWEEP); break; case OSM_SM_SIGNAL_HANDOVER_SENT: