From patchwork Wed Aug 1 14:52:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Foraker X-Patchwork-Id: 1264531 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7B7D23FC23 for ; Wed, 1 Aug 2012 14:52:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755214Ab2HAOw5 (ORCPT ); Wed, 1 Aug 2012 10:52:57 -0400 Received: from nspiron-1.llnl.gov ([128.115.41.81]:57070 "EHLO nspiron-1.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754992Ab2HAOw4 (ORCPT ); Wed, 1 Aug 2012 10:52:56 -0400 X-Attachments: Received: from auk75.llnl.gov ([10.253.135.81]) by nspiron-1.llnl.gov with ESMTP; 01 Aug 2012 07:52:54 -0700 From: Jim Foraker To: linux-rdma@vger.kernel.org Cc: weiny2@llnl.gov, alexne@meallanox.com, Jim Foraker Subject: [PATCH 3/9 v2] opensm: Add locking where necessary around osm_req_* Date: Wed, 1 Aug 2012 07:52:29 -0700 Message-Id: <1343832755-26753-3-git-send-email-foraker1@llnl.gov> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <1343832755-26753-1-git-send-email-foraker1@llnl.gov> References: <1343832537.26423.8.camel@auk75.llnl.gov> <1343832755-26753-1-git-send-email-foraker1@llnl.gov> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Grabs plock for reading in the places where one did not already exist when osm_req_get/osm_req_set are called. Signed-off-by: Jim Foraker --- opensm/osm_perfmgr.c | 6 ++++++ opensm/osm_sm_state_mgr.c | 2 ++ opensm/osm_state_mgr.c | 8 ++++++++ opensm/osm_trap_rcv.c | 6 +++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/opensm/osm_perfmgr.c b/opensm/osm_perfmgr.c index 9083ea9..3b36ef6 100644 --- a/opensm/osm_perfmgr.c +++ b/opensm/osm_perfmgr.c @@ -622,8 +622,10 @@ static int sweep_hop_1(osm_sm_t * sm) path_array[1] = port_num; osm_dr_path_init(&hop_1_path, 1, path_array); + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_get(sm, &hop_1_path, IB_MAD_ATTR_NODE_INFO, 0, CL_DISP_MSGID_NONE, &context); + CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4C82: " @@ -654,9 +656,11 @@ static int sweep_hop_1(osm_sm_t * sm) path_array[1] = port_num; osm_dr_path_init(&hop_1_path, 1, path_array); + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_get(sm, &hop_1_path, IB_MAD_ATTR_NODE_INFO, 0, CL_DISP_MSGID_NONE, &context); + CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4C84: " @@ -716,8 +720,10 @@ static int sweep_hop_0(osm_sm_t * sm) } osm_dr_path_init(&dr_path, 0, path_array); + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_get(sm, &dr_path, IB_MAD_ATTR_NODE_INFO, 0, CL_DISP_MSGID_NONE, NULL); + CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) OSM_LOG(sm->p_log, OSM_LOG_ERROR, diff --git a/opensm/osm_sm_state_mgr.c b/opensm/osm_sm_state_mgr.c index e826f1f..061a0f2 100644 --- a/opensm/osm_sm_state_mgr.c +++ b/opensm/osm_sm_state_mgr.c @@ -109,9 +109,11 @@ static void sm_state_mgr_send_master_sm_info_req(osm_sm_t * sm) context.smi_context.port_guid = p_port->guid; context.smi_context.set_method = FALSE; + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_port->p_physp), IB_MAD_ATTR_SM_INFO, 0, CL_DISP_MSGID_NONE, &context); + CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3204: " diff --git a/opensm/osm_state_mgr.c b/opensm/osm_state_mgr.c index d9563ee..63f7347 100644 --- a/opensm/osm_state_mgr.c +++ b/opensm/osm_state_mgr.c @@ -240,8 +240,10 @@ static ib_api_status_t state_mgr_sweep_hop_0(IN osm_sm_t * sm) CL_PLOCK_RELEASE(sm->p_lock); osm_dr_path_init(&dr_path, 0, path_array); + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_get(sm, &dr_path, IB_MAD_ATTR_NODE_INFO, 0, CL_DISP_MSGID_NONE, NULL); + CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3305: " "Request for NodeInfo failed (%s)\n", @@ -433,8 +435,10 @@ static ib_api_status_t state_mgr_sweep_hop_1(IN osm_sm_t * sm) path_array[1] = port_num; osm_dr_path_init(&hop_1_path, 1, path_array); + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_get(sm, &hop_1_path, IB_MAD_ATTR_NODE_INFO, 0, CL_DISP_MSGID_NONE, &context); + CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3311: " "Request for NodeInfo failed (%s)\n", @@ -462,10 +466,12 @@ static ib_api_status_t state_mgr_sweep_hop_1(IN osm_sm_t * sm) path_array[1] = port_num; osm_dr_path_init(&hop_1_path, 1, path_array); + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_get(sm, &hop_1_path, IB_MAD_ATTR_NODE_INFO, 0, CL_DISP_MSGID_NONE, &context); + CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3312: " @@ -812,10 +818,12 @@ static void state_mgr_send_handover(IN osm_sm_t * sm, IN osm_remote_sm_t * p_sm) p_smi->sm_key = 0; } + CL_PLOCK_ACQUIRE(sm->p_lock); status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p_port->p_physp), payload, sizeof(payload), IB_MAD_ATTR_SM_INFO, IB_SMINFO_ATTR_MOD_HANDOVER, CL_DISP_MSGID_NONE, &context); + CL_PLOCK_RELEASE(sm->p_lock); if (status != IB_SUCCESS) OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3317: " diff --git a/opensm/osm_trap_rcv.c b/opensm/osm_trap_rcv.c index 89caa39..4a59cfe 100644 --- a/opensm/osm_trap_rcv.c +++ b/opensm/osm_trap_rcv.c @@ -213,6 +213,7 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p) uint8_t payload[IB_SMP_DATA_SIZE]; osm_madw_context_t context; ib_port_info_t *pi = (ib_port_info_t *)payload; + ib_api_status_t status; /* select the nearest port to master opensm */ if (p->p_remote_physp && @@ -235,10 +236,13 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p) context.pi_context.light_sweep = FALSE; context.pi_context.active_transition = FALSE; - return osm_req_set(sm, osm_physp_get_dr_path_ptr(p), + CL_PLOCK_ACQUIRE(sm->p_lock); + status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p), payload, sizeof(payload), IB_MAD_ATTR_PORT_INFO, cl_hton32(osm_physp_get_port_num(p)), CL_DISP_MSGID_NONE, &context); + CL_PLOCK_RELEASE(sm->p_lock); + return status; } static void log_trap_info(osm_log_t *p_log, ib_mad_notice_attr_t *p_ntci,