From patchwork Thu May 6 23:36:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 354ABC433ED for ; Thu, 6 May 2021 23:37:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EE4961164 for ; Thu, 6 May 2021 23:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232578AbhEFXiU (ORCPT ); Thu, 6 May 2021 19:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbhEFXiT (ORCPT ); Thu, 6 May 2021 19:38:19 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2D6CC061574 for ; Thu, 6 May 2021 16:37:19 -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=l5TAd/20QZ8OSJ+6jWJNzrr1+IYZ42ZUw0bVB2P7asY=; b=Pv6xo1zrOOa6LfTpR4vACUmVny 5mhuUgxz1sCax6om6GflbKcebXsLRAuOFFK4bCCSRlwuS4LQhBk92PjtVYLLOdPG5DYN9cg2csJP4 QnZ++tcAKZp6AP+x91nhOKcXFOBAic4dxRbSXa7N2VQcSU5gX9C8ZkU39CScqI7Ry+A1e7EK1xz1o lz0Us1Xql5oWDn3mU3VCqFH7dIjmxirHki61kU6mMTViL2fdU1LjdnE2wO2PqnsaFWZ1lha/0ZV0q HeYO6J9YnUCQhtu5+XsIN5OfXqES/zGPm/bm39q1XlrEYMx40rRiILxxPpJ80c7ID7lTSR8YKTklW mlhZ2bLtCQwGb48YToHTZDhx3rtMXsTCLanv2EqE/05QWHxCzvuADz9Ky0/anPsOkKbwyOMWNDwl+ fpOY9zIl9mkWGAwTHTxDC+USY3MUxng0TMMNB9/4vvEuqIwWTVah3bW9wySrRh1HYSNpmHgViAVtl PLdYk5N9Mchy7Sg8y8qff0bg; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenYD-0004ID-Tb; Thu, 06 May 2021 23:37:01 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 01/31] rdma/siw: fix warning in siw_proc_send() Date: Fri, 7 May 2021 01:36:07 +0200 Message-Id: <1aa26782ef60cc69aa49886a4c478fbbf74a186e.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org CC [M] drivers/infiniband/sw/siw/siw_qp_rx.o In file included from ./include/linux/wait.h:9:0, from ./include/linux/net.h:19, from drivers/infiniband/sw/siw/siw_qp_rx.c:8: drivers/infiniband/sw/siw/siw_qp_rx.c: In function ‘siw_proc_send’: ./include/linux/spinlock.h:288:3: warning: ‘flags’ may be used uninitialized in this function [-Wmaybe-uninitialized] _raw_spin_unlock_irqrestore(lock, flags); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/infiniband/sw/siw/siw_qp_rx.c:335:16: note: ‘flags’ was declared here unsigned long flags; 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_qp_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c index 60116f20653c..0170c05d2cc3 100644 --- a/drivers/infiniband/sw/siw/siw_qp_rx.c +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c @@ -333,7 +333,7 @@ static struct siw_wqe *siw_rqe_get(struct siw_qp *qp) struct siw_srq *srq; struct siw_wqe *wqe = NULL; bool srq_event = false; - unsigned long flags; + unsigned long flags = 0; srq = qp->srq; if (srq) { From patchwork Thu May 6 23:36:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48876C433ED for ; Thu, 6 May 2021 23:37:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F199610FB for ; Thu, 6 May 2021 23:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230387AbhEFXiN (ORCPT ); Thu, 6 May 2021 19:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232466AbhEFXiM (ORCPT ); Thu, 6 May 2021 19:38:12 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2D1C061574 for ; Thu, 6 May 2021 16:37:13 -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=y26Xj1XG2gca4jDBkijfpjPGS784fVXX09iFUz+bJbg=; b=noRlAoeiy/PCKExiPjsoaUFqwr Yy+NcpnTUaPdYagry8GnBlklDTGlbHVmq43NvMhMQTUxOoixAs88EMvfNxiuPro0dV8PgSa9JW1oC 7uDydx59NSJDLRDx2q+F+Ceso/a7pFfMvKax9WmmryktCj6qhhkmPH3srV5LTToXO/PAmQwhi/n9i QhsZxu8pmxKc0qBV+yaUc+h7IYST5UzRQmywFWPSNa7PeX29IJKcx+9zP1Cqdq30oEzzqPFQKXrgp 5KaP1jpt0B0qVPacFbXV3Ku8GLrXnxRbUb5SE7WM6SgxkMEulTIwApWc2HU3B7eTECsxolWPf1JSq YsyunE7U+g5PFY0HyYBlUZ8sbXr/nDoHVzSFARLT0s2UXQAnrRGM2P7QDvZtZBE+8t9Vz3HFaeyre BnaDQRzlPGCuR/WFFJKDZi3FznZ8qP+Z+5+uV3LP6+QoajsqH7nc+VHnwVkHbWwD1whyLm3Gcbtuh n/INrwC0dLl3lQ6KTau0Zr3/; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenYK-0004IL-PF; Thu, 06 May 2021 23:37:08 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 02/31] rdma/siw: call smp_mb() after mem->stag_valid = 0 in siw_invalidate_stag() too Date: Fri, 7 May 2021 01:36:08 +0200 Message-Id: <04384dc3dd5396ae770aebf5434810f489605c63.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We already do the same in siw_mr_drop_mem(). Fixes: 2251334dcac9 ("rdma/siw: application buffer management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org Reviewed-by: Bernard Metzler --- drivers/infiniband/sw/siw/siw_mem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/sw/siw/siw_mem.c b/drivers/infiniband/sw/siw/siw_mem.c index 61c17db70d65..8596ce1ef5a3 100644 --- a/drivers/infiniband/sw/siw/siw_mem.c +++ b/drivers/infiniband/sw/siw/siw_mem.c @@ -309,6 +309,8 @@ int siw_invalidate_stag(struct ib_pd *pd, u32 stag) * state if invalidation is requested. So no state check here. */ mem->stag_valid = 0; + /* make STag invalid visible asap */ + smp_mb(); siw_dbg_pd(pd, "STag 0x%08x now invalid\n", stag); out: From patchwork Thu May 6 23:36:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6250C433B4 for ; Thu, 6 May 2021 23:37:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6C2661164 for ; Thu, 6 May 2021 23:37:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232466AbhEFXiT (ORCPT ); Thu, 6 May 2021 19:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232578AbhEFXiR (ORCPT ); Thu, 6 May 2021 19:38:17 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 827D0C061761 for ; Thu, 6 May 2021 16:37:17 -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=ubyzdjgArwbl4wlyloJfQHZi7RLBbfptfNOQg3lc/+M=; b=pcux5lkKe25AvO7tzAdqbXHhzS pwMicnijMT1FNPmoaZTS9qptzhKTGRZseDdO7+3OEQTa0wzsjNrsBV6YgByTAJ02ck+dksQrBgvdS mZERa57JCWkcT4GqPwLiebovgxJJD2KQ+jkawaUH/XMgyYNAiljndnPMcah2XuX3NcVH1BItXpzHt Ap/EIKY2M2zRiE+FrKnAP+lsLrJKybkNk8u5LjJrAENSxfHbZhy3ExA8MSWSjMgfXNTEIu7I+KWJ2 jWKOUFw5udrEeOmX6jal1KyYiOjwIuRiD6Rq9rmL+RI1nx8cHLM/yoiMMx7tAtX/JDp47a6O5DCEM p7I9WQqHGzYmWswQvx9g+0DIn91vF7iqWPvVbLdIegiIE5oJnq4q4IvNli/zsp95zWHZLrFi3A5TA W2RKYWu4tUA99V3uFZNmhZhAQFTQxsDAjIJI2DXN5oeStU+tGVnV1c11jd5cbdSYOtvBWRimQjlAk l/VK6QBO39j+sj8XglZO7jXi; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenYR-0004Ib-LG; Thu, 06 May 2021 23:37:15 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 03/31] rdma/siw: remove superfluous siw_cep_put() from siw_connect() error path Date: Fri, 7 May 2021 01:36:09 +0200 Message-Id: <66dd3e80886db4a9fe1795ecd906330255923625.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.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 Reviewed-by: Bernard Metzler --- 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 7a5ed86ffc9f..da84686a21fd 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1494,7 +1494,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 Thu May 6 23:36:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34305C433B4 for ; Thu, 6 May 2021 23:37:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1591D610FB for ; Thu, 6 May 2021 23:37:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232696AbhEFXiX (ORCPT ); Thu, 6 May 2021 19:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbhEFXiW (ORCPT ); Thu, 6 May 2021 19:38:22 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E73CFC061574 for ; Thu, 6 May 2021 16:37:23 -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=OXSE4EbkQdJLLrNmd52YoLQxbyDtmOHKK06g1ZuDyKk=; b=1fJ+tIrWjGTw2RXiOtK+i1VJgr 75TeaQ88PFrS23LJ6gzn7bOsv57ZXp5MgEPW28uJgWth5oLzdVBS9Kl3tqgPViB/C8FxeoePULwsK P3V9ow6tVRy790q1tM47geh5dd8sOow1dmf8VgQL1CgV8tJSoqBlCF0xaMbtd8Kv7GWdB/08DepG8 udgCRos8X5YyN02KAI1FTp4zq7pcf7P+fnPucXsRt6Je62VYkaw7mbLoS8/uwmP5X0g6X89HK7t0q d6wax2VrecnUmRFfFS9yV/MY0LwdkHfcvfGP8NWSzS5HP4yEsUhGOuUxGYeF34SUY5Xi7279cyhBy +ltCLc80onbgUYj5ElcBW2h5RAUSXeul9Wzhe0vJShx59UTJWABbWhZvR/zcIQjryfVHADAVePkm2 Gbp9RlIY5K51V7HG9tf3FkQ5wOcPMB4dg8PqP1sD9tvIgprD2XZqIAuwV2aWOchMAbKZp1/Z04NkO 3MfmTnOmG7uwnTdNio13GzI5; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenYY-0004Iy-2f; Thu, 06 May 2021 23:37:22 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 04/31] rdma/siw: let siw_accept() deferr RDMA_MODE until EVENT_ESTABLISHED Date: Fri, 7 May 2021 01:36:10 +0200 Message-Id: <4d26a4cfd96bfcb3fe0362a37d595608b09ddd91.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org If we receive an TCP FIN before sending the MPA response we'll get an error and posted IW_CM_EVENT_CLOSE. But the IWCM layer didn't receive IW_CM_EVENT_ESTABLISHED yet and doesn't expect IW_CM_EVENT_CLOSE. Instead it expects IW_CM_EVENT_CONNECT_REPLY. If we stay in SIW_EPSTATE_RECVD_MPAREQ until we posted IW_CM_EVENT_ESTABLISHED __siw_cep_terminate_upcall() will use IW_CM_EVENT_CONNECT_REPLY. This can be triggered by the following change on the client: --- 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; Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org Reviewed-by: Bernard Metzler --- drivers/infiniband/sw/siw/siw_cm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index da84686a21fd..145ab6e4e0ed 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -129,8 +129,10 @@ static void siw_rtr_data_ready(struct sock *sk) * Failed data processing would have already scheduled * connection drop. */ - if (!qp->rx_stream.rx_suspend) + if (!qp->rx_stream.rx_suspend) { siw_cm_upcall(cep, IW_CM_EVENT_ESTABLISHED, 0); + cep->state = SIW_EPSTATE_RDMA_MODE; + } out: read_unlock(&sk->sk_callback_lock); if (qp) @@ -1656,8 +1658,6 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) /* siw_qp_get(qp) already done by QP lookup */ cep->qp = qp; - cep->state = SIW_EPSTATE_RDMA_MODE; - /* Move socket RX/TX under QP control */ rv = siw_qp_modify(qp, &qp_attrs, SIW_QP_ATTR_STATE | SIW_QP_ATTR_LLP_HANDLE | @@ -1683,6 +1683,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) rv = siw_cm_upcall(cep, IW_CM_EVENT_ESTABLISHED, 0); if (rv) goto error; + cep->state = SIW_EPSTATE_RDMA_MODE; } siw_cep_set_free(cep); From patchwork Thu May 6 23:36:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E53AFC433ED for ; Thu, 6 May 2021 23:37:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4362610FB for ; Thu, 6 May 2021 23:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232729AbhEFXi3 (ORCPT ); Thu, 6 May 2021 19:38:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbhEFXi3 (ORCPT ); Thu, 6 May 2021 19:38:29 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74023C061574 for ; Thu, 6 May 2021 16:37:30 -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=g/v6Hu7Oi75FF+jmhYv0O9TT5+vFAPxZiZNDiqqWYqs=; b=asWRxJxlvmxTwIRENB4sYDv7JD 1+o1DDZPAf7riXnfPEuI757Vlm8BPh4eGyYnLcTxrIlOGreykcSFlQvZ1hgfq12PvuCsR+cx4NnD0 8uTTOl5+Yfe19NHZJrC8Xvox8+HrQdLcyWy6fBMZXjKjF2QhKY3NkC9AY+z6x0wfDvArB8J7nvRWq awkcfKsn466f0Y2V4BoorkG9MZQrjJHOK5XQMFttRf8h6qo+JkSy4mMjS2VNtHduU2fdIyCAKGyq2 i+eORklyXVsuKCdgip8FQotTPnq2juLap1JO08jWlNS+W47cYltQD0wYmUgMcsoAkF2iYZDcDJeDk +d/1jH8gFc1F2eJj186WntAvw+F9g+k6oNAPHnX7MN+jdBa/tYH4RtXE4ySjpFZy2gLTkpa0Da8Mb odzENG4JfWgsIuIx6L1WYxEDiaEvqLqasL/X3kFP8aRfD2L+Ou3kxGu4chy5sgigMAbu6HwKhDtkX udi2cTtoktvCYGiyKL7lnLN7; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenYe-0004JB-Ii; Thu, 06 May 2021 23:37:28 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 05/31] rdma/siw: make use of kernel_{bind,connect,listen}() Date: Fri, 7 May 2021 01:36:11 +0200 Message-Id: X-Mailer: git-send-email 2.25.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 Reviewed-by: Bernard Metzler --- 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 145ab6e4e0ed..e21cde84306e 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1319,11 +1319,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; } @@ -1787,8 +1787,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); @@ -1805,8 +1805,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); @@ -1826,7 +1826,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 Thu May 6 23:36:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCC83C433B4 for ; Thu, 6 May 2021 23:37:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF43C61164 for ; Thu, 6 May 2021 23:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232753AbhEFXig (ORCPT ); Thu, 6 May 2021 19:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbhEFXig (ORCPT ); Thu, 6 May 2021 19:38:36 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB923C061574 for ; Thu, 6 May 2021 16:37:36 -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=EttQSPx9qFq19Vtxe3NdZwcx7Qs093v7/weRoUUFNU4=; b=rEB0e+35SWfDhFzNVWTXPp+HZW rraYPY30fcbctlb4D5Cv/TnT1pgxFVuqGxagftClO1GqV8GGjw/8lWBdRcEZo8hMc8CDUiwdfVRF9 LZRAfnKFKKW5AM8Q8BAtZKV8cfz71dpdoj+/dxMykiSCVHOyrEM/bvZnN5vDcsdvxVYgdC+Yh8iyN 7SropswS2LxVHq3PR7lrL46kkbcP7XWZVw3jH4aOmKSDidhDzP8FhZVXPecjMA0uwB0UypBvXO1mC tf7j1QR9QMiLoEsvtMEg1+Z9WNc4FM2NciPOfO9Pj6VJtx6gH9+/tEBHQl3rpJKcH0e6JVRgToiva tognghL1bPK7PmseN4B6dUHVzXwKzzvXPTw0C+RlTNfYRc8Do2/LuUNHvNYvhAPoSUVa/ZzRGDEct hGwTak5rLF+PZRC07/YolUTGpjzJLnuNwz2+NahEjIB6VkE0i5+/4xB+9OEN69WNKVX/G0lD+kDTz PGn96m90oZu2qJJhCbqCyc38; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenYk-0004JO-VB; Thu, 06 May 2021 23:37:35 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 06/31] rdma/siw: make siw_cm_upcall() a noop without valid 'id' Date: Fri, 7 May 2021 01:36:12 +0200 Message-Id: <3a85c3d589b8fd86193c871c84ae4c4e0a60bf4a.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.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 e21cde84306e..2cc2863bd427 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -324,6 +324,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 Thu May 6 23:36:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0729BC433B4 for ; Thu, 6 May 2021 23:37:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5FBB610FB for ; Thu, 6 May 2021 23:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232764AbhEFXio (ORCPT ); Thu, 6 May 2021 19:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbhEFXim (ORCPT ); Thu, 6 May 2021 19:38:42 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80452C061574 for ; Thu, 6 May 2021 16:37:43 -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=i6YFyx6pmnhV20spuCC88gFr4SLp3rkIU6d9LlynQF0=; b=OfVLs3kNyc3UACC6MaKV991rNj 7yeyzQnYKQnLV0ija9vUbDQQH23gSGNJ8xLf+EO5Wwon8E9yetCeT0t/ozsxHQaAtnZBkzg4zmv7h DoGULdPw1VnKTBYswfcLgAcaUREFtJ1cBEsqP8/eKd070erbXQC0quJnvT5z7cW+wsUoSlU518VvI 74f+DgUC8rXLzUbSciUIA86lyCvBXDEesjluLab2JzfkZ2SnKvvClu8oFWbh9INIbsx9f82LJOfJd 5DjpKRkDvZhU1kqUuJSvNyhiR6RKPjjJuminvrCRXgRB4Prv9nQZs8tqY+R8Ptj2E6XV1+OISndMr vOtbIVBccQqoKNAzsxrqzO+ObgkOD46lmmHovOHqMTDanQrdQOiAGptdHerQoRf+YTksWWbwu3Otq DCu+FGrQpGS1gBRRoBI/nFHLIqpou9yrkkhZL+WQBjHLdo4Hfyw9Z6hRNhPXheLsJZt4gHxGrFxz0 8lji8HXlUoxzFtlGIY0cD6lD; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenYr-0004Jc-Hq; Thu, 06 May 2021 23:37:41 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 07/31] rdma/siw: split out a __siw_cep_terminate_upcall() function Date: Fri, 7 May 2021 01:36:13 +0200 Message-Id: <8d6af83bbaf4647290d25c7ba0017a5a8059f107.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.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 2cc2863bd427..c91a74271b9b 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; @@ -395,29 +426,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 Thu May 6 23:36:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C3DBC433ED for ; Thu, 6 May 2021 23:37:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AC0F61164 for ; Thu, 6 May 2021 23:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232642AbhEFXiw (ORCPT ); Thu, 6 May 2021 19:38:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232789AbhEFXiv (ORCPT ); Thu, 6 May 2021 19:38:51 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3833C061761 for ; Thu, 6 May 2021 16:37:50 -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=0qtB4Cl0hGBRt7Yo3gJ1E+UNj0AN64ZCB0gKeZKCxo4=; b=3UUyI8mR06sO0L4uOSdCLhWaFS EgrFNiFQI+lmpa6fyey7RnP1pugw0ToVLL9UTB7pL6723Nh5dW5yXIw6xQ9YukfeEk28nJRyDYTAZ 0EayaWrSkGn3XnoMPcAvZalNFW9Ww7lB1yozZBj8tNSeiedBeMhfmIR6ey/Krp9LRNI0QI9ioS7aN mUavhavJ7tkviz1CWKFQwXd+YDG2TywZaeeowzI6F6II/sTr81RgwMr4jkrBIRmVAWzp6fnPfpeOB V5bB9T9UKoOvQZT7npMC8U6Obk4COkut3TQ1ankMvAYTNNLttu/pTHIzI8ClDnWW+2qQx4s9CIO50 dnDq5G+70XM5EnC7FrGz+tnAynjlggz7Gy//+BENN0+v3dK0auPs43pI/5pn6CkQZ+oiwam0b7Jwo Tfng/XsVqmRhusSqUwoPrGIZATBmV0AnGPmnqnZLpMGa6EeACQhCRjTfiA3GV1L0h9tP2D6r/ui6J LyOZF2AOSwRkszfdmecIDT1E; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenYy-0004Js-AY; Thu, 06 May 2021 23:37:48 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 08/31] rdma/siw: use __siw_cep_terminate_upcall() for indirect SIW_CM_WORK_CLOSE_LLP Date: Fri, 7 May 2021 01:36:14 +0200 Message-Id: X-Mailer: git-send-email 2.25.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 c91a74271b9b..b7e7f637bd03 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1071,11 +1071,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 Thu May 6 23:36:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3F51C433B4 for ; Thu, 6 May 2021 23:37:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D1AF61164 for ; Thu, 6 May 2021 23:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232803AbhEFXi4 (ORCPT ); Thu, 6 May 2021 19:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232790AbhEFXi4 (ORCPT ); Thu, 6 May 2021 19:38:56 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33A48C061574 for ; Thu, 6 May 2021 16:37:57 -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=4ghGPwbtdUNVmzIv9YdNxgZyOiZxvzy9M884OuRyLjg=; b=zEEJQ2tzQ4wWoZ1dZc3wYvIo/D noJLphrg2jHEy9jq1wb+SGbEhpjHr4DM6uAHKRpfD+DoGHZbH4b6I0rJnvkSFJXk9/WqoZH/CZNIf ZNguuFoaWDOEr02GeQ28BrLccKVbCQHqL9q/zn61rRAbqUGmyYI5x2n4WpG2WQCFXvcjnz11+HM3A PvrIucwqDiFGp0bIBjX4Ztqe8mC52euBrft5lnq0g+sUrxrbT5kBEzv82uxtCR95oxgdJ9CUnLJrX UyeOXDTB365zby+ccreCp5OVtiO8VCGuH9QDRfDxipixet8rCBlbFkTH4L591cKeyP6R2ma1KGHKi F6o4QMlEO3IzkMXkuZnz7CvIaWuY8liyHFgaUwmnNu1QFuUlkLvqTRK93wt34+3M77EMLyNfe85ca f/Z+8GdImG4+NPaRP0czkh/ZM9TjqJWmsmv3D+roz0otvAhD0v13nQJ6zGIogHfX0xJXfqYi7zrr5 HdJF4iuM/NOpQuo1vjnejyVQ; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZ5-0004KC-87; Thu, 06 May 2021 23:37:55 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 09/31] rdma/siw: use __siw_cep_terminate_upcall() for SIW_CM_WORK_PEER_CLOSE Date: Fri, 7 May 2021 01:36:15 +0200 Message-Id: <8cf78b479cca333caf82eca812d421c61675d776.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.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 b7e7f637bd03..5338be450285 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; } } @@ -1077,41 +1118,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 Thu May 6 23:36:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 528CBC433ED for ; Thu, 6 May 2021 23:38:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E814610FB for ; Thu, 6 May 2021 23:38:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232790AbhEFXjD (ORCPT ); Thu, 6 May 2021 19:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232800AbhEFXjC (ORCPT ); Thu, 6 May 2021 19:39:02 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86EA8C061761 for ; Thu, 6 May 2021 16:38:03 -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=6ZjFxhlfrxPhnxtbN+9Rvmz4gSbJh7L75ocIj3yOLoc=; b=MqrbQvWpUpcS3Sn+viqbxwO8xN BBsBLQ25W7uonyoPdpPuXfX3nZN2vlTLGx+EsK6dGAN6msAztSw3S96F+V4oMlUvgHg5SBpt1tV7J T/SfdzadA1dM3WpvkIX9A7OjtPiVpedQZ6eds2Dldq6Twrn1SDDqD9LJdAbNdAketbquoSErX8Nne gEuYT+YCEXYC6jvo+c10VbezRyBwB40m2YddT1NNw7DmJzAZ9DbBDoHIlM71Em5+jjlHmxbblYyCO uXIfa9Ge/aS4uyAcC2HUKKjWBVLnpNnc5V6pr4FEJkrIAWWmaKhBHgD2NyhVRglrHr9M8U12CxJlI CGwQ4SVVLWA2s3nwG/oYJlfPycRp8nrJAnYgbgocbrCFqF8riQby8bolwX5R8G6C8i/guYbMLYKac DmYlebUsq9P0MAn5BKmwbQjwqXd9c7mBlbWK+c6AXV+f7TeUcBUjqPyAHJUlGlX4DxDKLemo/l0Q1 ilcJMa+12dOhsYmT8v30Yw+Z; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZB-0004KO-MG; Thu, 06 May 2021 23:38:01 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 10/31] rdma/siw: use __siw_cep_terminate_upcall() for SIW_CM_WORK_MPATIMEOUT Date: Fri, 7 May 2021 01:36:16 +0200 Message-Id: <6ba824c412e5535b70683676734bebf82a4f325f.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.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 5338be450285..d03c7a66c6d1 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1127,31 +1127,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 Thu May 6 23:36:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E33DDC433ED for ; Thu, 6 May 2021 23:38:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2D5261164 for ; Thu, 6 May 2021 23:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232800AbhEFXjL (ORCPT ); Thu, 6 May 2021 19:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbhEFXjJ (ORCPT ); Thu, 6 May 2021 19:39:09 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1391EC061574 for ; Thu, 6 May 2021 16:38:09 -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=tFyEeOJh+aZyZhLhVw9Pu179zrnwDo6xMfSVp0eSes0=; b=WJRmC4J0DvS/wOkKD/9azm86rJ ZFV85845ThkPF35metkF7UnwWfHanoWzKPLNUrq9/tBZO/e7kFHjNrM7qkmmYL0WkxEKiZxHA3Ipa idZz+SxeLG37CkGQj1rYCpPYQLcwE+WuFJbvzjZEcle3ZgCVlcDzaDhdDFhD+GxT113h6FmMpW4T5 GGScodwIogLOF2knQ9dMqEer5LL2W0FkSjY7QKEOH8N0U3ZE1tEShB3kjXIHeb2rx7vzs5kcaZOzl QPsE+lISlzCQr2n5AHPYZS6V28mg/zLhHn3tzLrL7EsjgVqTQIlWKb+67Ms8GjjzRKOYIOLZWGk9b SFPpPj9R8X9VT88dJXXNZjvQOm5qQUTSaCI8vbcqSrCWYvhL32CCi3mYKi0VefoG22nW1NmyrYW0S EEntvloqDu0lz9aJwxTDASNSIAiPKYR83MJ/xbSM7zqwaEUOFuVtpHm2XWjMrgGSAojIXp7T44WJM jchIyTV3+IrIDQTEvYrN5w+s; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZI-0004Ka-6Z; Thu, 06 May 2021 23:38:08 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 11/31] rdma/siw: introduce SIW_EPSTATE_ACCEPTING/REJECTING for rdma_accept/rdma_reject Date: Fri, 7 May 2021 01:36:17 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org When we received the MPA Request, we set SIW_EPSTATE_RECVD_MPAREQ and port IW_CM_EVENT_CONNECT_REQUEST to the IWCM layer. In that state we expect the caller to reacted with rdma_accept() or rdma_reject(), which will turn the connection into SIW_EPSTATE_RDMA_MODE or SIW_EPSTATE_CLOSED finally. I think it much saner that rdma_accept and rdma_reject change the state instead of keeping it as SIW_EPSTATE_RECVD_MPAREQ in order to make the logic more understandable and allow more useful debug messages. In all cases we need to inform the IWCM layer about that error! As it only allows IW_CM_EVENT_ESTABLISHED to be posted after IW_CM_EVENT_CONNECT_REQUEST was posted, we need to go through IW_CM_EVENT_ESTABLISHED via IW_CM_EVENT_DISCONNECT to IW_CM_EVENT_CLOSE. 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 ++++++++++++++++++++++++++++-- drivers/infiniband/sw/siw/siw_cm.h | 2 ++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index d03c7a66c6d1..3cc1d22fe232 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -146,10 +146,35 @@ static void __siw_cep_terminate_upcall(struct siw_cep *cep, case SIW_EPSTATE_RECVD_MPAREQ: /* - * Wait for the ulp/CM to call accept/reject + * Waited 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"); + siw_dbg_cep(cep, "mpa req recvd, post established/disconnect/close\n"); + siw_cm_upcall(cep, IW_CM_EVENT_ESTABLISHED, 0); + siw_cm_upcall(cep, IW_CM_EVENT_DISCONNECT, 0); + siw_cm_upcall(cep, IW_CM_EVENT_CLOSE, 0); + break; + + case SIW_EPSTATE_ACCEPTING: + /* + * We failed during the rdma_accept/siw_accept handling + */ + WARN(!suspended, "SIW_EPSTATE_ACCEPTING called without suspended\n"); + siw_dbg_cep(cep, "accepting, post established/disconnect/close\n"); + siw_cm_upcall(cep, IW_CM_EVENT_ESTABLISHED, 0); + siw_cm_upcall(cep, IW_CM_EVENT_DISCONNECT, 0); + siw_cm_upcall(cep, IW_CM_EVENT_CLOSE, 0); + break; + + case SIW_EPSTATE_REJECTING: + /* + * We failed during the rdma_reject/siw_reject handling + */ + WARN(!suspended, "SIW_EPSTATE_REJECTING called without suspended\n"); + siw_dbg_cep(cep, "rejecting, post established/disconnect/close\n"); + siw_cm_upcall(cep, IW_CM_EVENT_ESTABLISHED, 0); + siw_cm_upcall(cep, IW_CM_EVENT_DISCONNECT, 0); + siw_cm_upcall(cep, IW_CM_EVENT_CLOSE, 0); break; case SIW_EPSTATE_AWAIT_MPAREQ: @@ -1563,6 +1588,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) return -ECONNRESET; } + cep->state = SIW_EPSTATE_ACCEPTING; qp = siw_qp_id2obj(sdev, params->qpn); if (!qp) { WARN(1, "[QP %d] does not exist\n", params->qpn); @@ -1743,6 +1769,7 @@ int siw_reject(struct iw_cm_id *id, const void *pdata, u8 pd_len) } siw_dbg_cep(cep, "cep->state %d, pd_len %d\n", cep->state, pd_len); + cep->state = SIW_EPSTATE_REJECTING; if (__mpa_rr_revision(cep->mpa.hdr.params.bits) >= MPA_REVISION_1) { cep->mpa.hdr.params.bits |= MPA_RR_FLAG_REJECT; /* reject */ diff --git a/drivers/infiniband/sw/siw/siw_cm.h b/drivers/infiniband/sw/siw/siw_cm.h index 8c59cb3e2868..4f6219bd746b 100644 --- a/drivers/infiniband/sw/siw/siw_cm.h +++ b/drivers/infiniband/sw/siw/siw_cm.h @@ -20,6 +20,8 @@ enum siw_cep_state { SIW_EPSTATE_AWAIT_MPAREQ, SIW_EPSTATE_RECVD_MPAREQ, SIW_EPSTATE_AWAIT_MPAREP, + SIW_EPSTATE_ACCEPTING, + SIW_EPSTATE_REJECTING, SIW_EPSTATE_RDMA_MODE, SIW_EPSTATE_CLOSED }; From patchwork Thu May 6 23:36:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4AB8C433ED for ; Thu, 6 May 2021 23:38:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C010961164 for ; Thu, 6 May 2021 23:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232818AbhEFXjU (ORCPT ); Thu, 6 May 2021 19:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhEFXjQ (ORCPT ); Thu, 6 May 2021 19:39:16 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD9ACC061761 for ; Thu, 6 May 2021 16:38:16 -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=6H+QNgqu01dvYHmtu2P5PruSlj+5YpvlchBxB5d3SUk=; b=3aL4ydXXRVA+y2pIDNuW4kShFa ZET8mAGRbFqqGdqcDiuueo2l+SjLKpAI38C+r9Wo6uFkQ6N/QTQqik2GgjAcAxFEn831QIiBdNn8g L4LM2XNOVkRGXv+2L4cVWfgTC1TjoWfIvKzYHbL7a0pxGSf/7yqtpnkybSTcl3DR55s3Wdc9W0xRR MQZ2teQWpCBD0rUaQCLZePnAy8Qe+VPygLZ4AC3lUNfH/iqCfoNLQW9tEuHAxVdQsoQ1s1H3Ipl1U EcBuQY6LujkgMr/zI61PkspIjaEuxrtilR3V6GnhkMRuCk5hlAxxesniwG8MxbVUXqxLUI0zGeQsy JAj/UNkDBGPsduBldAxhPOqZaeOHpCISktj2owI92aa9fc9AJ6o1QzMt8aLLiI5lyTMXsVdr5ZQjo y7KkZB/qlUnsshIhlfPwJ3o80OuE8S4vurC9mGUyBglP7aDD1F6NPpxfryyvQYKzj+rHPvJjhIbP0 3Ac3MuDIm48psGGU2WjU90Jo; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZO-0004Ko-OD; Thu, 06 May 2021 23:38:14 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 12/31] rdma/siw: add some debugging of state and sk_state to the teardown process Date: Fri, 7 May 2021 01:36:18 +0200 Message-Id: <0f85e2dc8c8cdeb25a14113b279ec44441112867.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org That makes it easier to understanf where possible problems come from. 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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 3cc1d22fe232..ed33533ff9e6 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -111,6 +111,14 @@ static void __siw_cep_terminate_upcall(struct siw_cep *cep, int reply_status) { bool suspended = false; + int sk_state_val = UINT_MAX; + + if (cep->sock && cep->sock->sk) + sk_state_val = cep->sock->sk->sk_state; + + siw_dbg_cep(cep, "[QP %u]: state: %d sk_state: %d\n", + cep->qp ? qp_id(cep->qp) : UINT_MAX, + cep->state, sk_state_val); if (cep->qp) { struct siw_qp *qp = cep->qp; @@ -118,9 +126,14 @@ static void __siw_cep_terminate_upcall(struct siw_cep *cep, if (qp->term_info.valid) siw_send_terminate(qp); + siw_dbg_cep(cep, + "with qp rx_suspend=%d tx_suspend=%d\n", + qp->rx_stream.rx_suspend, + qp->tx_ctx.tx_suspend); if (qp->rx_stream.rx_suspend || qp->tx_ctx.tx_suspend) suspended = true; } else { + siw_dbg_cep(cep, "without qp\n"); suspended = true; } @@ -1307,7 +1320,7 @@ static void siw_cm_llp_state_change(struct sock *sk) } orig_state_change = cep->sk_state_change; - siw_dbg_cep(cep, "state: %d\n", cep->state); + siw_dbg_cep(cep, "state: %d sk_state: %d\n", cep->state, sk->sk_state); switch (sk->sk_state) { case TCP_ESTABLISHED: From patchwork Thu May 6 23:36:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E26FC43461 for ; Thu, 6 May 2021 23:38:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6043561164 for ; Thu, 6 May 2021 23:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232822AbhEFXjZ (ORCPT ); Thu, 6 May 2021 19:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232834AbhEFXjY (ORCPT ); Thu, 6 May 2021 19:39: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 33610C061574 for ; Thu, 6 May 2021 16:38:23 -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=pP9BzoMZjNMJ0mB7ftvb70BJHJszpGFSWVB6rbAoomM=; b=BqtmOIccP8IHEMpGM7FWZLyymF Sbwq5Iv9qtVgsV21SrkkyZ/bfFo6EAxS2ysjLrxLEt1ctEef1se9QIf2OeLezQymeopvxuhAQbU0s MYY3ydeLq1J2Utz+brPS+DF2l0zUKe3r5wCl5hpLrAMCi7ipqTXgPUFdpDI8gNcjcUK04m+7nXfU4 HyKqyv2uUcPTCGEYQBtFM13y9hSKesaMg8uc6EuTUgoSaavJgSxmsbTAO0iKYWwsPIrtV8R90AmII Cpot7p2MHdoQNlNCdQuG1+LtKMJ6YUyK0nlq8/U78z4gqmWTbkGCPaPEr12/DeWa/w6jEdtensrZp mKZvn42MxfaiL6mJl1Noh7DIJemvzUyYZ1UYStWLS3QC+ebxfJG/6z0Oa2jHelSMqbLqsST1CbLBF C1Z65Wgw5PqN7d3pxGmc8fLKQMsdckUcTDYGSZ7OAe1ltxuSfiDwgs9/qc73B8yekkmIqrZEe06PZ gW6TZaKeE+HJ5xnlvdUxcqcZ; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZV-0004L1-66; Thu, 06 May 2021 23:38:21 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 13/31] rdma/siw: handle SIW_EPSTATE_CONNECTING in __siw_cep_terminate_upcall() Date: Fri, 7 May 2021 01:36:19 +0200 Message-Id: X-Mailer: git-send-email 2.25.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 ed33533ff9e6..8e9f5ce5ce29 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -138,6 +138,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, @@ -202,7 +210,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 Thu May 6 23:36:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 304CFC433B4 for ; Thu, 6 May 2021 23:38:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 104C0610FB for ; Thu, 6 May 2021 23:38:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232834AbhEFXjc (ORCPT ); Thu, 6 May 2021 19:39:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhEFXja (ORCPT ); Thu, 6 May 2021 19:39:30 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD629C061761 for ; Thu, 6 May 2021 16:38:30 -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=ofug5v24UpU4dzRHZOy8hbAsCgib2HTwXBwMiFH4lEU=; b=Guh6ZdvpodlKLsniPJf1s61d2T o1z7ydZw8QXTFz7ogQr8wFHHSSgPJyMbzOuaEL0jeeRxKtYv9zuhpKPM35L43krdz1HL0Nf5f0UTq SBcXJB/sUx5WLnVw+C0lOA5tp57oukowJnl49ny06OUPMAA0nL/e199o7AIATXOtcI49FkhO+AQiu 1ne1OYFPsgI9IdO5L7GJTvBkOsbxdvmlbFML7KVx6dY0eRWU5euC6TLwTGH5o8Q5nYZc0ICGLaFPd M96g3hQYt5VJV0UBhwulbwaFNnis7rrJsC98eR3oRFk/hO+xxlt0Pn2DUcxONdqpAGn1zcghZE8iQ 52mkEH8XHGOJTWgKvO+7FqEZhwWDeFd2VY5TEMJU2zjZLj6xHtxx7KW6UhJ9GgM2Jb3JNKEpiwnrG cxFPJjLeI5hZ1tRY7tOKIHhWytedCJZoCS5SxaM6jjN87eI3Z20MP6ar1e7pdZOrAluaFwL+4tVvj N84jh/chAikwnvPnyshGdFMl; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZc-0004LD-Ss; Thu, 06 May 2021 23:38:28 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 14/31] rdma/siw: let siw_connect() set AWAIT_MPAREP before siw_send_mpareqrep() Date: Fri, 7 May 2021 01:36:20 +0200 Message-Id: X-Mailer: git-send-email 2.25.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 8e9f5ce5ce29..027bc18cb801 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1477,8 +1477,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'. @@ -1521,6 +1519,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 Thu May 6 23:36:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35295C433ED for ; Thu, 6 May 2021 23:38:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13223610FB for ; Thu, 6 May 2021 23:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232861AbhEFXjh (ORCPT ); Thu, 6 May 2021 19:39:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhEFXjg (ORCPT ); Thu, 6 May 2021 19:39:36 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36FF2C061574 for ; Thu, 6 May 2021 16:38:37 -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=ZWc9RZj6x+/FMj7iLvPpV4BtuYQEsZX3sqTosGD6gB0=; b=UYvwFwxpzFjWPkOWYDfW1Pablw yJGXpoowheWqKBNORcaLKNMZOORMIs/HkBYJ9dZBcp2dPEWm52k7cA5aPRcT8tKCKEPdfL+aAOcbH OozTtUVXwyau0ZsMOUl3zFPAkrz816kebrLQvdfMKsdu4Lqip7MF2L+0RvzeZqbu7CCFSUEw0iXUF n/XG6cpkr07R14oyCtjN/yA6mSs1cj61HkuSTjana/D1p0IDc/8Pfjx8598KiLoEVzq8XcWdfGHIC 6mEb90KZfFlAIzFcb4RbsboMt3g52hUmwJoU6klj8rTLifyfarh+4Dwx3acyC+c7cfoAN4Lt2RCxx 8eJANSHBUbvJGq3v/5Yzecegn+vPgNZjZwD7cHsdRS1UyoypskIiGZDoMN7/eE+WC874gNunM1Gpt SjBlXmNulofXdhXvBDVDILt2RWNiYuFiwBXFZslH5kLCx1GqUU+w7kJIod546dGO6YqAiJEl4gnz8 E52CZMOJqH/3ow7+1kvFwfEv; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZj-0004LS-9B; Thu, 06 May 2021 23:38:35 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 15/31] rdma/siw: create a temporary copy of private data Date: Fri, 7 May 2021 01:36:21 +0200 Message-Id: X-Mailer: git-send-email 2.25.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. 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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 027bc18cb801..41d3436985a6 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1519,13 +1519,25 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) } memcpy(cep->mpa.hdr.key, MPA_KEY_REQ, 16); + 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 Thu May 6 23:36:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E828C433ED for ; Thu, 6 May 2021 23:38:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8111061164 for ; Thu, 6 May 2021 23:38:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232840AbhEFXjn (ORCPT ); Thu, 6 May 2021 19:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhEFXjm (ORCPT ); Thu, 6 May 2021 19:39:42 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824E0C061574 for ; Thu, 6 May 2021 16:38:43 -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=ysiqFt6wjmuvvJ3BMaZhbil9Yy6iEDpm6PVV3IzjKEU=; b=Vzs94vp+2fYixqb5Xz0QFiBsNq 12kpt5xs+SB44DvwL24V6+Hs8e0jm1BG8ZViWRoYanvlXRqkZa9fgDDaTOBaBFyj8KFFDFMlAx37w /OYwpwzaok2PRiTepw8ClojHVh9R5pSv7f1FAL0HeN4NNQfqec5Ie+MZC3I6c1v0SNyH1Vy3ylX9d dQTK/clq3Ncv+/as6aHhP+HiP/yv5ivmaGbjt3lUVzReKNG0QCXXppYIRVFDowHdeqKbyfNgJB+dt PlHli590Rjbpt8oeUO0OG6HVYaV20xs9MLjJ9K4XCY/JoZ5wBXfay3Gwtn13HR6rSDDzHanY1cUZA 2cKFvgfmlvmRWTs6vZDrEmFdMkpWN4tU9sSB4uhA9ccHDXmHsf8iRNwPv+Mhgxg40cB3Rl+Vu+FBS q8z+g9ohTDGRoVrUmdzEanFUe+FGylY7Vcw5ULonkh9NsysVQ6N5KsfDcru0vn9J9KAH0o21aIh1k tp0zrGSARMvfmXTFqf5VyPBE; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZp-0004Lg-Kc; Thu, 06 May 2021 23:38:41 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 16/31] rdma/siw: use error and out logic at the end of siw_connect() Date: Fri, 7 May 2021 01:36:22 +0200 Message-Id: <3c43552c9b61a4d2352ae3680bfcacc25a9cc9b4.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.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 Reviewed-by: Bernard Metzler --- 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 41d3436985a6..ec6d5c26fe22 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1539,14 +1539,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 Thu May 6 23:36:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB426C433ED for ; Thu, 6 May 2021 23:38:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D2D761164 for ; Thu, 6 May 2021 23:38:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbhEFXjt (ORCPT ); Thu, 6 May 2021 19:39:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhEFXjs (ORCPT ); Thu, 6 May 2021 19:39:48 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D24C061574 for ; Thu, 6 May 2021 16:38:49 -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=wnPlEd2eniaz91RNeltIO2WRhr5HA/Lh6vheCzw/3zs=; b=m+x/79jiSheSey36LxoP+O2mCM Y+6+ht9RJGqSWJyj66ihwl+E14rSxPkJLzZwCyHzQyrQanaurK8/AZZVX97HNIH73LfcewZ0aqImx pO0RC9h4QZpCbjsz+F/IZ7R1dqUdn+qga5BoQ6yuCfam1lnCn1MN5rhxybQSz5EQzvPnhKvjSsN7S ouk/BU0L9sSSwqAJjh78XXJNihOKQqbeI/Ydz6MwKrcEZaG2pu2ps6h1aJovu0jnu1zoNOjXdtn96 lUaCtwAUzOVHlJrvMOhPIIPIszfQQXstBYim03EYyE0QbTt1KUzhz5SYcxBBvcWIGPhoHoH1Dpy/U IqfDF0X5BCh8oTNRY/cPPvNgxBTHdvY2WJLS6r7QiSHCVQBBAgxkI+hWuSVfLihmzMBMkizLh/5Cb Ja6IFHo7jC6y2eI2uBr3ICD2Hx6Ljit1umXy9KwybV7vQ0ZgSf7KAjqULJ34Wx7DbrkVhD5ErQ6fh 72LO+s/imzAxjpKJvJZX5qYM; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenZw-0004Lu-2H; Thu, 06 May 2021 23:38:48 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 17/31] rdma/siw: start mpa timer before calling siw_send_mpareqrep() Date: Fri, 7 May 2021 01:36:23 +0200 Message-Id: X-Mailer: git-send-email 2.25.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 Reviewed-by: Bernard Metzler --- 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 ec6d5c26fe22..853b80fcb8b0 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1526,6 +1526,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, @@ -1543,11 +1548,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; @@ -1556,6 +1556,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 Thu May 6 23:36:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B4E4C433B4 for ; Thu, 6 May 2021 23:38:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29EF961164 for ; Thu, 6 May 2021 23:38:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232858AbhEFXj4 (ORCPT ); Thu, 6 May 2021 19:39:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhEFXjz (ORCPT ); Thu, 6 May 2021 19:39:55 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F16C061574 for ; Thu, 6 May 2021 16:38:56 -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=yHn+dA+pHBHLIY/pMgk8wOiWS4xrPuG6UitQ/WoamtQ=; b=UCYzIronO6SwXndZZxa+gcWGJH Ag+A7EiROSs5ONRrvFHAmWDFr7284W9nzEHtJW3KiOqPVHfSLPrWA4sDU6ZNJgvRvlZPSKYPqiOY3 owCfSprpnB932dS0o1ojvwyd1T3vnf+XURDfRH7Z4k/sqhZ8AQoinDTLYh4F19DGtWhxr4RSvhR48 wfd3XPZtPJjoCHR7Bl/mAfiiRj/WoZ2WoM9Dqwo0kq+jXIgu0+Rt2mdliaVgbSeDFxxI3sLiZR3Zy N07DlWc/4tCpBbcJagqx1NqrS/uBJJp2w1fAaKzPHQS1gk44pBZsHOxMpgdSyB9okgdFDlxuLotHh v0TpHsdULBaHDAziYh2ka0vm8MT8DlUB3J92LZTa/Iyx3aZUPx2VlMkcY4KpWJxNQr+Jbo7Z7AMet D2PQ6q0fG28/H0/UAEFK8+j1vUtfJB22LS5+MtZMhQDJ9az0D6jPP+FFvgobJypd5ZBrJRXZbdbLX oW0kkI0DpWG923oFztlDraLg; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lena2-0004M7-OE; Thu, 06 May 2021 23:38:54 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 18/31] rdma/siw: call the blocking kernel_bindconnect() just before siw_send_mpareqrep() Date: Fri, 7 May 2021 01:36:24 +0200 Message-Id: <8d9e1879a8b13516a4aae5ae3d3b1741c78b7d1d.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.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 853b80fcb8b0..009a0afe6669 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1425,18 +1425,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; @@ -1531,6 +1519,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 Thu May 6 23:36:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3FB4C433ED for ; Thu, 6 May 2021 23:39:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 915A6610FB for ; Thu, 6 May 2021 23:39:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232868AbhEFXkC (ORCPT ); Thu, 6 May 2021 19:40:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhEFXkC (ORCPT ); Thu, 6 May 2021 19:40:02 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B74C061574 for ; Thu, 6 May 2021 16:39:03 -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=Po4bU4uuYArp5nFCWjbgEB6uuMZCMypdxRuVdxaTI5k=; b=Cq7J6FVwA6CuB3h5KE2Di+hCgh 3ENjvlltdjau180+gSKYq/479ovZ0C0QDBS43oGeM67M6eWWJWcGZZ4t6eTgmY4RMbqib74GcyQCV nQfMv65Lznke64sGwAYoUmFtQGgpf0TDm4vdRE57RgMB+t/ocGtIsUa4lhXrCfBqttnGgMNeq7eyY ezYZqIC8rflS98qkZ4IOoosTA+NebutfhdgTQD6Ht5OCOxybi4frHd5p2snxO267uWfJDFuucPYWM 8jIeh5IB5y/XPonCPwuKPWCsPK84ohkt7u4XpuH5Kt83HZFX1Kp5Dhr7XuADMQi4B0P5EwZTteL/A je930C9A6aWEcd3++2WLnGOZ+XWO2hZjrDD1W3wfAL/N8EppvS125YdWoVFe2v7+GbxbodJ8P4ksi momuA67RTRHtFUuFx1I7otpXnBrUJPNfsV8At5t5v1dRixKC88v87hEnxUW0QBCxdNNW8NVf6Xnof K8msrkOZMoaV1AsfLt1ldYR9; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lena9-0004MJ-BS; Thu, 06 May 2021 23:39:01 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 19/31] rdma/siw: split out a __siw_cep_close() function Date: Fri, 7 May 2021 01:36:25 +0200 Message-Id: <8f68ab650c2ecac55075d07a4256eff7b1735324.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This can be used in a lot of other places too. And can be the code path that we can easily adjust without forgetting other places. 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 | 48 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 009a0afe6669..cf0f881c6793 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -220,6 +220,34 @@ static void __siw_cep_terminate_upcall(struct siw_cep *cep, } } +/* + * The caller needs to deal with siw_cep_set_inuse() + * and siw_cep_set_free() + */ +static void __siw_cep_close(struct siw_cep *cep) +{ + cep->state = SIW_EPSTATE_CLOSED; + + if (cep->sock) { + siw_socket_disassoc(cep->sock); + sock_release(cep->sock); + cep->sock = NULL; + } + + if (cep->cm_id) { + cep->cm_id->rem_ref(cep->cm_id); + cep->cm_id = NULL; + } + + if (cep->qp) { + BUG_ON(cep->qp->cep != cep); + cep->qp->cep = NULL; + siw_qp_put(cep->qp); + cep->qp = NULL; + siw_cep_put(cep); + } +} + static void siw_rtr_data_ready(struct sock *sk) { struct siw_cep *cep; @@ -1559,27 +1587,17 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) if (cep) { siw_cancel_mpatimer(cep); - siw_socket_disassoc(s); - sock_release(s); - cep->sock = NULL; - - cep->qp = NULL; + s = NULL; + qp = NULL; - cep->cm_id = NULL; - id->rem_ref(id); - - qp->cep = NULL; - siw_cep_put(cep); - - cep->state = SIW_EPSTATE_CLOSED; + __siw_cep_close(cep); siw_cep_set_free(cep); siw_cep_put(cep); - - } else if (s) { - sock_release(s); } + if (s) + sock_release(s); if (qp) siw_qp_put(qp); From patchwork Thu May 6 23:36:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34F85C433ED for ; Thu, 6 May 2021 23:39:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11B38610FB for ; Thu, 6 May 2021 23:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232846AbhEFXkJ (ORCPT ); Thu, 6 May 2021 19:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232521AbhEFXkI (ORCPT ); Thu, 6 May 2021 19:40:08 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6A64C061574 for ; Thu, 6 May 2021 16:39:09 -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=sKDhMddpDYwMlZNTFJg3BqdaHlziQfuLC+vCF31iEe8=; b=HgMdaQ9BaiIOMdOub8NjS3HmZx vFWND01R9IvDantjhmguzm9bBarkjUw5HkzRdOeZVECeZP1GbHE1YhXk6nUYISMO2X4yKFhSqg5r6 cpYEohlwsT8jyEil+pAsvZl0J/u+KIKoxs2na/m/EcsFDnGl+wrGB8fQvuZMpZNePTNxY1zl6Od+n ROlb0MSxwzNibTcDreK1rjks/iyxmQ7q4Cq8gNmz8GICpwYcpUBqUHShKfCxG7DNl2TXXD0uPOs5X KPPx54I4X2+uO5+oisqeo4PPjG/2XZujn5gnsYJKuo3KDnuJHwErJsTgQnjzF627YTTxKfFXqDKw6 UcntuoOmOPRHWYMzMjiB7SmDJKBK1yziaoBr5WLMItBXS/M8d+wCUNuD93HVSkjHCmWfn8WCkXPkf /3fNJfbT9HeEE0SoTccWpJ0sa1pu8ZFH5Jmw3WD/PivJ327MnUB8/33jzan2mAdsIRwvGFmWKwZw8 /DeT3nCAMeNXLRCxidWjjoLA; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenaF-0004MW-QW; Thu, 06 May 2021 23:39:07 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 20/31] rdma/siw: implement non-blocking connect. Date: Fri, 7 May 2021 01:36:26 +0200 Message-Id: <80a82b4d3029d1a63042910e3ac4c3731561967e.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.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(). 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 | 114 +++++++++++++++++++++-------- drivers/infiniband/sw/siw/siw_cm.h | 1 + 2 files changed, 85 insertions(+), 30 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index cf0f881c6793..9a550f040678 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) { @@ -1141,6 +1142,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) { @@ -1306,6 +1311,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: @@ -1359,12 +1365,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); + /* fall through */ case TCP_CLOSE: case TCP_CLOSE_WAIT: @@ -1383,7 +1403,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); @@ -1402,7 +1422,7 @@ static int kernel_bindconnect(struct socket *s, struct sockaddr *laddr, if (rv < 0) return rv; - rv = kernel_connect(s, raddr, size, flags); + rv = kernel_connect(s, raddr, size, O_NONBLOCK); return rv < 0 ? rv : 0; } @@ -1547,36 +1567,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; @@ -1604,6 +1615,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 4f6219bd746b..62c9947999ac 100644 --- a/drivers/infiniband/sw/siw/siw_cm.h +++ b/drivers/infiniband/sw/siw/siw_cm.h @@ -78,6 +78,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 */ From patchwork Thu May 6 23:36:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8595DC433B4 for ; Thu, 6 May 2021 23:39:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6631F61164 for ; Thu, 6 May 2021 23:39:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232871AbhEFXkP (ORCPT ); Thu, 6 May 2021 19:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232521AbhEFXkP (ORCPT ); Thu, 6 May 2021 19:40:15 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC81C061574 for ; Thu, 6 May 2021 16:39:15 -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=5BOyOcbxbJ4md9sXdLKC7g15MuupL/qOC5xr1Vkt/pk=; b=fK32m8dXu4MQkksWxWmOr8bqdg v57Q7uK9z4zQ4NsL0B2qOV6/PunLVcMlzpyo66BvO8g9oaCSaBhGFnv5fePI74D+hyv+ZhrksAgg9 HOcpmq/lKfxgy+BfM/V/PacI17kAramvQr9LukodZ6bPTT4+TwomUSjhus4VP0XOWb7TbcsH68sHJ z8jeFT+azWrH5aWKow3bndpHzISStJM+Dau7r4TD+LwtY5SZE+8/I8RaXoLPTj937fueTG0R0ao3E pGErIMDArF/eswGc0mShYhNz9RgyJ6iKve7kQVWl+WtTuXtLcoEcyz1M37DfJH/GTl/9bQEhNfszE Q/OG+0Z2Xz8rk0jXeZ6EMfrHfLDUpec95FXzY6aNt/9mtZrJJqIkWqDNKjmcMIys7qrrAvb38z9UR oYoT6Yiw6IQal/qP09uXMefO4CgFQjQJwR3CF6ErIS8Oh33sd99unZfTTbeCxKfhA8hJvUHSyJ9cr eYEcGcW6xUrLTtyV+oE7rt8L; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenaM-0004Mk-5b; Thu, 06 May 2021 23:39:14 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 21/31] rdma/siw: let siw_listen_address() call siw_cep_alloc() first Date: Fri, 7 May 2021 01:36:27 +0200 Message-Id: <66ef71c4c9cd6767746e0d48c75423487e59834a.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This simplifies the cleanup path and makes the following changes easier to review. Check with "git show -w". 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 | 39 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 9a550f040678..fe6f7bb4d615 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1916,9 +1916,16 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) if (addr_family != AF_INET && addr_family != AF_INET6) return -EAFNOSUPPORT; + cep = siw_cep_alloc(sdev); + if (!cep) + return -ENOMEM; + rv = sock_create(addr_family, SOCK_STREAM, IPPROTO_TCP, &s); - if (rv < 0) - return rv; + if (rv < 0) { + siw_dbg(id->device, "sock_create error: %d\n", rv); + goto error; + } + siw_cep_socket_assoc(cep, s); /* * Allow binding local port when still in TIME_WAIT from last close. @@ -1957,12 +1964,6 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) siw_dbg(id->device, "socket bind error: %d\n", rv); goto error; } - cep = siw_cep_alloc(sdev); - if (!cep) { - rv = -ENOMEM; - goto error; - } - siw_cep_socket_assoc(cep, s); rv = siw_cm_alloc_work(cep, backlog); if (rv) { @@ -2018,20 +2019,18 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) error: siw_dbg(id->device, "failed: %d\n", rv); - if (cep) { - siw_cep_set_inuse(cep); - - if (cep->cm_id) { - cep->cm_id->rem_ref(cep->cm_id); - cep->cm_id = NULL; - } - cep->sock = NULL; - siw_socket_disassoc(s); - cep->state = SIW_EPSTATE_CLOSED; + siw_cep_set_inuse(cep); - siw_cep_set_free(cep); - siw_cep_put(cep); + if (cep->cm_id) { + cep->cm_id->rem_ref(cep->cm_id); + cep->cm_id = NULL; } + cep->sock = NULL; + siw_socket_disassoc(s); + cep->state = SIW_EPSTATE_CLOSED; + + siw_cep_set_free(cep); + siw_cep_put(cep); sock_release(s); return rv; From patchwork Thu May 6 23:36:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8BD8C433ED for ; Thu, 6 May 2021 23:39:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E91961164 for ; Thu, 6 May 2021 23:39:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232889AbhEFXkW (ORCPT ); Thu, 6 May 2021 19:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232884AbhEFXkV (ORCPT ); Thu, 6 May 2021 19:40:21 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C27FC061574 for ; Thu, 6 May 2021 16:39:22 -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=W72aT2pJurjmDhoaXNR3tpgcPeJrLVH2bDU1/lqUAbw=; b=XJulgsrtTcc4HXt5U1b8ohZ0bB dmNtw+yXFWw7hkMbmEB2Bz7lsaG96slRD81IyM1eAxKLX2qN825wOmtYlMZhY8+CHpprnnS+vj7bp 7ZKDj78pQbD4VhZl0XmKfHy4Cf+2tEqODfi8+6clpDy5h+YPYsBmQnJKhbCqOgIW8leJGv6LeWx3b a5HAob7yGZBwwcY3IoU4800z2jnWlxFUIr+cp1pgSy+yRAzTss15s6OqdTbOkd4qDA6m7rQa6Odge msdKxna/B0hNRiqYQliZpAco6qSdFY805QBZoX+80YaIRBvTMrP93BrLh+ajpradNzup7+UV4K48F lrqliwKmISDs0MwOAQEfvQ69QB/HzpmQpgoJvFKzI5GDRadIJAv8Xa4nOlO87SaMA1xiF4QYtJfkU ATWpI/auf9ndFlXYY56gtMo9ZJc7eWtDnyaiVDsQ5TdqZsu23DPXAerDsupTtgb4RrgoWbCebZMkL 6Hu7aIZmU2GLcMDBrCsPNEXJ; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenaS-0004Mw-LG; Thu, 06 May 2021 23:39:20 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 22/31] rdma/siw: let siw_listen_address() call siw_cep_set_inuse() early Date: Fri, 7 May 2021 01:36:28 +0200 Message-Id: <33abff2233b36a51e468d691cb4327d0294d2734.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We should protect the whole section after siw_cep_alloc(). Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org Reviewed-by: Bernard Metzler --- drivers/infiniband/sw/siw/siw_cm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index fe6f7bb4d615..09ae7f7ca82a 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1920,6 +1920,8 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) if (!cep) return -ENOMEM; + siw_cep_set_inuse(cep); + rv = sock_create(addr_family, SOCK_STREAM, IPPROTO_TCP, &s); if (rv < 0) { siw_dbg(id->device, "sock_create error: %d\n", rv); @@ -2014,13 +2016,12 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) siw_dbg(id->device, "Listen at laddr %pISp\n", &id->local_addr); + siw_cep_set_free(cep); return 0; error: siw_dbg(id->device, "failed: %d\n", rv); - siw_cep_set_inuse(cep); - if (cep->cm_id) { cep->cm_id->rem_ref(cep->cm_id); cep->cm_id = NULL; From patchwork Thu May 6 23:36:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A9EAC433B4 for ; Thu, 6 May 2021 23:39:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AE76610FB for ; Thu, 6 May 2021 23:39:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232521AbhEFXk3 (ORCPT ); Thu, 6 May 2021 19:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232877AbhEFXk2 (ORCPT ); Thu, 6 May 2021 19:40: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 EC2BCC061761 for ; Thu, 6 May 2021 16:39:29 -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=ztncEAoT1eKkq9inquNni1Xp2rvapRlijUDB6jPhC34=; b=YP3qQKRw366C1mfxnoCRyayj4H lEBbDT1pc1GiCUEKLsq65XhuNOpOvXODeG58Ps8H+Lc07b0a63PLOPNwK1cMXWdNhJOcCh926KHIS dbJ3UlqIKv/70ZMcE1yaBxdutMH982ynLmihbYmAWnBOZdH/frxN2an4/v2wVrA8hUtOwYyjjo1B+ w5/14gR5zxfwe8JZOEfvm1NEMR6v8KoDq4Ex0uwIqRMVN/hJWpiD9lfqVGa79Jkt24xkeE2EOytlh bLNe+UNAZ/j8lc4mREL/z5P2CNJIryBPte8q8kDGhDxt41orj82Y4PTPpsWw0bhlt8rkm1rRc6Afu sBfIU2iw0M+xKx8mrSrANryDnAobm1h8hhTcjU3EhK7W8GgNqEHYsYN41CtwwVIeSiOoHTiheTb0n HqpGpZ1QfGCVyQoB0IVBUba38TayorIKSp1MBpTirKNIpipBJobcvdGnqlOiIjDDwxVFFCNUB2CF3 0HsksG29SRgKoCrJN0NYT79j; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenaZ-0004ND-UC; Thu, 06 May 2021 23:39:27 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 23/31] rdma/siw: make use of __siw_cep_close() in siw_accept() Date: Fri, 7 May 2021 01:36:29 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This is basically the same just that the code in __siw_cep_close() common, it skips elements which are still NULL. Before it was really hard to prove that we don't deference NULL pointers. While developing my smbdirect driver, I hit so much crashes and deadlocks, so we better have code that's understandable. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Stefan Metzmacher Cc: Bernard Metzler Cc: linux-rdma@vger.kernel.org Reviewed-by: Bernard Metzler --- drivers/infiniband/sw/siw/siw_cm.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 09ae7f7ca82a..7fd67499f1d3 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1833,23 +1833,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) return 0; error: - siw_socket_disassoc(cep->sock); - sock_release(cep->sock); - cep->sock = NULL; - - cep->state = SIW_EPSTATE_CLOSED; - - if (cep->cm_id) { - cep->cm_id->rem_ref(id); - cep->cm_id = NULL; - } - if (qp->cep) { - siw_cep_put(cep); - qp->cep = NULL; - } - cep->qp = NULL; - siw_qp_put(qp); - + __siw_cep_close(cep); siw_cep_set_free(cep); siw_cep_put(cep); From patchwork Thu May 6 23:36:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92347C433ED for ; Thu, 6 May 2021 23:39:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E0D861164 for ; Thu, 6 May 2021 23:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232884AbhEFXkf (ORCPT ); Thu, 6 May 2021 19:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232877AbhEFXkf (ORCPT ); Thu, 6 May 2021 19:40:35 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25AFDC061761 for ; Thu, 6 May 2021 16:39:35 -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=ZsobkM1YfPjvMwiTYMVy+t1N2zoP6ZDVULTZ3u7YKE4=; b=iGlEwMOz41yv8LNNu/p+0O1LEW QAzpX0Ek+K1mUmyuKVC51lVgkJYJE3Obxxq+amh1YZ5n/YivCfu10chkEPByRXJjAbUrmTqUkKU2N /f1MChgVZ+JT4enjhd+LJIBBKW7uLf+gRWQrTViOBgMyViTiwDqHwO0jS8nICXBLIXqlP9H0KjRNu zfpKiSyR+nm4VDcGCM8l9hWCGF4W69+BNDriJy26pd+DU7KgapxiLpFRIs3ImlacR9RxiFErJUJ// WE2GEtEPFBjxjcA8zt2lmAmuZhuS1v3ov9gKeLIGmrVmCUXs6cRm5H6lHXt42fICtCDHWkRSdQMSj HZ4ieN8zc9QLfNy/rQWWSCrJw4oAEASNuM9CL9mAYgRttFE+Exc+s3MmxmZrdNFZn3txa8sMuHZNn TKJHJUzeMAZNDmmSx4kW6jQkBO86uWh97K8E2DZ/+C+OA7j/YDluM+bqZBuGWTvWrHKbv4B5Gx7Xt ki2alBLoM2fxVhpaRtbGoCbb; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenag-0004NX-Af; Thu, 06 May 2021 23:39:34 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 24/31] rdma/siw: do the full disassociation of cep and qp in siw_qp_llp_close() Date: Fri, 7 May 2021 01:36:30 +0200 Message-Id: <05e4a83a1b65d0cf47f4d0501f6dd081bce75602.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org It's much clearer to drop the references on both sides and reset the cross referencing pointers in one place. I makes the caller much saner and understandable. 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 | 2 -- drivers/infiniband/sw/siw/siw_qp.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 7fd67499f1d3..31135d877d41 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1240,10 +1240,8 @@ static void siw_cm_work_handler(struct work_struct *w) siw_cep_set_free(cep); siw_qp_llp_close(qp); - siw_qp_put(qp); siw_cep_set_inuse(cep); - cep->qp = NULL; siw_qp_put(qp); } if (cep->sock) { diff --git a/drivers/infiniband/sw/siw/siw_qp.c b/drivers/infiniband/sw/siw/siw_qp.c index ddb2e66f9f13..badb065eb9b1 100644 --- a/drivers/infiniband/sw/siw/siw_qp.c +++ b/drivers/infiniband/sw/siw/siw_qp.c @@ -166,8 +166,11 @@ void siw_qp_llp_close(struct siw_qp *qp) * Dereference closing CEP */ if (qp->cep) { + BUG_ON(qp->cep->qp != qp); + qp->cep->qp = NULL; siw_cep_put(qp->cep); qp->cep = NULL; + siw_qp_put(qp); } up_write(&qp->state_lock); From patchwork Thu May 6 23:36:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AACEC433ED for ; Thu, 6 May 2021 23:39:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF8AF61164 for ; Thu, 6 May 2021 23:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232877AbhEFXkl (ORCPT ); Thu, 6 May 2021 19:40:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232890AbhEFXkl (ORCPT ); Thu, 6 May 2021 19:40: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 8E26AC061761 for ; Thu, 6 May 2021 16:39:42 -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=suRtG7wCehN8DQZCt/GewGNzt5u6D3ch0EGVmqJ1cvw=; b=2LaG0ihGbW6NcZpneqZ/rkBq11 mhevPOXy03b47WpgNX3pqS7CTHPwoUI/1BbsveMbThBifH0eWEV+xfT6ePAEDDclqCbQoRR9umBJc sVQ4pkp4M++GgobpMZrt9DzWHdXKpzQ1YGGs/HOGMt7b+FDmTC1PmaaEnAyF2ibNkcX5Xra/BsiC7 Y8gBNYph5zRK9r+l6x0j+qE4whbhMtdvNs20wm1f19p56xEMjCY+1XbqOJ3S7+hr5uG91mQaAOfn7 7N1NhcxqblMM2p9bxNwp95jQHxA/qyjfiQn02hkYpZPRbErFu+UqNmPHVtvrkauByw45fC9HvxAT7 mLYH4c8aAFhbFqFZs20TVfzUdVX18DXpRESNFMQIDBfX/wCqTfuMTE4Nr/sOm55sauHyMT6iYU7y6 R3ScHRGMdfKf4a1AYCxnEfUoSMbCDknfBX1RAP8qFVHhOhak185RVRZLaYMmgAtvaUHgaeHCalbw1 8CFV3TOuYjcQvcVqLiD+Q1mU; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenam-0004Nw-NA; Thu, 06 May 2021 23:39:40 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 25/31] rdma/siw: fix double siw_cep_put() in siw_cm_work_handler() Date: Fri, 7 May 2021 01:36:31 +0200 Message-Id: <5f9dda492f0ff3ff0f858c9ee604f7ca8f179336.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We never do an additional siw_cep_get(cep) when calling id->add_ref(id), there's no reason to call siw_cep_put(cep) when calling cep->cm_id->rem_ref(cep->cm_id)! I saw this happening quite often while testing my smbdirect driver and the peer already reseted the tcp connection. 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 31135d877d41..a2a5a36370af 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1252,7 +1252,6 @@ static void siw_cm_work_handler(struct work_struct *w) if (cep->cm_id) { cep->cm_id->rem_ref(cep->cm_id); cep->cm_id = NULL; - siw_cep_put(cep); } } siw_cep_set_free(cep); From patchwork Thu May 6 23:36:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B915C433B4 for ; Thu, 6 May 2021 23:39:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F0F661164 for ; Thu, 6 May 2021 23:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232890AbhEFXks (ORCPT ); Thu, 6 May 2021 19:40:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbhEFXkr (ORCPT ); Thu, 6 May 2021 19:40:47 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8D92C061761 for ; Thu, 6 May 2021 16:39:48 -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=c2m/BivsbwLTT/EdW8cczakrbQ6UcyoLiKFwaX4IFWo=; b=j0agjUiLh8Vs4rGwd4wITPFdrS PyTbJeAz5NFWHK8VHtOrSUoiM9zKBQ+br4woGIJUKadYbdwdD4xN+H/ZJKVt/g5kNba5iRTFjMyWI 1DWDsyASIrpyJtsl/SC16Tu7tzUoyvNxUb5yNrfM+RnOtAgTbWHwqxThROH0j9v89UDU/CkjY5lWQ 6lm2/AdkRfKmL5QUXhdbBG9kIy6mjdFp63n0yMFpXejRfzK4rTxnJ3fJfAiDLHtHS4dR1TNdFMV7Q 3+RMseNEdjPGMc9+IvcXF/cK6UWdc4xkP8wuFPp5fOcgUBeqAY1bbguolb7Ot+o9y/fmYqq9OwvLt wRfNbkyW6Q+/eWxW3Y8mNdqAnLBVIJj/DchPWjkD+DKf5+xW2BqI5jOnSAvwdP2PMaxfpRPJPEXFc LMisJPj3l9q7vNj8hUsyzzj47rDFLNVTHKUENNRlRcID59Q4nblHIx3dwywfP5BJ2fupUdKDmixPe 1gkJ+cYSm7ioRJ1JF/2tJJfw; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenat-0004O8-0c; Thu, 06 May 2021 23:39:47 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 26/31] rdma/siw: make use of __siw_cep_close() in siw_cm_work_handler() Date: Fri, 7 May 2021 01:36:32 +0200 Message-Id: <3d322fc684f15f4658fb8489adaf15f22fd35c29.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We should always go to that common function in order to avoid potential problems in future. 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 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index a2a5a36370af..3dc80c21ac60 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1244,15 +1244,7 @@ static void siw_cm_work_handler(struct work_struct *w) siw_cep_set_inuse(cep); siw_qp_put(qp); } - if (cep->sock) { - siw_socket_disassoc(cep->sock); - sock_release(cep->sock); - cep->sock = NULL; - } - if (cep->cm_id) { - cep->cm_id->rem_ref(cep->cm_id); - cep->cm_id = NULL; - } + __siw_cep_close(cep); } siw_cep_set_free(cep); siw_put_work(work); From patchwork Thu May 6 23:36:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC502C433ED for ; Thu, 6 May 2021 23:39:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B14DA613BA for ; Thu, 6 May 2021 23:39:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232900AbhEFXky (ORCPT ); Thu, 6 May 2021 19:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbhEFXky (ORCPT ); Thu, 6 May 2021 19:40:54 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7833FC061574 for ; Thu, 6 May 2021 16:39:55 -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=yjCAzb3OrX6FYHNFPxKWeZzACgrDqv6fUiFQuSGKF+I=; b=Xgr81s44okSKOsPPocXNTb3XG7 qSU5Pq/a66JabEOX3OLfGrKhRRi07KjFAINaCLc0eCzhjZnVcykVIReuIQ2ZkrOLNiwcq6XNbzgcv 0IPJN+0ohChBnlNb+V4iQRKmNg+q9xO8fHJ0OTcdFYyoE63IkXGjtFx/oU2oSzPamVpp7TdECpnkW xATs3WpPuw0LripgZxIAM6zxBlyQq7dO0qQgBpNTn96xOusFTI9QNBGuthLWEeCuPFpHfn7gRzrJX YpcBCh+Gp5e3+RPASFrtIwNiEQMmayDQruQmZ9I0RpJJ2GbW7HewE5XyRv8LjX2V5Et1TayyMaX2x YAgB6sm7nKNNreo9z65F90l3xYw+zRCg49nFVicfRYgk+vUH2nkAKpizoTXQE/IelFSgyLWkQRGjb /UdErdHEpZ4NwuBQdZXIFNe2pn3Cwq62NwozrtzYWzFGKNIoOj5Uol2mskJc7F55BMS6+SfmtGJ1Q OofvLgKmxGq0LufKsuUpDlGf; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenaz-0004OM-JI; Thu, 06 May 2021 23:39:53 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 27/31] rdma/siw: fix the "close" logic in siw_qp_cm_drop() Date: Fri, 7 May 2021 01:36:33 +0200 Message-Id: <2a9916bda4eb2ec63fcbf8b01041723383c3f844.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org cep->cm_id->rem_ref(cep->cm_id) is no reason to call siw_cep_put(cep), we never call siw_cep_get(cep) when calling id->add_ref(id). But the cep->qp cleanup needs to drop both references! 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, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 3dc80c21ac60..9f9750237e75 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -546,7 +546,6 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule) if (cep->cm_id) { cep->cm_id->rem_ref(cep->cm_id); cep->cm_id = NULL; - siw_cep_put(cep); } cep->state = SIW_EPSTATE_CLOSED; @@ -559,8 +558,11 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule) cep->sock = NULL; } if (cep->qp) { + BUG_ON(cep->qp->cep != cep); + cep->qp->cep = NULL; + siw_qp_put(cep->qp); cep->qp = NULL; - siw_qp_put(qp); + siw_cep_put(cep); } out: siw_cep_set_free(cep); From patchwork Thu May 6 23:36:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88747C433B4 for ; Thu, 6 May 2021 23:40:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62FD861164 for ; Thu, 6 May 2021 23:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232910AbhEFXlB (ORCPT ); Thu, 6 May 2021 19:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbhEFXlA (ORCPT ); Thu, 6 May 2021 19:41:00 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3AF9C061574 for ; Thu, 6 May 2021 16:40:01 -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=5mLw9W9vQl9uvRSm5A7okVmcJ4Ft1ZKQRuubBosggWI=; b=tNr143gG4CHO1I2bXys3Q2NclR WiZ2It72L8rFJRZRQK785+W9aEudTHLeASQW0x2Jbw5KtSXeqplnUesJzKYW5SZvFG8rdAvP2PfQX +kpOCeGt170sBBM5KpbCp2VR1+bfaTHHu3J3X//WEB57668qpUy8/joG4g1LjtjtQ/ngL/HQJzRPS IurkJThxii0t/8Zt9cd6ZgyEuYOk5iJlhUX7adll3cirlzEZDjtBz2dn6zrtvfs1F3p8KJJ4nvbxh vAg5ayNSm8QG8GKzWRYnN87RpjSL6i64S0jhOnHrI5l6zuiAOnoMb1ROCRdHXIS3PKfIv5Bwk0WN7 yW6H8NaMLsZlIWZ4ku+IonNjiJZGmFdSvgz4YhmSzMqraMB8s726gvEmT3Ce6PEQUlB6MffT3UmG9 tCwFlT472xPFtvkggyiAQPzY8w6AVht2jowZMMd0D4nsfEdN5t8nCC+6UeN9YPUb0I0lE/jGgKdUE xmAlHA5Nq8NMLKKHN6cZrqPv; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenb5-0004OZ-VB; Thu, 06 May 2021 23:40:00 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 28/31] rdma/siw: make use of __siw_cep_close() in siw_qp_cm_drop() Date: Fri, 7 May 2021 01:36:34 +0200 Message-Id: <728163975670504e4401f73dcd9d6d18b56d1ba0.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Now that the logic is identical we better use the common function in order to avoid future problems. 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 | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 9f9750237e75..d2b1c62177ea 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -542,28 +542,7 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule) siw_dbg_cep(cep, "immediate close, state %d\n", cep->state); __siw_cep_terminate_upcall(cep, -EINVAL); - - if (cep->cm_id) { - cep->cm_id->rem_ref(cep->cm_id); - cep->cm_id = NULL; - } - cep->state = SIW_EPSTATE_CLOSED; - - if (cep->sock) { - siw_socket_disassoc(cep->sock); - /* - * Immediately close socket - */ - sock_release(cep->sock); - cep->sock = NULL; - } - if (cep->qp) { - BUG_ON(cep->qp->cep != cep); - cep->qp->cep = NULL; - siw_qp_put(cep->qp); - cep->qp = NULL; - siw_cep_put(cep); - } + __siw_cep_close(cep); out: siw_cep_set_free(cep); } From patchwork Thu May 6 23:36:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57360C433B4 for ; Thu, 6 May 2021 23:40:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C30B610FB for ; Thu, 6 May 2021 23:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232915AbhEFXlH (ORCPT ); Thu, 6 May 2021 19:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbhEFXlH (ORCPT ); Thu, 6 May 2021 19:41:07 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D9E5C061574 for ; Thu, 6 May 2021 16:40:08 -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=JbXbd0iFD8gwymEMDg823u7WKB24KxLxzjjSRxw9Ws0=; b=fp/VzCJubSnG8Yuso7CqXGZ3yt EJlhEk1DjLQj3eH9RICS6iY6xAF58i8peLW1sSmgYP6ZPJjv/1BuooP6TNboQZGhfIupuSoVCI6IF 2HqBDDdw6TgTB5t4TUAKfFQ1/+yEsUUVyS4OSRiC9UA0OzBW6otrrtHANDcfMJdCNqF4eUH/0LKic pie/TjkMlMLQbbhiioK16iufJGXK/ZXSxWHBKbNzcqIHf0f2Dy9amfuBajs/QQLChEbBg98yI9sY0 0/4GznWhUsLnnf91HA7goHXTBoKw/kYgdEaXy+rYcT3Q73Nv24RhO7qUqmXurgIXRaGB7+UhpHNC1 X93Y5SsxwG4laJAeTQZIHIY6E2gVmXtzO5LD8733CkZlFMX6m7qCLxaSFJUOAqw8M2abun4guJLbw eDekhMzvEnYgiWfivpC7HhOzTJ8t8HSndO0fJqvaUDIbok8l6lUn2+hS8SJqSwMkGpgEg4/+GfeXq Lr6PzXpZ4h8uwje9ZyFHwCUc; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenbC-0004Op-C1; Thu, 06 May 2021 23:40:06 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 29/31] rdma/siw: make use of __siw_cep_close() in siw_reject() Date: Fri, 7 May 2021 01:36:35 +0200 Message-Id: <41aaa6bb913455f197b189a36ebc033f31de66fa.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This is more or less a consistency change, we should always go via __siw_cep_close() to release the socket in order to avoid problems in future. 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 d2b1c62177ea..4b789379f676 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1841,12 +1841,8 @@ int siw_reject(struct iw_cm_id *id, const void *pdata, u8 pd_len) cep->mpa.hdr.params.bits |= MPA_RR_FLAG_REJECT; /* reject */ siw_send_mpareqrep(cep, pdata, pd_len); } - siw_socket_disassoc(cep->sock); - sock_release(cep->sock); - cep->sock = NULL; - - cep->state = SIW_EPSTATE_CLOSED; + __siw_cep_close(cep); siw_cep_set_free(cep); siw_cep_put(cep); From patchwork Thu May 6 23:36:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23CDCC433ED for ; Thu, 6 May 2021 23:40:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 031C0610FB for ; Thu, 6 May 2021 23:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232917AbhEFXlP (ORCPT ); Thu, 6 May 2021 19:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbhEFXlP (ORCPT ); Thu, 6 May 2021 19:41:15 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BA87C061574 for ; Thu, 6 May 2021 16:40:16 -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=NfDSBX6IPXDCcwgubDjXiXpObAHZuYoajksDZxW1F1g=; b=K6X2ShgP7+7tpFg2+8ZOnCqd75 MQGDC1osgcCRzDFQs7yJ8Z2G4kW3AazEjy2ScpRmky6i5qeKT/oO9OlWDxYQvTu3ged/6Rv0R0ump RocIIuj9SUf23zvkBYPLfEBva4CG7mFa8T4J0dCHtHA04MoPyvkE/Ucngb7l/9fOcmMlXRn80dGIc KxxEMjm4jpVipo5Tdgy8AW4jyDRlwz6Vdj6ZDajffSJJHpK9k8AD+G3uCFoZWTLMzSRkGJFKMQF/t d1GkhjRXFlPPXuW4f+cAOX7LSAN1sTzx1YEFjEl7nG6W7TAyRuaeGAmi2dK62RTGd8H9gDMblliIc BcEoLNQqveoRSSh+QXunEPbJi1M2m1skbhhp3HLhrB7hDpJkZRgGsIwZMRkDjPyAZRMHQgwDGT1oS BqgEP80dohxzuAjkQ+VHUuDo6qZVkR3DcDUG45ggKvibgRGBc//06YVGaieHY5xJ59tsY+Q/VboOI yqaPKy9yERkCKXJDLboZgUAn; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenbI-0004P2-Rm; Thu, 06 May 2021 23:40:13 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 30/31] rdma/siw: make use of __siw_cep_close() in siw_listen_address() Date: Fri, 7 May 2021 01:36:36 +0200 Message-Id: <66cf98af9f3cdf3111d79d7e076e3304ff9eb419.1620343860.git.metze@samba.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This is more or less a consistency change, we should always go via __siw_cep_close() to release the socket in order to avoid problems in future. 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 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 4b789379f676..49d01264682a 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1972,17 +1972,9 @@ int siw_create_listen(struct iw_cm_id *id, int backlog) error: siw_dbg(id->device, "failed: %d\n", rv); - if (cep->cm_id) { - cep->cm_id->rem_ref(cep->cm_id); - cep->cm_id = NULL; - } - cep->sock = NULL; - siw_socket_disassoc(s); - cep->state = SIW_EPSTATE_CLOSED; - + __siw_cep_close(cep); siw_cep_set_free(cep); siw_cep_put(cep); - sock_release(s); return rv; } From patchwork Thu May 6 23:36:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 12243679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 345B4C433ED for ; Thu, 6 May 2021 23:40:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1219761164 for ; Thu, 6 May 2021 23:40:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232927AbhEFXlZ (ORCPT ); Thu, 6 May 2021 19:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232934AbhEFXlW (ORCPT ); Thu, 6 May 2021 19:41:22 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F7CC061761 for ; Thu, 6 May 2021 16:40:22 -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=1LCOSH1ZG21310bxw+RF0Wm0jsU11rb9f/qSMeoC25s=; b=STqzINP7jiWet1U0vOt0iaoaEj 35ytJ6Zyqt5w25GMOvPgeve2dzf7VTg0TtRitBKlSO2Z76hwYJZFYh3tVi3n4FHHU1UMA0ujqZZLJ nxz00qFMAUMYQ8yrgL3PQDHt2s600KDvc6WPGiFte4ZZhxgteNu0ChExFXU+HGasVATXhnVSfoTXO h9bJzpk7d05ynkG205lEbZm/B5DG3BgWNHKslrqjbX8+8iahCuwV+vy99U8tDFUsr9MnVgNUtsyRj RPmsNOge/ixPHP7RPENpDTG+XsMHZV2vUbe3dK0JmAWC0Iuz0R0US2gE1CcglF/gh2oi+LMapmE4o 2cuZzzVGD5r7RWU4XTKZKip8KYCcqAdUE5GPWF4cvr8cUFovP3DQZkdcKTguVH//7U5AngBJu7BWU eLjPboAhHhES//KIeisOUg4/w5VhCbBbsCiMfavHkIqY32AwubjXkPgfmlQVULL2IphccjMVwOR87 XC6ilnVRC12edzrtdr1y3ohH; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim) id 1lenbP-0004PE-N5; Thu, 06 May 2021 23:40:20 +0000 From: Stefan Metzmacher To: Bernard Metzler Cc: linux-rdma@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 31/31] rdma/siw: make use of __siw_cep_close() in siw_drop_listeners() Date: Fri, 7 May 2021 01:36:37 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This is more or less a consistency change, we should always go via __siw_cep_close() to release the socket in order to avoid problems in future. 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, 1 insertion(+), 11 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 49d01264682a..58e965970f3e 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1995,17 +1995,7 @@ static void siw_drop_listeners(struct iw_cm_id *id) siw_dbg_cep(cep, "drop cep, state %d\n", cep->state); siw_cep_set_inuse(cep); - - if (cep->cm_id) { - cep->cm_id->rem_ref(cep->cm_id); - cep->cm_id = NULL; - } - if (cep->sock) { - siw_socket_disassoc(cep->sock); - sock_release(cep->sock); - cep->sock = NULL; - } - cep->state = SIW_EPSTATE_CLOSED; + __siw_cep_close(cep); siw_cep_set_free(cep); siw_cep_put(cep); }