From patchwork Wed Jul 4 00:25:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Foraker X-Patchwork-Id: 1153651 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 B39163FE80 for ; Wed, 4 Jul 2012 00:26:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756675Ab2GDA0K (ORCPT ); Tue, 3 Jul 2012 20:26:10 -0400 Received: from nspiron-1.llnl.gov ([128.115.41.81]:9213 "EHLO nspiron-1.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753661Ab2GDA0K (ORCPT ); Tue, 3 Jul 2012 20:26:10 -0400 X-Attachments: Received: from auk75.llnl.gov ([10.253.135.81]) by nspiron-1.llnl.gov with ESMTP; 03 Jul 2012 17:26:09 -0700 From: Jim Foraker To: linux-rdma@vger.kernel.org Cc: alexne@mellanox.com, weiny2@llnl.gov, Jim Foraker Subject: [PATCH V1.1 3/8] Add locking where necessary around osm_req_* Date: Tue, 3 Jul 2012 17:25:48 -0700 Message-Id: <1341361548-30229-2-git-send-email-foraker1@llnl.gov> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <1341361548-30229-1-git-send-email-foraker1@llnl.gov> References: <1341361508.5218.148.camel@auk75.llnl.gov> <1341361548-30229-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 a7ff017..f8e56d2 100644 --- a/opensm/osm_perfmgr.c +++ b/opensm/osm_perfmgr.c @@ -610,8 +610,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: " @@ -642,9 +644,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: " @@ -704,8 +708,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 74114af..e276a64 100644 --- a/opensm/osm_state_mgr.c +++ b/opensm/osm_state_mgr.c @@ -239,8 +239,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", @@ -432,8 +434,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", @@ -461,10 +465,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: " @@ -811,10 +817,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 e90ad5e..90cb673 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,