From patchwork Wed Jan 3 21:39:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10143491 X-Patchwork-Delegate: dledford@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D89960594 for ; Wed, 3 Jan 2018 21:40:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60F6629361 for ; Wed, 3 Jan 2018 21:40:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55AAF2936D; Wed, 3 Jan 2018 21:40:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0844F29361 for ; Wed, 3 Jan 2018 21:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751342AbeACVkC (ORCPT ); Wed, 3 Jan 2018 16:40:02 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:37771 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298AbeACVjq (ORCPT ); Wed, 3 Jan 2018 16:39:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1515015586; x=1546551586; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=7nQ9U5YyLPufFqCIbcTfAbox5hlZCCOcjHVJQlIFlik=; b=Aenb62ojj5S4AuNpnJfzG6xKzRdS4AONdt0PI/PFLk6WzyVjTHvl+va8 Iy5g3p0M2tzFOBr1s1MPvMuDymUisRApqLNgKCJT3mpvkYrj+0atbEZ6e rs3IbI2TZpsVX4Yn5MFB4evZdBeEGoWaMEncai2WJe7cKIERLM/NzV5I6 MN29B/Cbi7OXNO694cxiEy3zaWboksRDMjl4uW8Ewd2VWXDK5vbu2mwED XDgq2eTl0f3YrlBSH9PxmXxkQz/SCAxLTDhFE+oyfvni8kzMzfmDBwRC4 YfmVJl2f3a78k1/cQgjp4NmZTabOS+GpvisWpvHjki4ta9xSaDlmVYC8f Q==; X-IronPort-AV: E=Sophos;i="5.45,504,1508774400"; d="scan'208";a="68160085" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 04 Jan 2018 05:39:42 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Jan 2018 13:35:51 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Jan 2018 13:39:42 -0800 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche Subject: [PATCH 26/28] IB/srpt: Fix a race condition related to wait list processing Date: Wed, 3 Jan 2018 13:39:36 -0800 Message-Id: <20180103213938.11664-27-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180103213938.11664-1-bart.vanassche@wdc.com> References: <20180103213938.11664-1-bart.vanassche@wdc.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Wait list processing only occurs if the channel state >= CH_LIVE. Hence set the channel state to CH_LIVE before triggering wait list processing asynchronously. Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srpt/ib_srpt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index e222794ec1aa..a509e0d0df0b 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -2300,18 +2300,20 @@ static void srpt_cm_rtu_recv(struct srpt_rdma_ch *ch) return; } - /* Trigger wait list processing. */ - ret = srpt_zerolength_write(ch); - WARN_ONCE(ret < 0, "%d\n", ret); - /* * Note: calling srpt_close_ch() if the transition to the LIVE state * fails is not necessary since that means that that function has * already been invoked from another thread. */ - if (!srpt_set_ch_state(ch, CH_LIVE)) + if (!srpt_set_ch_state(ch, CH_LIVE)) { pr_err("%s-%d: channel transition to LIVE state failed\n", ch->sess_name, ch->qp->qp_num); + return; + } + + /* Trigger wait list processing. */ + ret = srpt_zerolength_write(ch); + WARN_ONCE(ret < 0, "%d\n", ret); } /*