From patchwork Fri Dec 3 23:33:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arlin Davis X-Patchwork-Id: 379301 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 oB3NXFvt012237 for ; Fri, 3 Dec 2010 23:33:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753899Ab0LCXdU (ORCPT ); Fri, 3 Dec 2010 18:33:20 -0500 Received: from mga01.intel.com ([192.55.52.88]:26206 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753748Ab0LCXdU convert rfc822-to-8bit (ORCPT ); Fri, 3 Dec 2010 18:33:20 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 03 Dec 2010 15:33:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,296,1288594800"; d="scan'208";a="864263095" Received: from orsmsx602.amr.corp.intel.com ([10.22.226.211]) by fmsmga001.fm.intel.com with ESMTP; 03 Dec 2010 15:33:19 -0800 Received: from orsmsx506.amr.corp.intel.com ([10.22.226.44]) by orsmsx602.amr.corp.intel.com ([10.22.226.211]) with mapi; Fri, 3 Dec 2010 15:33:18 -0800 From: "Davis, Arlin R" To: linux-rdma , "ofw@lists.openfabrics.org" CC: "Smith, Stan" Date: Fri, 3 Dec 2010 15:33:12 -0800 Subject: [PATCH 2/4] DAPL v2.0: ucm: hold lock when sending ucm msgs to sync timer start with packet send Thread-Topic: [PATCH 2/4] DAPL v2.0: ucm: hold lock when sending ucm msgs to sync timer start with packet send Thread-Index: ActyJdB1zpL8wMt1SpGrifvPhTdQ9QhG2UBwAAAhPyAAAAf+8A== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: BNr1 DPno DgAm ErKK EyFt Gld2 Its2 MCKs Np5A OEy4 SR3R TDbf Uu68 VDb9 VMhF WBFR; 2; bABpAG4AdQB4AC0AcgBkAG0AYQBAAHYAZwBlAHIALgBrAGUAcgBuAGUAbAAuAG8AcgBnADsAbwBmAHcAQABsAGkAcwB0AHMALgBvAHAAZQBuAGYAYQBiAHIAaQBjAHMALgBvAHIAZwA=; Sosha1_v1; 7; {22CEE29A-7957-4779-AF5E-AAC7439CCB91}; YQByAGwAaQBuAC4AcgAuAGQAYQB2AGkAcwBAAGkAbgB0AGUAbAAuAGMAbwBtAA==; Fri, 03 Dec 2010 23:33:12 GMT; WwBQAEEAVABDAEgAIAAyAC8ANABdACAARABBAFAATAAgAHYAMgAuADAAOgAgAHUAYwBtADoAIABoAG8AbABkACAAbABvAGMAawAgAHcAaABlAG4AIABzAGUAbgBkAGkAbgBnACAAdQBjAG0AIABtAHMAZwBzACAAdABvACAAcwB5AG4AYwAgAHQAaQBtAGUAcgAgAHMAdABhAHIAdAAgAHcAaQB0AGgAIABwAGEAYwBrAGUAdAAgAHMAZQBuAGQA x-cr-puzzleid: {22CEE29A-7957-4779-AF5E-AAC7439CCB91} acceptlanguage: en-US MIME-Version: 1.0 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.3 (demeter1.kernel.org [140.211.167.41]); Fri, 03 Dec 2010 23:33:21 +0000 (UTC) diff --git a/dapl/openib_ucm/cm.c b/dapl/openib_ucm/cm.c index 25b3a39..fd3106a 100644 --- a/dapl/openib_ucm/cm.c +++ b/dapl/openib_ucm/cm.c @@ -969,13 +969,15 @@ dapli_cm_connect(DAPL_EP *ep, dp_ib_cm_handle_t cm) return DAT_ERROR(DAT_INVALID_ADDRESS, DAT_INVALID_ADDRESS_UNREACHABLE); } - dapl_os_unlock(&cm->lock); cm->msg.op = htons(DCM_REQ); dapl_os_get_time(&cm->timer); /* reply expected */ if (ucm_send(&cm->hca->ib_trans, &cm->msg, - &cm->msg.p_data, ntohs(cm->msg.p_size))) + &cm->msg.p_data, ntohs(cm->msg.p_size))) { + dapl_os_unlock(&cm->lock); goto bail; + } + dapl_os_unlock(&cm->lock); /* first time through, link EP and CM, put on work queue */ if (!cm->retries) { @@ -1183,7 +1185,6 @@ ud_bail: (DAT_COUNT)ntohs(cm->msg.p_size), (DAT_PVOID *)cm->msg.p_data, (DAT_PVOID *)&xevent); - dapli_cm_free(cm); /* still attached to EP */ } else #endif { @@ -1409,7 +1410,6 @@ static int ucm_reply(dp_ib_cm_handle_t cm) dapl_os_unlock(&cm->lock); #ifdef DAPL_COUNTERS - /* called from check_timers in cm_thread, cm lock held */ if (g_dapl_dbg_type & DAPL_DBG_TYPE_CM_LIST) { dapl_os_unlock(&cm->hca->ib_trans.lock); dapls_print_cm_list(dapl_llist_peek_head(&cm->hca->ia_list_head)); @@ -1437,12 +1437,14 @@ static int ucm_reply(dp_ib_cm_handle_t cm) NULL, 0, cm->sp); return -1; } + dapl_os_get_time(&cm->timer); /* RTU expected */ - dapl_os_unlock(&cm->lock); if (ucm_send(&cm->hca->ib_trans, &cm->msg, cm->p_data, cm->p_size)) { dapl_log(DAPL_DBG_TYPE_ERR," accept ERR: ucm reply send()\n"); + dapl_os_unlock(&cm->lock); return -1; } + dapl_os_unlock(&cm->lock); return 0; } @@ -1545,9 +1547,9 @@ dapli_accept_usr(DAPL_EP *ep, DAPL_CR *cr, DAT_COUNT p_size, DAT_PVOID p_data) dapl_os_memcpy(&cm->msg.saddr.ib.gid[0], &cm->hca->ib_trans.addr.ib.gid, 16); - /* - * UD: deliver p_data with REQ and EST event, keep REQ p_data in - * cm->msg.p_data and save REPLY accept data in cm->p_data for retries + /* + * UD: deliver p_data with REQ and EST event, keep REQ p_data in + * cm->msg.p_data and save REPLY accept data in cm->p_data for retries */ cm->p_size = p_size; dapl_os_memcpy(&cm->p_data, p_data, p_size); @@ -1556,16 +1558,19 @@ dapli_accept_usr(DAPL_EP *ep, DAPL_CR *cr, DAT_COUNT p_size, DAT_PVOID p_data) dapl_ep_link_cm(ep, cm); cm->ep = ep; cm->hca = ia->hca_ptr; - + + /* Send RTU and change state under CM lock */ dapl_os_lock(&cm->lock); - dapl_os_get_time(&cm->timer); /* RTU expected */ cm->state = DCM_RTU_PENDING; - dapl_os_unlock(&cm->lock); - - if (ucm_reply(cm)) { + dapl_os_get_time(&cm->timer); /* RTU expected */ + if (ucm_send(&cm->hca->ib_trans, &cm->msg, cm->p_data, cm->p_size)) { + dapl_log(DAPL_DBG_TYPE_ERR," accept ERR: ucm reply send()\n"); + dapl_os_unlock(&cm->lock); dapl_ep_unlink_cm(ep, cm); goto bail; } + dapl_os_unlock(&cm->lock); + dapl_dbg_log(DAPL_DBG_TYPE_CM, " PASSIVE: accepted!\n"); dapls_thread_signal(&cm->hca->ib_trans.signal); return DAT_SUCCESS;