From patchwork Fri Jan 29 23:13:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 8168541 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 97DEF9F96D for ; Fri, 29 Jan 2016 23:14:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D6542039C for ; Fri, 29 Jan 2016 23:14:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9269D20398 for ; Fri, 29 Jan 2016 23:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753591AbcA2XN6 (ORCPT ); Fri, 29 Jan 2016 18:13:58 -0500 Received: from mail-by2on0065.outbound.protection.outlook.com ([207.46.100.65]:36293 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753204AbcA2XN5 (ORCPT ); Fri, 29 Jan 2016 18:13:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Lyk9wGsL5HVIltEiTC+IZOfDl1Ar998NRGp26CtmyuY=; b=H4wVnIFh+BVfKNcZoZQb4w/EGSlWHbRBVCpZzQw5ReYfdnViHMCilKrnUZvSK56EDtl7vnYeloKOB3oi/yDH5dl32QMmSeKWrBlQheelXIJMHuTdW6qN5X5avdPWLuyf69tmdULrrnHAZvrI87nn36oek02esY/etrN2y834CR0= Received: from CY1PR0201CA0030.namprd02.prod.outlook.com (10.163.30.168) by DM2PR02MB303.namprd02.prod.outlook.com (10.141.83.146) with Microsoft SMTP Server (TLS) id 15.1.390.13; Fri, 29 Jan 2016 23:13:55 +0000 Received: from BL2FFO11OLC007.protection.gbl (2a01:111:f400:7c09::192) by CY1PR0201CA0030.outlook.office365.com (2a01:111:e400:58b9::40) with Microsoft SMTP Server (TLS) id 15.1.396.15 via Frontend Transport; Fri, 29 Jan 2016 23:13:55 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.172) smtp.mailfrom=sandisk.com; lst.de; dkim=none (message not signed) header.d=none;lst.de; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.172 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.172; helo=milsmgep11.sandisk.com; Received: from milsmgep11.sandisk.com (63.163.107.172) by BL2FFO11OLC007.mail.protection.outlook.com (10.173.160.142) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Fri, 29 Jan 2016 23:13:54 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com ( [172.22.12.162]) by (Symantec Messaging Gateway) with SMTP id F9.20.29304.232FBA65; Fri, 29 Jan 2016 15:13:54 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.248.2; Fri, 29 Jan 2016 15:13:54 -0800 X-AuditID: ac160a68-f4bff70000007278-ef-56abf2328313 Received: from [10.60.52.49] ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 26.57.02700.132FBA65; Fri, 29 Jan 2016 15:13:53 -0800 (PST) Subject: [PATCH v2 08/22] IB/srpt: Simplify channel state management To: Doug Ledford References: <56ABF16E.7070006@sandisk.com> CC: Christoph Hellwig , Sagi Grimberg , "Alex Estrin" , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <56ABF231.4030308@sandisk.com> Date: Fri, 29 Jan 2016 15:13:53 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56ABF16E.7070006@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRmVeSWpSXmKPExsWyRoxnka7Rp9VhBluns1lcePqdyeLl+Q+s FitXH2WyeHaol8XiRtsDNgdWj8V7XjJ57L7ZwObxbPphJo/3+66yeXzeJBfAGsVlk5Kak1mW WqRvl8CVMXH/QqaCR1IVV9fNZmxg/C/axcjJISFgIrFt4gn2LkYuDiGBTYwSJ9/OZoNwdjBK nFkznw2u6lYbI0RiDqPElV1tzCAJYQEXidPt01hAbBEBNYlNrxaxg9hCAloS5y58ARvLLLCK UWLT1etgCTYBI4lv72eCNfACFZ1YtR/MZhFQlTjx5AsjiC0qECFxuLOLHaJGUOLkzCdgNZwC 2hJLZl8AsjmAhmpKrN+lDxJmFpCX2P52DjPEoXtZJZY9coK4QV3i5JL5TBMYhWchmTQLoXsW ku4FjMyrGMVyM3OKc9NTCwwN9YoT81Iyi7P1kvNzNzGCo4MrYwfj1knmhxgFOBiVeHg9lq0O E2JNLCuuzD3EKMHBrCTCW/cCKMSbklhZlVqUH19UmpNafIhRmoNFSZzXukUtTEggPbEkNTs1 tSC1CCbLxMEp1cB485XV5RtS0UKHw1YG2rxZztH64ZhnckVLt862RMmVbp9mfy/ueaT+WzKc 59eMeO7DASdmWOv3FORtfnzl8lO9zGl1Fzb8uSa38J2J4s7oAOnYmw9DZDN62xNkZBekP5I5 LervaPH54JovfkzZP6zWR5jE3F597NG9xfGrdpis+dl7//Xzdu5NSizFGYmGWsxFxYkAcvCH UooCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPJMWRmVeSWpSXmKPExsXCtZEjRdfw0+owgzMHTCwuPP3OZPHy/AdW i5WrjzJZPDvUy2Jxo+0BmwOrx+I9L5k8dt9sYPN4Nv0wk8f7fVfZPD5vkgtgjeKySUnNySxL LdK3S+DKmLh/IVPBI6mKq+tmMzYw/hftYuTkkBAwkdh2q42xi5GLQ0hgFqPE5+5FbCAJYQEX idPt01hAbBEBNYlNrxaxg9hCAloS5y58YQdpYBZYxSjxe+UHsAY2ASOJb+9ngjXwAhWdWLUf zGYRUJU48eQLI4gtKhAhcbizix2iRlDi5MwnYDWcAtoSS2ZfALOZBdQl/sy7xAxhy0tsfzuH eQIj3ywkLbOQlM1CUraAkXkVo1huZk5xbnpmgaGhXnFiXkpmcbZecn7uJkZwkHJG7mB8OtH8 ECMTB6dUA2OR9vs9030/nVL9nbJVdd4sO72dik8kjN/9Saw52Tb99+GMFV/KRQLb97TM3Xlk L7/Pjfx0sQhdg0l/mU5xGinxmTQtnHfVXlj8oZ30kT+7U9W36XCqmNvUPpWqCg+5M4vpxaH1 1+quJpzVn36BvXTh4UnCac94mPJrj0yb0HzpVRvrt2u3fokosRRnJBpqMRcVJwIARu8r1AIC AAA= X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC007; 1:HYd2qf1AOAKWKOBcC+3OdJfeRahf9yHT7pZnv+PJLwiQRKT73KkTmHK5ff8VDBHaNjmFHlTXVH27gCtXpn87Lfjc6v/76+uQ22Jh3Wqd4EG+7CH9B5QuytfpWLwZY7+xm6KMze3VWuIinfxVazGufH0ElmsOMcF5CjeiqqudUisgzFUXcfh6073Eg9YWiQA5gXaTECgIRLKpkYs9jfwTPepctH8+1/Bl6OAr1xBhREEcO/jyiWFG2xc01xSCGEMmFchiPcbr9sUIUqv9AbpbOSbg7js6jAmYRbZpWXL4KVkTSjny/ffKYsLokhgJEjTKuOJwZjcizbOPjx8AGMX/8kt2ZYavaLZ4GLrLIPTZCG8yHMyOxwHKGH8hzebA4pA15Naja753rlzAbNFoW0WDNy1knO+AzAG6mqFGkPDEZszPrXk9Xntwv6tgyCFpP7US X-Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(23676002)(11100500001)(64126003)(5008740100001)(33656002)(36756003)(1096002)(586003)(1220700001)(4326007)(92566002)(2906002)(50986999)(110136002)(54356999)(87266999)(19580395003)(47776003)(87936001)(80316001)(19580405001)(76176999)(4001350100001)(83506001)(65816999)(50466002)(65956001)(65806001)(2950100001)(230700001)(5001960100002)(229853001)(189998001)(86362001)(106466001)(77096005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR02MB303; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB303; 2:Jp9VIz/KqmJIFRRpJeqM1kPlKIynKjmS2OPIh1yte8QJpCW+gbB0OMn/Ni2qdo6lN7lreCelhNrtNd8dP44T0LLXij81OQ27uPO4gX7aadzxFwsqCBqdDddFoQJXga4OUuuKon9xRh0OqwRU9Z0HrQ==; 3:clAHYOFUaQJmgTADHWf89R0BWz3a1z8ZspmTGXtirv18WLqhv93kKawcjy/lAevdDfi4gPw+Z8iyaLwbJcIg1dfeR2e9wpFnerp5O776k1GJl3zBNmrfmyPSwdGtKGfWl3vby+04Vl7klLOtwkIghfz91KhY8CcS9dFo2phsZHGDyF+sebOGJeEfRLhp14IkRE+amFkWlOdjN1G2TwRdSku4rEnW1n6fMWxukRv0fC8M9zaRmjjB88V5MK7R19v1MQZrZA11PCErpFwABAOrQA==; 25:vEEVMKEhMJi88YwxJny8004Jpw+qqY2Ar8RHipaHg3rbFyQVE46N8iqw+Ty+yvVy4FGNKT+F1czqOCfrvhnymTq2dEUNVpwfUpraCMeH/xCBAsvvdOffrRlkyqFFrPzCLfPgAf1DcCMcv9VbJ6q7pckWJdVUkVVMk5t6xomTIwPQ9Nf/X+ur2Wm1JpUC31MtxweL5JSEeQhmuHuufOtnWjHGPB2TalWqhvivGIlqzmbeu9eZoRQxdSoE2JdGzA9S X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:DM2PR02MB303; X-MS-Office365-Filtering-Correlation-Id: c095f553-4e7e-4bc0-95f0-08d32901dc0d X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB303; 20:QAnUJc++9DkxpgsUVQGEGgtRDo8UsyC4Byk4KT4Ql96jvjFsLiMFfgVWEXNgWCC+XN9cH/EmSqtEhGmWukdzLHcE5Xe3QRghZdSWSCM3GMR2LYbg+yQyn3W9hI8Xzu3iTz9l35HjXkWWoF3qfQWvEU36L1F797Ka7A1nHAr/nskhQ+O8iQ3sZ2zhMClX0725m+2MZSAzlily9T4ln1MQlwX92upknFr7T+O/YY9ogLsGzKIP3i7T81UKsAyz4ucq0aXd6Y5f5h5cBP5BBsujNG1KCk7Uj9Uv0V/OPHpfcvy6UBmYiEVZsI1vtVmx10JRCRGF5+2GFJa8NQuuql/hb1IW0zx63XS/owCKlRPn54Id0j475DXYa+AxuCMP4TJfb9elYnplBSXNJVKPkK4HdEPYeLj006sfX2YZPVk2uuCgSbufdH5H7w1pdFVpfGxR0HO5zReahZjLJEG+oBSejGuatsm3gZ15UQ35Pq6N2fMuro5Ky1zEu9W4kioCDaZ+ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(34787635062028)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(5005006)(13024025)(13017025)(13023025)(8121501046)(13015025)(10201501046)(3002001); SRVR:DM2PR02MB303; BCL:0; PCL:0; RULEID:; SRVR:DM2PR02MB303; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB303; 4:oVYj5AuU4S4LZ47dHszUaULTzVOrCmQPGDnxS2tShVTmU1gsa0X77pUPVcYVnP2hqpALCp4Fz3T8EWDeiDPH/bdJj39hYppU+8S032yCKNWrBteAHsFSvbnItOYo1UFTT67fEMGz4TggXCiNOwCbj1J8jW9C+4oQnGnTgxYfrY2zGxgCQVXQ4zfKpbykldNjvHoc5J40N5wJaCK2eHTw2RWe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NvPb2E+FCWW5PH7w8N5NXF?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB303; 5:6csGnEuwkTviL5txgi+2+SqfoRHtbNVTR/6/oZEbihBmX2KLOE/Qj2S98S0Szmg0RMJHM1M+L1RYrTtkitGOLGQny/cPIhrlHGuFmFCka+vSjQUHzwaznI+R5AGZg+k/LBRkQEVgkXv0VE+WuQjuUQ==; 24:wVqtio73M4ikGG/ZEW6Z0qxET9tB9QpUOpKugVPQeagtFt2/jU0fOLua4ki3dM6sy3LXr4Krf/6gx0h18nflGLRPdWlMHuTSlNxyvY/mtWE=; 20:honSFwC0wk4Uh0Pk2lPi8rmMeRCj4Z218VAQd9kXwmeF1ZHCgT6gWg8C5zryUg2cSrI3mKOd//BgyC4bXYbsBg/NGWwT8CWDhyYqewtCi0YX9gPPLJR3xtJ1gRLCAhR8oOVV40EPC5Hz3m6IjF29+kllXZ5gRil3h3SIrBKnYMvuHoAsl1pGOrz6aQnCVAHF4m7tGGI3bdUgEcaGtB4wviuPGTlAjWMttVVVP9g0Il9xWbfMwGa9htC/gZWvu5v2 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2016 23:13:54.7651 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.172]; Helo=[milsmgep11.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR02MB303 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 The only allowed channel state changes are those that change the channel state into a state with a higher numerical value. This allows to merge the functions srpt_set_ch_state() and srpt_test_and_set_ch_state() into a single function. Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- drivers/infiniband/ulp/srpt/ib_srpt.c | 44 +++++++++++------------------------ 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 64820a2..72f58a7 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -96,37 +96,25 @@ static int srpt_queue_status(struct se_cmd *cmd); static void srpt_recv_done(struct ib_cq *cq, struct ib_wc *wc); static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc); -static enum rdma_ch_state -srpt_set_ch_state(struct srpt_rdma_ch *ch, enum rdma_ch_state new_state) -{ - unsigned long flags; - enum rdma_ch_state prev; - - spin_lock_irqsave(&ch->spinlock, flags); - prev = ch->state; - ch->state = new_state; - spin_unlock_irqrestore(&ch->spinlock, flags); - return prev; -} - -/** - * srpt_test_and_set_ch_state() - Test and set the channel state. - * - * Returns true if and only if the channel state has been set to the new state. +/* + * The only allowed channel state changes are those that change the channel + * state into a state with a higher numerical value. Hence the new > prev test. */ -static bool -srpt_test_and_set_ch_state(struct srpt_rdma_ch *ch, enum rdma_ch_state old, - enum rdma_ch_state new) +static bool srpt_set_ch_state(struct srpt_rdma_ch *ch, enum rdma_ch_state new) { unsigned long flags; enum rdma_ch_state prev; + bool changed = false; spin_lock_irqsave(&ch->spinlock, flags); prev = ch->state; - if (prev == old) + if (new > prev) { ch->state = new; + changed = true; + } spin_unlock_irqrestore(&ch->spinlock, flags); - return prev == old; + + return changed; } /** @@ -199,8 +187,7 @@ static void srpt_qp_event(struct ib_event *event, struct srpt_rdma_ch *ch) ib_cm_notify(ch->cm_id, event->event); break; case IB_EVENT_QP_LAST_WQE_REACHED: - if (srpt_test_and_set_ch_state(ch, CH_DRAINING, - CH_RELEASING)) + if (srpt_set_ch_state(ch, CH_RELEASING)) srpt_release_channel(ch); else pr_debug("%s: state %d - ignored LAST_WQE.\n", @@ -1947,12 +1934,7 @@ static void srpt_drain_channel(struct ib_cm_id *cm_id) spin_lock_irq(&sdev->spinlock); list_for_each_entry(ch, &sdev->rch_list, list) { if (ch->cm_id == cm_id) { - do_reset = srpt_test_and_set_ch_state(ch, - CH_CONNECTING, CH_DRAINING) || - srpt_test_and_set_ch_state(ch, - CH_LIVE, CH_DRAINING) || - srpt_test_and_set_ch_state(ch, - CH_DISCONNECTING, CH_DRAINING); + do_reset = srpt_set_ch_state(ch, CH_DRAINING); break; } } @@ -2353,7 +2335,7 @@ static void srpt_cm_rtu_recv(struct ib_cm_id *cm_id) ch = srpt_find_channel(cm_id->context, cm_id); BUG_ON(!ch); - if (srpt_test_and_set_ch_state(ch, CH_CONNECTING, CH_LIVE)) { + if (srpt_set_ch_state(ch, CH_LIVE)) { struct srpt_recv_ioctx *ioctx, *ioctx_tmp; ret = srpt_ch_qp_rts(ch, ch->qp);