From patchwork Wed Jun 15 15:26:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6589BCCA473 for ; Wed, 15 Jun 2022 15:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241899AbiFOP3g (ORCPT ); Wed, 15 Jun 2022 11:29:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352232AbiFOP12 (ORCPT ); Wed, 15 Jun 2022 11:27:28 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFA9146651 for ; Wed, 15 Jun 2022 08:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=m1PuB1qtxm4ghj9lajtZ3bMOFp5guBs3P8avzPP57xE=; b=Qma86r0wiyVdYETOfZXZaduzu8 l7lzNEU2x1j+Yc19HIErFd0wtMPrJLYpOJsXZqg+V0dz+a8HtlzbamNcErm7WYwxhU329lEkUO7U0 STWzqbyVwewGaiYqOxIjivrjbIPECeLVSs9n0C8Z0QoBzNYM7ZeAfqPoFqaoaOhPjeNUlAIQapfx9 p3CIvesoZB9tq4jCKj/WFyh7Iocy/lJ8wC2UVmWHUnPil5nlgVQps37Z7XOkEG5t6mBNn2GiaxZYO utgRsfQJrc+0YdlgEEcd04USuGx61CYfqHGKYXfLruODdMD0fsc/RbpSRJVTA1CNQEK3IC2zvVjj0 3D3TMkKcbhh4sUNZWrIhEONwhSF5w7gwZt/PPKmxmB/k4dW1Ll6jTQuXyYAQwV0Okig7hKl1AXIgi 2PlVzz2QE5ZrfR1mcK0Rbw0GpNOCF68EV77WPvUeUSdV2M3FXVg8rsIzCTym/oHZleJw96eCxdw1V fnAgrupUCuBrqx5OqExxb18N; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1UvF-005rt3-Lm; Wed, 15 Jun 2022 15:27:09 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 01/14] rdma/siw: remove superfluous siw_cep_put() from siw_connect() error path Date: Wed, 15 Jun 2022 17:26:39 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The following change demonstrate the bug: --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1507,6 +1507,9 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) if (rv >= 0) { rv = siw_cm_queue_work(cep, SIW_CM_WORK_MPATIMEOUT); if (!rv) { + rv = -ECONNRESET; + msleep_interruptible(100); + goto error; siw_dbg_cep(cep, "[QP %u]: exit\n", qp_id(qp)); siw_cep_set_free(cep); return 0; That change triggers the WARN_ON() in siw_cep_put(). As there's no siw_cep_get() arround id->add_ref() I removed the siw_cep_put() following id->rem_ref(). Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 17f34d584cd9..a8e546670d05 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1495,7 +1495,6 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep->cm_id = NULL; id->rem_ref(id); - siw_cep_put(cep); qp->cep = NULL; siw_cep_put(cep); From patchwork Wed Jun 15 15:26:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 065B3C433EF for ; Wed, 15 Jun 2022 15:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349593AbiFOP2T (ORCPT ); Wed, 15 Jun 2022 11:28:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352845AbiFOP1t (ORCPT ); Wed, 15 Jun 2022 11:27:49 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD196483A1 for ; Wed, 15 Jun 2022 08:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=x/l0VzagZh3qsHeJoVHY5Rfk0xYZjmhFup2+zDP4VNc=; b=JNLuITWWDdWuZSDRJ2yLMgXsKL 9WaTg+fJW3IJ4copvzeVK3CzD/+RX3RvbAk5DgQBWjJbZAdYcRtjbYWwFtRvK4A8Tno+Bksd/cUPI mfcLR3tgOQihQbDkS1kUsGI7ytarOfdEAsBQ6tdbjc90nZYvDI0DqHpYLPZOKnxzYkrr/kxgOVrw6 6/nP1Y6l7eW6TzXPt2xNIgy38HBRCHQyoFLho8WfF/wykcde9HyRhhaZKa9Lem0wKK7qpgs7PmB3h GYuZnYVTDW8BIq0sADVO8O6rtXBBhFEEehmS8Jxs3y0NUf0sfhV34GEExDUr2hpawqFCs8wpcfE1Z IUvcpi8lx1OUEr5mSinPgbJXA7pyFh41InCsxh/1C7HqhT6pifiXrYueLcYXivi1UuPURgEWVmpdR uKCeJid9Svo6OswUDg5q46A4FyLAhHchLQtDCTUm5l4dXeqtAXLDZG+UKAHTvdCKmSZZQVhniBxoc clbDM6pOuTCIBjowZRhm3qqj; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1UvM-005rtC-CE; Wed, 15 Jun 2022 15:27:16 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 02/14] rdma/siw: make siw_cm_upcall() a noop without valid 'id' Date: Wed, 15 Jun 2022 17:26:40 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This will simplify the callers. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index a8e546670d05..eeb366edba2a 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -322,6 +322,9 @@ static int siw_cm_upcall(struct siw_cep *cep, enum iw_cm_event_type reason, } else { id = cep->cm_id; } + if (id == NULL) + return status; + /* Signal IRD and ORD */ if (reason == IW_CM_EVENT_ESTABLISHED || reason == IW_CM_EVENT_CONNECT_REPLY) { From patchwork Wed Jun 15 15:26:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E903C433EF for ; Wed, 15 Jun 2022 15:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349193AbiFOP2S (ORCPT ); Wed, 15 Jun 2022 11:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353642AbiFOP1x (ORCPT ); Wed, 15 Jun 2022 11:27:53 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B8EB3A8 for ; Wed, 15 Jun 2022 08:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=6mxleO61ntnrzTsACZ11U45J7gyAN6fy3NChb7ddr5M=; b=2tzVPyC+Dqc/CtiPiER/+45TWp R3w9YUKggRPBI80DaewsVLFUOjbWw76UMW+7R/9gNJNKsjYDJK4/8gnuw+4JiRLB5Wd/ToaRhmnH9 ZEKH7YRKdiuiATCjSkjLoe8CeXI78DYymhAEYOCkkJlH5pgDGwWdq1pppXH/7j+l3o8vZkj/u72Ki dkXAOlbz4UrsKHKGcAeBikBylOkl6DySCV6ARdSKu1Ak5vPhEL6D7VkPCGV2D1hBaEmeS1onB89AM 5/U+pxq6yefwAX9nuakNCqA2chuwV++mqAc4dKEwWAbSrouID9iBaSDQ2fn8vF49SFzSxc3UG3/Nh nfL6JvMprk7fwdq1XcWmFDAwjSqDPjR67GOeH6Yo29N7MmZ+8Hjdz6TOTqPpk7jq2VUUJ2cU8F05Z 46HwaF8zqqpybiAwhmSfYk4iOhefU3lyT78nYdW8RYKkn+rB/lTyFMxBe7yxndMuFOYKXSayNK+XV nsdb/JRaAhRV3KC42zu1ywbJ; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1UvT-005rtL-AL; Wed, 15 Jun 2022 15:27:23 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 03/14] rdma/siw: split out a __siw_cep_terminate_upcall() function Date: Wed, 15 Jun 2022 17:26:41 +0200 Message-Id: <7c1b2f0b2cabc91c0085f7d04da75cb80dd72ccb.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org There are multiple places where should have the same logic. Having one helper function to be used in all places makes it easier to extended the logic. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 53 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index eeb366edba2a..c5ef5de7e84c 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -103,6 +103,37 @@ static void siw_socket_disassoc(struct socket *s) } } +/* + * The caller needs to deal with siw_cep_set_inuse() + * and siw_cep_set_free() + */ +static void __siw_cep_terminate_upcall(struct siw_cep *cep, + int reply_status) +{ + if (cep->qp && cep->qp->term_info.valid) + siw_send_terminate(cep->qp); + + switch (cep->state) { + case SIW_EPSTATE_AWAIT_MPAREP: + siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY, + reply_status); + break; + + case SIW_EPSTATE_RDMA_MODE: + siw_cm_upcall(cep, IW_CM_EVENT_CLOSE, 0); + break; + + case SIW_EPSTATE_IDLE: + case SIW_EPSTATE_LISTENING: + case SIW_EPSTATE_CONNECTING: + case SIW_EPSTATE_AWAIT_MPAREQ: + case SIW_EPSTATE_RECVD_MPAREQ: + case SIW_EPSTATE_CLOSED: + default: + break; + } +} + static void siw_rtr_data_ready(struct sock *sk) { struct siw_cep *cep; @@ -393,29 +424,9 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule) } siw_dbg_cep(cep, "immediate close, state %d\n", cep->state); - if (qp->term_info.valid) - siw_send_terminate(qp); + __siw_cep_terminate_upcall(cep, -EINVAL); if (cep->cm_id) { - switch (cep->state) { - case SIW_EPSTATE_AWAIT_MPAREP: - siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY, - -EINVAL); - break; - - case SIW_EPSTATE_RDMA_MODE: - siw_cm_upcall(cep, IW_CM_EVENT_CLOSE, 0); - break; - - case SIW_EPSTATE_IDLE: - case SIW_EPSTATE_LISTENING: - case SIW_EPSTATE_CONNECTING: - case SIW_EPSTATE_AWAIT_MPAREQ: - case SIW_EPSTATE_RECVD_MPAREQ: - case SIW_EPSTATE_CLOSED: - default: - break; - } cep->cm_id->rem_ref(cep->cm_id); cep->cm_id = NULL; siw_cep_put(cep); From patchwork Wed Jun 15 15:26:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22AF1C43334 for ; Wed, 15 Jun 2022 15:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234002AbiFOP25 (ORCPT ); Wed, 15 Jun 2022 11:28:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353817AbiFOP17 (ORCPT ); Wed, 15 Jun 2022 11:27:59 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FC4E16595 for ; Wed, 15 Jun 2022 08:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=X4yjjgUauZLNVhdKH977DyeFAC1iEOZ232nEBNxdlo8=; b=GwB+lmuEeKLzHGM+uQKuCH3hWT RhktaHbF+juBMlnbFrWJ0seADYHKkqtOWANeZdvDecYKYDQx76ozDQsCrAfHSxrZgzmyKc8ioZUPk fMU4kdlSLAI9Zs4CHDdXVGSXrNnwn+UgwWvas4ngOIuFkmQfHOWz2FctONr8d8ZCf0Mo/QucgjKew Oo+LAJf0SA+KS9jig89XcVKdc4I3pxJu6tZvtkxCrlC7TpXaAFzWTk5bMdjuu3wXAdmA8Z94OWaBT bTkoIB8cj483A7pjzM3oyRHAcRZvTN2BFMNctst2o+fUPetI4hFSPe92xwOMBY+Uctlz9bufaUwO0 4jzzDHdvhoOjKPlfpoImmt5+c0Jt0RPlYlSMdmQWkLE4SqNxaB5wUUSlgCJEdQYjVF63b5px1vP5R sIzIGZZcniqhqm0PDHq0k+sq7i9i/nugByP0SjhVtG8/Czui3jOUzQrWhV7MSd5+yvcQYTm8cZOQb FHk9eXul6bsj/mpCvYYTx+Hp; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1UvZ-005rtZ-SV; Wed, 15 Jun 2022 15:27:29 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 04/14] rdma/siw: use __siw_cep_terminate_upcall() for indirect SIW_CM_WORK_CLOSE_LLP Date: Wed, 15 Jun 2022 17:26:42 +0200 Message-Id: <8cd3dfb0bee64ca1de4157bc6d7c9b1a9602ac31.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Both code paths from siw_qp_cm_drop() should use the same logic. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index c5ef5de7e84c..4387cdf99cf9 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1070,11 +1070,7 @@ static void siw_cm_work_handler(struct work_struct *w) /* * QP scheduled LLP close */ - if (cep->qp && cep->qp->term_info.valid) - siw_send_terminate(cep->qp); - - if (cep->cm_id) - siw_cm_upcall(cep, IW_CM_EVENT_CLOSE, 0); + __siw_cep_terminate_upcall(cep, -EINVAL); release_cep = 1; break; From patchwork Wed Jun 15 15:26:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16713C43334 for ; Wed, 15 Jun 2022 15:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241794AbiFOP26 (ORCPT ); Wed, 15 Jun 2022 11:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243040AbiFOP2Y (ORCPT ); Wed, 15 Jun 2022 11:28:24 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD45520BDD for ; Wed, 15 Jun 2022 08:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=uhlPF86eIyB2XWzVT6cUueNapFDGhTlydRZCxMCvo9U=; b=TTnRBRTBvcWoK0tpKHn0F6sDTd UTqyLwuI1d2pkDPZLbFrOa2JaI9MF+30IzVUJBX9OTvyqaAbvNjFLpmvlrYU2o9WYs81iDXEsO+fg oimy/rLdoov9814kRn08VRsBP4o3cApJPGEUj/LU1RCqxsTAEk+9CmQeoQQ0R/hm2GEzRyVx9pDPY Zigd2wLwzLU4cGqvsrag1er6193HIqkETZk3YF9AXBMdZ2mJnUBc52u9l3KDfQnhYcbUmK/W+LpeA 8JnAaMHU8N2nwCJsrzYJJ6YS5H1YWKPTrN8ZRvQ2Brf0p+eoFd94q6Zt1pAm4iGgiRmoHF4u45VdL zfgUWVvL3NKjHEjL65CPVGU+s6R09Kr2TzTXo6kBmU9jZ2UW2NDwcMF86EyJXbYujhbMSkJzE8oFF EKUemeoUOm/P7oa1MHYpCvO4dJrBWX2mEGIRAlT/Fn6K46RIF29ydc7mkPxDxwOdtNT2rjySB8a0x HJIdBboGwPcVljbcB/ujrZXL; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1Uvg-005rtq-Ai; Wed, 15 Jun 2022 15:27:36 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 05/14] rdma/siw: use __siw_cep_terminate_upcall() for SIW_CM_WORK_PEER_CLOSE Date: Wed, 15 Jun 2022 17:26:43 +0200 Message-Id: <31498ba0d4fde312d6bdc94072f64e29380bc966.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org It's easier to have generic logic in just one place. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 89 +++++++++++++++++------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 4387cdf99cf9..3160f3fc4ca8 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -110,26 +110,67 @@ static void siw_socket_disassoc(struct socket *s) static void __siw_cep_terminate_upcall(struct siw_cep *cep, int reply_status) { - if (cep->qp && cep->qp->term_info.valid) - siw_send_terminate(cep->qp); + bool suspended = false; + + if (cep->qp) { + struct siw_qp *qp = cep->qp; + + if (qp->term_info.valid) + siw_send_terminate(qp); + + if (qp->rx_stream.rx_suspend || qp->tx_ctx.tx_suspend) + suspended = true; + } else { + suspended = true; + } switch (cep->state) { case SIW_EPSTATE_AWAIT_MPAREP: + /* + * MPA reply not received, but connection drop, + * or timeout. + */ siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY, reply_status); break; case SIW_EPSTATE_RDMA_MODE: + /* + * NOTE: IW_CM_EVENT_DISCONNECT is given just + * to transition IWCM into CLOSING. + */ + WARN(!suspended, "SIW_EPSTATE_RDMA_MODE called without suspended\n"); + siw_cm_upcall(cep, IW_CM_EVENT_DISCONNECT, 0); siw_cm_upcall(cep, IW_CM_EVENT_CLOSE, 0); break; + case SIW_EPSTATE_RECVD_MPAREQ: + /* + * Wait for the ulp/CM to call accept/reject + */ + siw_dbg_cep(cep, "mpa req recvd, wait for ULP\n"); + WARN(!suspended, "SIW_EPSTATE_RECVD_MPAREQ called without suspended\n"); + break; + + case SIW_EPSTATE_AWAIT_MPAREQ: + /* + * Socket close before MPA request received. + */ + siw_dbg_cep(cep, "no mpareq: drop listener\n"); + if (cep->listen_cep) + siw_cep_put(cep->listen_cep); + cep->listen_cep = NULL; + break; + case SIW_EPSTATE_IDLE: case SIW_EPSTATE_LISTENING: case SIW_EPSTATE_CONNECTING: - case SIW_EPSTATE_AWAIT_MPAREQ: - case SIW_EPSTATE_RECVD_MPAREQ: case SIW_EPSTATE_CLOSED: default: + /* + * for other states there is no connection + * known to the IWCM. + */ break; } } @@ -1076,41 +1117,11 @@ static void siw_cm_work_handler(struct work_struct *w) break; case SIW_CM_WORK_PEER_CLOSE: - if (cep->cm_id) { - if (cep->state == SIW_EPSTATE_AWAIT_MPAREP) { - /* - * MPA reply not received, but connection drop - */ - siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY, - -ECONNRESET); - } else if (cep->state == SIW_EPSTATE_RDMA_MODE) { - /* - * NOTE: IW_CM_EVENT_DISCONNECT is given just - * to transition IWCM into CLOSING. - */ - siw_cm_upcall(cep, IW_CM_EVENT_DISCONNECT, 0); - siw_cm_upcall(cep, IW_CM_EVENT_CLOSE, 0); - } - /* - * for other states there is no connection - * known to the IWCM. - */ - } else { - if (cep->state == SIW_EPSTATE_RECVD_MPAREQ) { - /* - * Wait for the ulp/CM to call accept/reject - */ - siw_dbg_cep(cep, - "mpa req recvd, wait for ULP\n"); - } else if (cep->state == SIW_EPSTATE_AWAIT_MPAREQ) { - /* - * Socket close before MPA request received. - */ - siw_dbg_cep(cep, "no mpareq: drop listener\n"); - siw_cep_put(cep->listen_cep); - cep->listen_cep = NULL; - } - } + /* + * Peer closed the connection: TCP_CLOSE* + */ + __siw_cep_terminate_upcall(cep, -ECONNRESET); + release_cep = 1; break; From patchwork Wed Jun 15 15:26:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 263F9CCA473 for ; Wed, 15 Jun 2022 15:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345540AbiFOP26 (ORCPT ); Wed, 15 Jun 2022 11:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355265AbiFOP2h (ORCPT ); Wed, 15 Jun 2022 11:28:37 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48F814F1C7 for ; Wed, 15 Jun 2022 08:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=YhpO3TS14LMHOHwZO8jxbCVr+5Hbr5NLcdR2reS5xI0=; b=sVu08+VQYulrzVz/0J6kc/tidV 8jMQqywzuNXFrV5rx9HPyTQA7MY1+9EDTs1uv+IZav/n/8dnmf38Th53pb7nbp/Lck6IY/DRCKKZR 0UQb6cRs/fRTc9ZISoqMLc2LUrCCYcvF5puq4DHrcsH3ibHVuxD7XCCX7c73yyKcHZIKrnFpjD4Z2 pNvIBgFxOxSG+RLZ82qqkTJhAkmR/rRxl/DBjmn0vCOtFAwpTfYzlIH09FjzN72393myJk9eed+Ic DfzjJlHso51Y+TFoTtPBA8DnwaoES7uIdBcUY04i/P3YTC31CF7pIaqup5GqiI/o0Sz+pzWF2Jyjl M4JMqCQkJGwfQtxo6acadq1+3dEOatC2+jxBCGGVLig671gEmkQA/XlVByH8ANFojGfzb8Juvzxax Z9SitMB0FJ+fKoc3ULS9DvCLbeLSTqew04QxLVugbOltZpS1t9YDP5fbAgaGRzLNT5dGLLyNghgwq VW/04eW2nuNL4TSTuJ3R0wdI; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1Uvn-005ru0-01; Wed, 15 Jun 2022 15:27:43 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 06/14] rdma/siw: use __siw_cep_terminate_upcall() for SIW_CM_WORK_MPATIMEOUT Date: Wed, 15 Jun 2022 17:26:44 +0200 Message-Id: <6854531a411a17e34efb2fe012f45fabd27c7d14.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org It's easier to have generic logic in just one place. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 31 ++++++++---------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 3160f3fc4ca8..56c484f85160 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1126,31 +1126,16 @@ static void siw_cm_work_handler(struct work_struct *w) break; case SIW_CM_WORK_MPATIMEOUT: + /* + * MPA request timed out: + * Hide any partially received private data and signal + * timeout + */ cep->mpa_timer = NULL; + cep->mpa.hdr.params.pd_len = 0; + __siw_cep_terminate_upcall(cep, -ETIMEDOUT); - if (cep->state == SIW_EPSTATE_AWAIT_MPAREP) { - /* - * MPA request timed out: - * Hide any partially received private data and signal - * timeout - */ - cep->mpa.hdr.params.pd_len = 0; - - if (cep->cm_id) - siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY, - -ETIMEDOUT); - release_cep = 1; - - } else if (cep->state == SIW_EPSTATE_AWAIT_MPAREQ) { - /* - * No MPA request received after peer TCP stream setup. - */ - if (cep->listen_cep) { - siw_cep_put(cep->listen_cep); - cep->listen_cep = NULL; - } - release_cep = 1; - } + release_cep = 1; break; default: From patchwork Wed Jun 15 15:26:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B61EACCA480 for ; Wed, 15 Jun 2022 15:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348439AbiFOP3i (ORCPT ); Wed, 15 Jun 2022 11:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355712AbiFOP2l (ORCPT ); Wed, 15 Jun 2022 11:28:41 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE78D4338E for ; Wed, 15 Jun 2022 08:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=K1YBsWTlv3dUju28IUgerHcp1VUDHyN7zkNFBdM0XsI=; b=fsyaotPoeJqLxjPLN6gyv9UhVp z0mFvHDoQkVM1Amu77pVTtk9Sq7RtG0FNdUfEyR9gwM2HVKAdLrFYt05g5+Bm1L6OrHZmxA/46I72 5whVAJdbC03ofFKV7D+tbp62YxmLNLqwbIbrLdMzB1dLgAwLMbqZmNNiL/l4hNAxKLYTZnH1bQ+9c yFexL7mc/AQhMZnRq2+kDXEQ1Zf7DHfbALxSWhPIbZr3P6ZcPPzFIRUBeW2vPFhahp2HtM7GJHU0z DqTZphSdAzKx6mN+eByDK3dWj7D7ZbSgEOldHGkW5Sx3HD4cNXL1DxDrxInI7yb5Q2IR/mm+cTsUv hLSX1zqD17og4ZW9IoDvtmz2kJYra0QOUGvArQJ7LyjNFZn/5iKRZrPw9LRBAX4+Nxgj2flQ8lP7d 0dNokVcaHZmg9oVrLhQNFG383rmrffeVK0M7QwGoAixJMIn1SxpBNLZeyOWK2LHpu3OkdYPxuaAbP fFTFRCfzsI0WqmZxz+mBbMmQ; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1Uvu-005ruG-FQ; Wed, 15 Jun 2022 15:27:50 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 07/14] rdma/siw: handle SIW_EPSTATE_CONNECTING in __siw_cep_terminate_upcall() Date: Wed, 15 Jun 2022 17:26:45 +0200 Message-Id: <4afcaaa2ba7bfe248f12030bd9168c70bbeb0fb2.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The final patch will implement a non-blocking connect, which means SIW_CM_WORK_MPATIMEOUT can also happen during SIW_EPSTATE_CONNECTING. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 56c484f85160..80e1d5b274e7 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -125,6 +125,14 @@ static void __siw_cep_terminate_upcall(struct siw_cep *cep, } switch (cep->state) { + case SIW_EPSTATE_CONNECTING: + /* + * The TCP connect got rejected or timed out. + */ + siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY, + reply_status); + break; + case SIW_EPSTATE_AWAIT_MPAREP: /* * MPA reply not received, but connection drop, @@ -164,7 +172,6 @@ static void __siw_cep_terminate_upcall(struct siw_cep *cep, case SIW_EPSTATE_IDLE: case SIW_EPSTATE_LISTENING: - case SIW_EPSTATE_CONNECTING: case SIW_EPSTATE_CLOSED: default: /* From patchwork Wed Jun 15 15:26:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45740CCA47F for ; Wed, 15 Jun 2022 15:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347511AbiFOP27 (ORCPT ); Wed, 15 Jun 2022 11:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355903AbiFOP2n (ORCPT ); Wed, 15 Jun 2022 11:28:43 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68E35377C1 for ; Wed, 15 Jun 2022 08:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=UW2Q4DKap7dbdm1xz+2zCR+DEnfL3DGRO96gvyc4UDg=; b=2fVIMFsDxBrV9xGhue/cDm27kL s+EnNzaeqTtcdmOOXnpFYknqGCVEBzDW9k1pzC6+r2nmTLA9n8XNSF1b8OtXJjKmXWGoRmBobDT0J 50SQvX07jCDfLwS0xql6lVlko+MFo8qIjRGS5jM7MHJZbebLzs7nx4dWnhcqbXBaHWVYVGLovqgxd lL28EL0PRxby/xAxVxOQSPT9R/H13ZiStUaBJgNeG0WC0UoUTNQBpRvTcuHy/wi1NkG4g2lpTLDEz FDTTgy/Ve7M+kyki9bwMKHwU4A8pq7+jdu1wbYOl/exdsbhVC6+mfCDx6Sui+E0UVGUS/2aX44Sx8 CtWDcqxf3r76IJtKPG+ae4WqHG3OXMVH673P6oReep92SBrR/dG5lpSDhuIzkAFOQnG1rEdqhAlBg J94X6KlRTebJ+l5F4yhTXG4sXTCUL8BC2T8ecIGb+xHuo4hVAmugAoQSzNfZvvxRERRVrGVNd28Av WuO9dORdt5oPErauP8CiDkBY; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1Uw1-005rvT-9s; Wed, 15 Jun 2022 15:27:57 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 08/14] rdma/siw: make use of kernel_{bind,connect,listen}() Date: Wed, 15 Jun 2022 17:26:46 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org That's nicer than dereferencing socket structures. This prepares making rdma_connect()/siw_connect() non-blocking in order to avoid deadlocks in the callers. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 80e1d5b274e7..e8e29ce609b4 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1331,11 +1331,11 @@ static int kernel_bindconnect(struct socket *s, struct sockaddr *laddr, return rv; } - rv = s->ops->bind(s, laddr, size); + rv = kernel_bind(s, laddr, size); if (rv < 0) return rv; - rv = s->ops->connect(s, raddr, size, flags); + rv = kernel_connect(s, raddr, size, flags); return rv < 0 ? rv : 0; } @@ -1800,8 +1800,8 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) if (ipv4_is_zeronet(laddr->sin_addr.s_addr)) s->sk->sk_bound_dev_if = sdev->netdev->ifindex; - rv = s->ops->bind(s, (struct sockaddr *)laddr, - sizeof(struct sockaddr_in)); + rv = kernel_bind(s, (struct sockaddr *)laddr, + sizeof(struct sockaddr_in)); } else { struct sockaddr_in6 *laddr = &to_sockaddr_in6(id->local_addr); @@ -1818,8 +1818,8 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) if (ipv6_addr_any(&laddr->sin6_addr)) s->sk->sk_bound_dev_if = sdev->netdev->ifindex; - rv = s->ops->bind(s, (struct sockaddr *)laddr, - sizeof(struct sockaddr_in6)); + rv = kernel_bind(s, (struct sockaddr *)laddr, + sizeof(struct sockaddr_in6)); } if (rv) { siw_dbg(id->device, "socket bind error: %d\n", rv); @@ -1839,7 +1839,7 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) rv, backlog); goto error; } - rv = s->ops->listen(s, backlog); + rv = kernel_listen(s, backlog); if (rv) { siw_dbg(id->device, "listen error %d\n", rv); goto error; From patchwork Wed Jun 15 15:26:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A2A3CCA481 for ; Wed, 15 Jun 2022 15:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232421AbiFOP3A (ORCPT ); Wed, 15 Jun 2022 11:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356054AbiFOP2o (ORCPT ); Wed, 15 Jun 2022 11:28:44 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4D841627 for ; Wed, 15 Jun 2022 08:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=w617rm3oZUEYJKGoyPrQTxhDUo13rDhgNJvJO7+eoSc=; b=T21IigJT9qYcPyqIPYE7rYhxGO THvKb5TtLkdaAueUtbsj/itoH3DfSDxOhzKhqhSgk+KpQ2iy3/w9esl7E0ZtG3W+mxgbVDRhcmzlV eDs26mmxLJ0EFbZHyK0OK3WR0rLM+YlRVK5D0hVU+ujHeGBvn5xCl2yI5thvrtY2v5m2AZa+lbIeQ 36zuyxXuNvGNwAflT4FGHOTKOf61wSEhqFNaCakUI/kHC8AuZKZFLxeq5soLriuaQ1EV/RQkyWP6Y ONf8frHAIwB7vRYk9/IeXgl8wWNW9Zb9uxqb+WYrAEGnbKrUlvZ08atbsHtSlRLGb2pIFfTDGfzw+ fgxu5EbddF1eN9euUr3i581SXhMf7HqNJY65j5ffck8h9cg3bMYFah0JT6oHXp3YzAulblK9X/Z41 xr8XkM3YPckykYCVxmyhDJQRUxN3dfdA/Ddg+TItE45pMmWkVUddC8VtGqK3iKqPr6jy1yVjrdYwr xFK2x5H9S+tlt3///p1/bPPM; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1Uw7-005rvh-Sj; Wed, 15 Jun 2022 15:28:03 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 09/14] rdma/siw: let siw_connect() set AWAIT_MPAREP before siw_send_mpareqrep() Date: Wed, 15 Jun 2022 17:26:47 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org There's no real change made in this commit, but it makes the follwing commits easier to review. The idea is that we stay in SIW_EPSTATE_CONNECTING as long as we only deal with tcp and not started the MPA negotiation. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index e8e29ce609b4..c980e5035552 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1438,8 +1438,6 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) */ siw_cep_socket_assoc(cep, s); - cep->state = SIW_EPSTATE_AWAIT_MPAREP; - /* * Set MPA Request bits: CRC if required, no MPA Markers, * MPA Rev. according to module parameter 'mpa_version', Key 'Request'. @@ -1482,6 +1480,8 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) } memcpy(cep->mpa.hdr.key, MPA_KEY_REQ, 16); + cep->state = SIW_EPSTATE_AWAIT_MPAREP; + rv = siw_send_mpareqrep(cep, params->private_data, pd_len); /* * Reset private data. From patchwork Wed Jun 15 15:26:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54D07CCA47E for ; Wed, 15 Jun 2022 15:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352845AbiFOP27 (ORCPT ); Wed, 15 Jun 2022 11:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356115AbiFOP2o (ORCPT ); Wed, 15 Jun 2022 11:28:44 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F2B84615B for ; Wed, 15 Jun 2022 08:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=R1jxQQe45vczPRNKdLsSJYVZvPiaBRAQEVVO1On1/ZY=; b=jTqYI7JZ9UMHLomPW+mVEZSmnD q7tORyQl+DzpSWz0BHoms+atXzEL4BwpqejShks9vY31MY0k3q46wouE+Voy6qsV3Gc1jiE/0D6iH isrFMouQ8ZIMfvHhjrTMQitCT/CfpH6MT/RsWFGJPB+rxHAl3gXVz8SClPctvJz8zkKrd55v1C1G0 ad9vHwNUKyigB8lvA4rfo653HdIXeqV7+0RxaUSmQmyxBAvGUdaXdZ9pn5G4bJzHjETO0zj9I0cqb 0MDRkOZHeyBbiSg8anL3WSQo7qO84FrEdCi0AG/6ZfDr4ASDH8W8RC8m9X5X0yf5c6AD90OQiSC2e Co9DM1cM5cdPxvgwn/9G7dQum3T3VFZ8OuQumpiIZeFE+utlUQSjZ66wX9iO+0k4kEJyV/tH3OWkW X+EJl6euCI9loysGekx5JpIGS1+oy1kakX3vj4d42sTw1z0j4Q9dnQ5VYDpjfRd8p+CE/SQeKny17 BAkldcYVqF+Os43C5qPz4zqP; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1UwF-005rvp-3A; Wed, 15 Jun 2022 15:28:11 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 10/14] rdma/siw: create a temporary copy of private data Date: Wed, 15 Jun 2022 17:26:48 +0200 Message-Id: <3f660bd8e98c907cbef88623476b7c24ff2f3635.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The final patch will implement a non-blocking connect, which means that siw_connect() will be split into siw_connect() and siw_connected(). kernel_bindconnect() will be the last action in siw_connect(), while the MPA negotiation is deferred to siw_connected(). We should not rely on the callers private data pointers to be still valid when siw_connected() is called, so we better create a copy. Also note that __siw_cep_dealloc() already calls kfree(cep->mpa.pdata), so we already have the required cleanup when we'll split out siw_connected() and an error will prevent siw_connected() being called at all. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index c980e5035552..307494c6707a 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1480,13 +1480,27 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) } memcpy(cep->mpa.hdr.key, MPA_KEY_REQ, 16); + if (pd_len > 0) { + cep->mpa.pdata = kmemdup(params->private_data, pd_len, GFP_KERNEL); + if (IS_ERR_OR_NULL(cep->mpa.pdata)) { + rv = -ENOMEM; + goto error; + } + cep->mpa.hdr.params.pd_len = pd_len; + } + cep->state = SIW_EPSTATE_AWAIT_MPAREP; - rv = siw_send_mpareqrep(cep, params->private_data, pd_len); + rv = siw_send_mpareqrep(cep, cep->mpa.pdata, + cep->mpa.hdr.params.pd_len); /* * Reset private data. */ - cep->mpa.hdr.params.pd_len = 0; + if (cep->mpa.hdr.params.pd_len) { + cep->mpa.hdr.params.pd_len = 0; + kfree(cep->mpa.pdata); + cep->mpa.pdata = NULL; + } if (rv >= 0) { rv = siw_cm_queue_work(cep, SIW_CM_WORK_MPATIMEOUT); From patchwork Wed Jun 15 15:26:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CF7AC43334 for ; Wed, 15 Jun 2022 15:29:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233084AbiFOP3J (ORCPT ); Wed, 15 Jun 2022 11:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356184AbiFOP2p (ORCPT ); Wed, 15 Jun 2022 11:28:45 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EF1FF51 for ; Wed, 15 Jun 2022 08:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=EklZFP4aFAqi/lEclxMAM1al3UCe/uBglyUeYgxdUa0=; b=j6sPsSbaWYnE6zXWlIdbyZfjVz JE4G2bfNdgonsaCxCHvyNn77O874Rmc47CpxPOHmLPAWzPxuZbHH7sDcdPXwrhOaYDPnsX9Xg3OYu GHWbmnW8en6eFjcfBsFKKJUUpNM2IyJDbFfJAc/XI/Gk3+8hCcesbCC/i2C8KlojKYhV20+WFgTlZ 6ZVi0FZhM/6fWabaGQT5pkTYVqcsyuHcOEWpVwmTqBs7tcvA8yl4dSPajBd3sh/xpWX9XUGGYfSOi DWySIRStqFFELbIaUuBk+ZwqXwT9k/blShHH3fctngYAu2sL+3CL75SyFD2whMxvoQQRrn4JdbeUI 9XulB573oJe0u/fjfjnfPVsRFd4PfMuyufU6MDd4eY+BZxN/XsZ1AcEX8jvJC5g4ebH1xpyMWERF7 9cWrmGfaBx73Ap5ZKIl6mtmJY1HsIuhxldTVVWxBIzQFieBaYN7FyP/kwql8DLueIiRb1JCK9V0PN detUKQ5QL2euU1ySpNM2Ti5B; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1UwM-005rvx-FF; Wed, 15 Jun 2022 15:28:18 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 11/14] rdma/siw: use error and out logic at the end of siw_connect() Date: Wed, 15 Jun 2022 17:26:49 +0200 Message-Id: <5da05688aba3d09db5c46a80915f13729c807245.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This will make the following changes easier. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 307494c6707a..66d90fc77cef 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1502,14 +1502,19 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep->mpa.pdata = NULL; } - if (rv >= 0) { - rv = siw_cm_queue_work(cep, SIW_CM_WORK_MPATIMEOUT); - if (!rv) { - siw_dbg_cep(cep, "[QP %u]: exit\n", qp_id(qp)); - siw_cep_set_free(cep); - return 0; - } + if (rv < 0) { + goto error; + } + + rv = siw_cm_queue_work(cep, SIW_CM_WORK_MPATIMEOUT); + if (rv != 0) { + goto error; } + + siw_dbg_cep(cep, "[QP %u]: exit\n", qp_id(qp)); + siw_cep_set_free(cep); + return 0; + error: siw_dbg(id->device, "failed: %d\n", rv); From patchwork Wed Jun 15 15:26:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B72F1CCA483 for ; Wed, 15 Jun 2022 15:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbiFOP3e (ORCPT ); Wed, 15 Jun 2022 11:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356340AbiFOP2u (ORCPT ); Wed, 15 Jun 2022 11:28:50 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 721004738E for ; Wed, 15 Jun 2022 08:28:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=CEgEmMjNl8BESZVo+q7Rxw8wDkgp80BAxjvFIYVn9yk=; b=sR1ZWktq+O1YG8Hla5LxeVV7F+ ucO//3VHU8HkP8U/e4yCExnT+rAzDU5uCGlBFw8Jl/G+hk1YKgG8cOPyD9DiFzRpsGpGCHIaTl62q Bg7PN0sU+ZYIiWja5atOymBJZZfyLVuzy4s4Zhw/1SZe3cTE0Yz0UMrHoPpUzkM5JbQVKDbrmyx6Q nVMfuePLFiJ3rMBiCfzQHmns5ibAq7TsQNz/BFxK7YhSGdDdkUyZMvhf3mMJBGBj5WDgkcdVPgzfS 16F3ETj12Q6NkFK40EwTrnHVxH7pDk9o2vMC9501R9l0rOSLxnfrR5XmMSCvS0RxlSfaN/fFc+L/x 9l5sLqm4E6Id8nxUru5jT6LR6dsizFPE1u7MareL54kzVEmHOJTQTOQtz6HHnwI8yMceA5MZpGxZj e29K+KO6lLU5g1kpApJQaMYrnqiQBW4IJdcaYsrVyHE9qFiYKZBzcyMI9LEx8fznBl3+RP0E93Cdp R2OfTip1v8LwILzIcRbqrIZ0; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1UwT-005rw5-03; Wed, 15 Jun 2022 15:28:25 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 12/14] rdma/siw: start mpa timer before calling siw_send_mpareqrep() Date: Wed, 15 Jun 2022 17:26:50 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The mpa timer will also span the non-blocking connect in the final patch. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 66d90fc77cef..279f5acf84d1 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1489,6 +1489,11 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep->mpa.hdr.params.pd_len = pd_len; } + rv = siw_cm_queue_work(cep, SIW_CM_WORK_MPATIMEOUT); + if (rv != 0) { + goto error; + } + cep->state = SIW_EPSTATE_AWAIT_MPAREP; rv = siw_send_mpareqrep(cep, cep->mpa.pdata, @@ -1506,11 +1511,6 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) goto error; } - rv = siw_cm_queue_work(cep, SIW_CM_WORK_MPATIMEOUT); - if (rv != 0) { - goto error; - } - siw_dbg_cep(cep, "[QP %u]: exit\n", qp_id(qp)); siw_cep_set_free(cep); return 0; @@ -1519,6 +1519,8 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) siw_dbg(id->device, "failed: %d\n", rv); if (cep) { + siw_cancel_mpatimer(cep); + siw_socket_disassoc(s); sock_release(s); cep->sock = NULL; From patchwork Wed Jun 15 15:26:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63263C433EF for ; Wed, 15 Jun 2022 15:29:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351186AbiFOP3m (ORCPT ); Wed, 15 Jun 2022 11:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356483AbiFOP2w (ORCPT ); Wed, 15 Jun 2022 11:28:52 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A488726CB for ; Wed, 15 Jun 2022 08:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=bIGeRwzwO/EQ7FL6FpVkOJbT4Nin7T0rDTCXLOwdI0c=; b=dJf7fbFiVnof5igGhiwdp/mHoA oaPfoBhjGR6Fu84twgI0kURIYlBjTd/jamqP0sf7sC19qwCrSc8txiXLNplbApXOJXzIvToCsRRXu ZBwBs06GB0RRgl6SQRfyhzfy5DIhB+DlRIt2SXsXsydVzz8OFZNyaDpzwuMoeq0fr/tAy1qoRLXre x0vYaCK2XaDOY8tCH7ZnuHaf12iBIA2yCJyJeNtTyyO8OMJD4WfdsBf+a1elQTz2v2IKI3MrE7P3f hfhVNIftiktq250+EJIdGhzCfb/V8+7uAqkxsDp5SlfgLnVa73EJfpKFhU+BkxWCjL9lpiZUCRUo0 AqyIXQh1GddbcB3rRnB4hI1PrzszgrYlonyPCgxroEdqxfOH636dZJr/5cT4ugGRWHWu+SIPhKT0E a7tp7nI0frVJe6j7LnpZmRSypRGSHfiULE2frO3L4QcrdC1l0SKlv3Mun8gY29Tn8I1Ujpi4gFXkJ BRY24lCA/2Ujr1p01BBpSiEV; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1UwZ-005rwD-Lg; Wed, 15 Jun 2022 15:28:31 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 13/14] rdma/siw: call the blocking kernel_bindconnect() just before siw_send_mpareqrep() Date: Wed, 15 Jun 2022 17:26:51 +0200 Message-Id: <95af035f1608d23f0221c39f5d6278646555e809.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We should build all state before calling kernel_bindconnect(). This will allow us to go async in the final patch. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 279f5acf84d1..74ed2a5a8f47 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1386,18 +1386,6 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) if (rv < 0) goto error; - /* - * NOTE: For simplification, connect() is called in blocking - * mode. Might be reconsidered for async connection setup at - * TCP level. - */ - rv = kernel_bindconnect(s, laddr, raddr, id->afonly); - if (rv != 0) { - siw_dbg_qp(qp, "kernel_bindconnect: error %d\n", rv); - goto error; - } - if (siw_tcp_nagle == false) - tcp_sock_set_nodelay(s->sk); cep = siw_cep_alloc(sdev); if (!cep) { rv = -ENOMEM; @@ -1494,6 +1482,19 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) goto error; } + /* + * NOTE: For simplification, connect() is called in blocking + * mode. Might be reconsidered for async connection setup at + * TCP level. + */ + rv = kernel_bindconnect(s, laddr, raddr, id->afonly); + if (rv != 0) { + siw_dbg_qp(qp, "kernel_bindconnect: error %d\n", rv); + goto error; + } + if (siw_tcp_nagle == false) + tcp_sock_set_nodelay(s->sk); + cep->state = SIW_EPSTATE_AWAIT_MPAREP; rv = siw_send_mpareqrep(cep, cep->mpa.pdata, From patchwork Wed Jun 15 15:26:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12882583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5653ACCA47E for ; Wed, 15 Jun 2022 15:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345181AbiFOP3h (ORCPT ); Wed, 15 Jun 2022 11:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356518AbiFOP2w (ORCPT ); Wed, 15 Jun 2022 11:28:52 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D7EA5F49 for ; Wed, 15 Jun 2022 08:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=FD38N1rEoSNqADxad3fE1dhfLCQObqO1yEbFX66mI9I=; b=MKoUPJBOWDl8wgCASlL0k47fI7 RRfrRQSUpK8/Zi23YPXV6nEHtLC8qBAIEoG3gT5fw5PM1UvyEwvlmftcxL31/DkOngB0V2Ixam0m3 GAkUdrHDPw+7PRg45OGySpPU2ZUdHPtxGXeR8n0TRW6ISqRgV1WfNdjwIrUng7B/7fSSNNjMvPaVZ YBLc2Ix04xv97802rhLvsihbbBj+FG11/hq1yQ7JM5oLGIG9dup3yZrIcfAHalLYcFgBdlbtpNpLT leO5WLFcpDE/a26OLVV9fPd+SFLwfea9f7OjSItdVgexqNCV21Z09yqzmSeVhZMh/MkyJEJtzD7J3 y9+LVFMIecYMSNlLsmyveTR/rFnlI9Kt86BD0qW2jGyKRgk1z4XNtjFvuiVgw6+tMQff+BF/bAyrh Sy0Zikr/CZa7LfTJvqfcJo5731HQrWVdLhWg58cWUFlEPsnlTMZ8pWVpoFQSOpy/WKxW97JRfQCzd wElSqUNCROflv/xAgj4MLt2T; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1o1Uwg-005rwN-2b; Wed, 15 Jun 2022 15:28:38 +0000 From: Stefan Metzmacher To: Bernard Metzler , linux-rdma@vger.kernel.org Cc: Stefan Metzmacher Subject: [PATCH v2 14/14] rdma/siw: implement non-blocking connect. Date: Wed, 15 Jun 2022 17:26:52 +0200 Message-Id: <34d8ab3e8cadd922bc000beda9d567217ebbdbd3.1655305567.git.metze@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This is very important in order to prevent deadlocks. The RDMA application layer expects rdma_connect() to be non-blocking as the completion is handled via RDMA_CM_EVENT_ESTABLISHED and other async events. It's not unlikely to hold a lock during the rdma_connect() call. Without out this a connection attempt to a non-existing/reachable server block until the very long tcp timeout hits. The application layer had no chance to have its own timeout handler as that would just deadlock with the already blocking rdma_connect(). First rdma_connect() holds id_priv->handler_mutex and deadlocks rdma_destroy_id(). And iw_cm_connect() called from within rdma_connect() sets IWCM_F_CONNECT_WAIT during the call to cm_id->device->ops.iw_connect(), siw_connect() in this case. It means that iw_cm_disconnect() and iw_destroy_cm_id() will both deadlock waiting for IWCM_F_CONNECT_WAIT being cleared. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/sw/siw/siw_cm.c | 125 ++++++++++++++++++++++------- drivers/infiniband/sw/siw/siw_cm.h | 1 + 2 files changed, 96 insertions(+), 30 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 74ed2a5a8f47..5b051aaa3fec 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -37,6 +37,7 @@ static void siw_cm_llp_write_space(struct sock *s); static void siw_cm_llp_error_report(struct sock *s); static int siw_cm_upcall(struct siw_cep *cep, enum iw_cm_event_type reason, int status); +static void siw_connected(struct siw_cep *cep); static void siw_sk_assign_cm_upcalls(struct sock *sk) { @@ -1074,6 +1075,10 @@ static void siw_cm_work_handler(struct work_struct *w) siw_accept_newconn(cep); break; + case SIW_CM_WORK_CONNECTED: + siw_connected(cep); + break; + case SIW_CM_WORK_READ_MPAHDR: if (cep->state == SIW_EPSTATE_AWAIT_MPAREQ) { if (cep->listen_cep) { @@ -1239,6 +1244,7 @@ static void siw_cm_llp_data_ready(struct sock *sk) switch (cep->state) { case SIW_EPSTATE_RDMA_MODE: case SIW_EPSTATE_LISTENING: + case SIW_EPSTATE_CONNECTING: break; case SIW_EPSTATE_AWAIT_MPAREQ: @@ -1292,12 +1298,26 @@ static void siw_cm_llp_state_change(struct sock *sk) switch (sk->sk_state) { case TCP_ESTABLISHED: - /* - * handle accepting socket as special case where only - * new connection is possible - */ - siw_cm_queue_work(cep, SIW_CM_WORK_ACCEPT); - break; + if (cep->state == SIW_EPSTATE_CONNECTING) { + /* + * handle accepting socket as special case where only + * new connection is possible + */ + siw_cm_queue_work(cep, SIW_CM_WORK_CONNECTED); + break; + + } else if (cep->state == SIW_EPSTATE_LISTENING) { + /* + * handle accepting socket as special case where only + * new connection is possible + */ + siw_cm_queue_work(cep, SIW_CM_WORK_ACCEPT); + break; + } + siw_dbg_cep(cep, + "unexpected socket state %d with cep state %d\n", + sk->sk_state, cep->state); + fallthrough; case TCP_CLOSE: case TCP_CLOSE_WAIT: @@ -1316,7 +1336,7 @@ static void siw_cm_llp_state_change(struct sock *sk) static int kernel_bindconnect(struct socket *s, struct sockaddr *laddr, struct sockaddr *raddr, bool afonly) { - int rv, flags = 0; + int rv; size_t size = laddr->sa_family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6); @@ -1335,7 +1355,18 @@ static int kernel_bindconnect(struct socket *s, struct sockaddr *laddr, if (rv < 0) return rv; - rv = kernel_connect(s, raddr, size, flags); + /* + * Yes, this is really O_NONBLOCK instead of + * SOCK_NONBLOCK. + * + * __sys_connect_file() passes + * sock->file->f_flags | file_flags to + * sock->ops->connect(). + * + * Also io_connect() from io_uring forces + * file_flags=O_NONBLOCK to __sys_connect_file(). + */ + rv = kernel_connect(s, raddr, size, O_NONBLOCK); return rv < 0 ? rv : 0; } @@ -1482,36 +1513,27 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) goto error; } - /* - * NOTE: For simplification, connect() is called in blocking - * mode. Might be reconsidered for async connection setup at - * TCP level. - */ rv = kernel_bindconnect(s, laddr, raddr, id->afonly); + if (rv == -EINPROGRESS) { + siw_dbg_qp(qp, "kernel_bindconnect: EINPROGRESS\n"); + rv = 0; + } if (rv != 0) { siw_dbg_qp(qp, "kernel_bindconnect: error %d\n", rv); goto error; } - if (siw_tcp_nagle == false) - tcp_sock_set_nodelay(s->sk); - - cep->state = SIW_EPSTATE_AWAIT_MPAREP; - rv = siw_send_mpareqrep(cep, cep->mpa.pdata, - cep->mpa.hdr.params.pd_len); /* - * Reset private data. + * The rest will be done by siw_connected() + * + * siw_cm_llp_state_change() will detect + * TCP_ESTABLISHED and schedules SIW_CM_WORK_CONNECTED, + * which will finally call siw_connected(). + * + * As siw_cm_llp_state_change() handles everything + * siw_cm_llp_data_ready() can be a noop for + * SIW_EPSTATE_CONNECTING. */ - if (cep->mpa.hdr.params.pd_len) { - cep->mpa.hdr.params.pd_len = 0; - kfree(cep->mpa.pdata); - cep->mpa.pdata = NULL; - } - - if (rv < 0) { - goto error; - } - siw_dbg_cep(cep, "[QP %u]: exit\n", qp_id(qp)); siw_cep_set_free(cep); return 0; @@ -1549,6 +1571,49 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) return rv; } +static void siw_connected(struct siw_cep *cep) +{ + struct siw_qp *qp = cep->qp; + struct socket *s = cep->sock; + int rv = -ECONNABORTED; + + /* + * already called with + * siw_cep_set_inuse(cep); + */ + + if (cep->state != SIW_EPSTATE_CONNECTING) + goto error; + + if (siw_tcp_nagle == false) + tcp_sock_set_nodelay(s->sk); + + cep->state = SIW_EPSTATE_AWAIT_MPAREP; + + rv = siw_send_mpareqrep(cep, cep->mpa.pdata, + cep->mpa.hdr.params.pd_len); + /* + * Reset private data. + */ + if (cep->mpa.hdr.params.pd_len) { + cep->mpa.hdr.params.pd_len = 0; + kfree(cep->mpa.pdata); + cep->mpa.pdata = NULL; + } + + if (rv < 0) { + goto error; + } + + siw_dbg_cep(cep, "[QP %u]: exit\n", qp_id(qp)); + return; + +error: + siw_dbg_cep(cep, "[QP %u]: exit, error %d\n", qp_id(qp), rv); + siw_qp_cm_drop(qp, 1); + return; +} + /* * siw_accept - Let SoftiWARP accept an RDMA connection request * diff --git a/drivers/infiniband/sw/siw/siw_cm.h b/drivers/infiniband/sw/siw/siw_cm.h index 8c59cb3e2868..c01bdc8e64ee 100644 --- a/drivers/infiniband/sw/siw/siw_cm.h +++ b/drivers/infiniband/sw/siw/siw_cm.h @@ -76,6 +76,7 @@ struct siw_cep { enum siw_work_type { SIW_CM_WORK_ACCEPT = 1, + SIW_CM_WORK_CONNECTED, SIW_CM_WORK_READ_MPAHDR, SIW_CM_WORK_CLOSE_LLP, /* close socket */ SIW_CM_WORK_PEER_CLOSE, /* socket indicated peer close */