From patchwork Fri Oct 23 07:43:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852407 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1DC46A2 for ; Fri, 23 Oct 2020 07:43:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F02D2192A for ; Fri, 23 Oct 2020 07:43:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="b8Df8JcM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S374559AbgJWHn6 (ORCPT ); Fri, 23 Oct 2020 03:43:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374512AbgJWHn6 (ORCPT ); Fri, 23 Oct 2020 03:43:58 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E62EC0613CE for ; Fri, 23 Oct 2020 00:43:57 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id z5so1042724ejw.7 for ; Fri, 23 Oct 2020 00:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HLm1LwNkrOc6cVasvNsJwbj1HCjyxWUB6ZkgiTWnMZs=; b=b8Df8JcMnqytudqMACQBZ059VzDEPsZSJPc/GQ916/OvvTdjZH7aDdLtkD1bmLBXxp eMaf4ounRtpfNfqGzmDxsU3dmXU0439f8LScvMI/GNBwHcCtxxNUKR8M53XOjTAcpNEa TUZrlHJp31+SP9c5IUJQzHXO7+7gwCAFVbSD1/6GfBsHjm8XvfX8L8Y0bAl68PE+N4wT sdFSGN4jA+VUTEvQbwNAhmJetBJobqlAfbrcNlTieyzLnhBOi9s/EGds+LkeOe+FIQO5 sl/AyfuBV0KDaFNorR2anCHIk9RQHS7ugIKEpmuS6AvCMjs2BWT6p66t/uc0lgCySxjW lZLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HLm1LwNkrOc6cVasvNsJwbj1HCjyxWUB6ZkgiTWnMZs=; b=NJD5J2xyNqJtIxfbMwLW4H8C4YKzQMFUmW8RWV1g4hTDC2QN8uMfgFD75mvbs0Hh+S wS6rFlaX4pG1jWLr80j0HVbmNK7u6zn5e5Wr2M4fWGKBla9AhMrKrqCB7F5mCtDwUWB3 tq7ksAIugWG5QGtx1JkDhxShNE7olD4mogkYk4zkezXinoSfRSTmnQZQawjhZhizlzJC 7NKos8HphmeyTvVN7ObwcNSJL/Acfy+qSTo/tvfOul4/PE4qnMuEBhpmEuHSp8Wq9R/K N3PTfZ7mejb7lMunNXDLSSexVGmBkriSdFSdQHmZvdPDjZhLy6AgY5IClLzd79iF6Xop C1+w== X-Gm-Message-State: AOAM5325bwwofQoqWXHJcWAGB+CKav70Im5Vf6/GNGHWgu5blxtlRwFQ S4MsaVBgOvrO54sFAM1eFvNFOwksPOapcw== X-Google-Smtp-Source: ABdhPJyyAgK7hcgsh1u/i6bLyadCV07Hh2rmrGbwbG7+PvC+4f81y8iwZKCRQEjdivhJSIKm/hvu0A== X-Received: by 2002:a17:906:3c03:: with SMTP id h3mr742063ejg.78.1603439035801; Fri, 23 Oct 2020 00:43:55 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:43:55 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com Subject: [PATCHv2 for-next 01/12] RDMA/rtrs-clt: remove destroy_con_cq_qp in case route resolving failed Date: Fri, 23 Oct 2020 09:43:42 +0200 Message-Id: <20201023074353.21946-2-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Danil Kipnis We call destroy_con_cq_qp(con) in rtrs_rdma_addr_resolved() in case route couldn't be resolved and then again in create_cm() because nothing happens. Don't call destroy_con_cq_qp from rtrs_rdma_addr_resolved, create_cm() does the clean up already. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Danil Kipnis Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 776e89231c52..9980bb4a6f78 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1640,10 +1640,8 @@ static int rtrs_rdma_addr_resolved(struct rtrs_clt_con *con) return err; } err = rdma_resolve_route(con->c.cm_id, RTRS_CONNECT_TIMEOUT_MS); - if (err) { + if (err) rtrs_err(s, "Resolving route failed, err: %d\n", err); - destroy_con_cq_qp(con); - } return err; } From patchwork Fri Oct 23 07:43:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852411 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D5FB15E6 for ; Fri, 23 Oct 2020 07:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1874221D47 for ; Fri, 23 Oct 2020 07:44:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="BT6kP5hi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375767AbgJWHoA (ORCPT ); Fri, 23 Oct 2020 03:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374512AbgJWHoA (ORCPT ); Fri, 23 Oct 2020 03:44:00 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B0A1C0613D2 for ; Fri, 23 Oct 2020 00:43:58 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a3so1022371ejy.11 for ; Fri, 23 Oct 2020 00:43:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LNhaVGuLfGJxt2upLMkHxMIuPnCfXPmkuUGTrNLSfkQ=; b=BT6kP5hinfIdc7n0NZXtUnQQ9ic3ug+TleL7om+3yh9kyg4gTA/bIWS5WCiwPlNaEj QyJsYo6KNmE6lSyw/u9qpPu5b9E7/vbarKJjE1ibBPGOs9g4HcryRsVq0toc0A0/NBPM 9gp38aTAiN/xdX74rZ95T6SCXgRjtQeXylP4rRgwsS5HyZVtDIUb4lRmZ8BPTRbdhvPj w4aq6VNZ8NiqKQhBxXF8Hinw4eXjey0tE2Kn6D30QidE1SBr9xnvZWfeoRZ2MYcEsC/B PKC2s/0Xy0IPCClwTKY88fjGrYceyYWQID5VHbB3gs0/S8gkazhvkr1+hDf/eAhJLhJ/ rEQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LNhaVGuLfGJxt2upLMkHxMIuPnCfXPmkuUGTrNLSfkQ=; b=lyna2Kl3SNtl4rbhfR8gHDTjADN8UvfLzQD4uOCAHyjHzRcjOk+P/D0UjltrWb9WIS 2vBQhu6IyJdJNf0aeIO7LDVcWri3nXwyeDR94pYy+lNQLJIO4ZE8PPiXoZs4tgsyMLAy +Jpq3yYbk1Wcc6/PcL9b33DoHFzff0Oyv2OtLecUvAG2ASrGSc8jRC71RpL00lnSJSxH 06S2E01wF6uvI337GCwWaKU7wLpuIUH3fbSupSZ11ustkgQL77ZRU1AdX8/rsp1QZ9Jg 8466u+VX18n6b4pufhUE9Mln984bvnJno0xTAx/HkxHlRPluXGqjD3ySHAC76cqSI9Cl cU2g== X-Gm-Message-State: AOAM533lNJur2jJV1gSWUiTcHNUsTmbRnRJab82rLPqgTohiC8ePJcAV iH5MHAxf4ERMQ8jvpDn3sKnJe2Oi5Lp53g== X-Google-Smtp-Source: ABdhPJz4Dm2vv185LZ3bwhDxNrc0UWZEVVqQgkUIK1Az78CjFbbN3VfKR74MafSPe3nswFPfary7Uw== X-Received: by 2002:a17:906:1299:: with SMTP id k25mr755091ejb.201.1603439036781; Fri, 23 Oct 2020 00:43:56 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:43:56 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 02/12] RDMA/rtrs-clt: remove outdated comment in create_con_cq_qp Date: Fri, 23 Oct 2020 09:43:43 +0200 Message-Id: <20201023074353.21946-3-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org As run destroy_con_cq_qp many times doesn't work, remove the comments. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Suggested-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 9980bb4a6f78..fb840b152b37 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1520,15 +1520,6 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; - /* - * This function can fail, but still destroy_con_cq_qp() should - * be called, this is because create_con_cq_qp() is called on cm - * event path, thus caller/waiter never knows: have we failed before - * create_con_cq_qp() or after. To solve this dilemma without - * creating any additional flags just allow destroy_con_cq_qp() be - * called many times. - */ - if (con->c.cid == 0) { /* * One completion for each receive and two for each send From patchwork Fri Oct 23 07:43:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852409 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C488992C for ; Fri, 23 Oct 2020 07:44:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99DAC21D47 for ; Fri, 23 Oct 2020 07:44:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="UXPqOAK3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375763AbgJWHoA (ORCPT ); Fri, 23 Oct 2020 03:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374512AbgJWHn7 (ORCPT ); Fri, 23 Oct 2020 03:43:59 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EC46C0613CE for ; Fri, 23 Oct 2020 00:43:59 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id t25so1013227ejd.13 for ; Fri, 23 Oct 2020 00:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T64CeVHz2c2Fu8Ot+IkGyFuzsWlnfqfpHdTmtUIvzdQ=; b=UXPqOAK3jZz/tURbCkKvEjOrkgQ+mf3rDiFTh+czpvt43Sv+sSekIsEsGcb03H0SV+ h00ok5JcscwJXud4QldLt5ChPwG1zI4oupevmINzoEJtLcXf91hxAIMeIJ4CXLxT2KTu 3TzCFll21b989FNHcBgfhi6i3epl/fSq7n0F/BD5H2UNCRzdc0YYzdINMinTRmAYsm1v BDCUWCJVPefh+dE6OmccFtM8ViJJ8NfyEAPD467PSk95ExTFBJhe8w8eBNAlkA3D5Slo G+ybGLyWG+JxS1LMno9yqsa6PmgpUW+b1JhFjK6Expcm5gftKj/hQ6ivJIVBndPwII0b 8PfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T64CeVHz2c2Fu8Ot+IkGyFuzsWlnfqfpHdTmtUIvzdQ=; b=iBpbrlxrGSXUiV7ZbqAEippIuj398QIHy8q1CDB+36Gzck4Y/NM2awlSyIuKKVctla 0yvsLVhmlm6WNVYlAULfxZhhlECr9uRklSBoD49ZZa8TZNEIk0Bd6aQ+HjIK67iaIbma GEVxh/8EnVydKcQ0RsWTNxu2zuSfV+tnPmqwa0kcIFDgMG8f7vMj9pZXJFiUN9tH51wh ZyBbp+Y+e04NawRWi+8XGK3XjkqQLAsy/Xt/qQFS6ZdsUglChUdggoul1YJdSi/x5t7b /50OhzzHbrMvgn1sH22XCRa9xxVqRkn/8cOTXCOAV7qUdFjyrs9/4X9w9Tg/muvNRIUp NXZQ== X-Gm-Message-State: AOAM532OcnUDODMy/a74F73kmxTWkGzj2oYP8fgghJ3L7i9UYlQT7Bnr 6WV8lexFKEzGgFiQwI4rZC6b9K+zBbLPtg== X-Google-Smtp-Source: ABdhPJy3SCFbQ1cupHAtVQxHS7IDlBPvysvpSx/22xQDeqCfWCKbOGv75bUsvVSOPyAJnAFx+fyDVw== X-Received: by 2002:a17:907:43c0:: with SMTP id ok24mr716043ejb.385.1603439037779; Fri, 23 Oct 2020 00:43:57 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:43:57 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 03/12] RDMA/rtrs-clt: avoid run destroy_con_cq_qp/create_con_cq_qp in parallel Date: Fri, 23 Oct 2020 09:43:44 +0200 Message-Id: <20201023074353.21946-4-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org It could happen two kworkers race with each other: addr_resolver kworker reconnect kworker rtrs_clt_rdma_cm_handler rtrs_rdma_addr_resolved create_con_cq_qp: s.dev_ref++ "s.dev_ref is 1" wait in create_cm fails with TIMEOUT destroy_con_cq_qp: --s.dev_ref "s.dev_ref is 0" destroy_con_cq_qp: sess->s.dev = NULL rtrs_cq_qp_create -> create_qp(con, sess->dev->ib_pd...) sess->dev is NULL, panic. To fix the problem using mutex to serialize create_con_cq_qp and destroy_con_cq_qp. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Jack Wang Reviewed-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 15 +++++++++++++-- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index fb840b152b37..4677e8ed29ae 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1499,6 +1499,7 @@ static int create_con(struct rtrs_clt_sess *sess, unsigned int cid) con->c.cid = cid; con->c.sess = &sess->s; atomic_set(&con->io_cnt, 0); + mutex_init(&con->con_mutex); sess->s.con[cid] = &con->c; @@ -1510,6 +1511,7 @@ static void destroy_con(struct rtrs_clt_con *con) struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); sess->s.con[con->c.cid] = NULL; + mutex_destroy(&con->con_mutex); kfree(con); } @@ -1520,6 +1522,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; + lockdep_assert_held(&con->con_mutex); if (con->c.cid == 0) { /* * One completion for each receive and two for each send @@ -1593,7 +1596,7 @@ static void destroy_con_cq_qp(struct rtrs_clt_con *con) * Be careful here: destroy_con_cq_qp() can be called even * create_con_cq_qp() failed, see comments there. */ - + lockdep_assert_held(&con->con_mutex); rtrs_cq_qp_destroy(&con->c); if (con->rsp_ius) { rtrs_iu_free(con->rsp_ius, DMA_FROM_DEVICE, @@ -1625,7 +1628,9 @@ static int rtrs_rdma_addr_resolved(struct rtrs_clt_con *con) struct rtrs_sess *s = con->c.sess; int err; + mutex_lock(&con->con_mutex); err = create_con_cq_qp(con); + mutex_unlock(&con->con_mutex); if (err) { rtrs_err(s, "create_con_cq_qp(), err: %d\n", err); return err; @@ -1938,8 +1943,9 @@ static int create_cm(struct rtrs_clt_con *con) errr: stop_cm(con); - /* Is safe to call destroy if cq_qp is not inited */ + mutex_lock(&con->con_mutex); destroy_con_cq_qp(con); + mutex_unlock(&con->con_mutex); destroy_cm: destroy_cm(con); @@ -2046,7 +2052,9 @@ static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_sess *sess) if (!sess->s.con[cid]) break; con = to_clt_con(sess->s.con[cid]); + mutex_lock(&con->con_mutex); destroy_con_cq_qp(con); + mutex_unlock(&con->con_mutex); destroy_cm(con); destroy_con(con); } @@ -2213,7 +2221,10 @@ static int init_conns(struct rtrs_clt_sess *sess) struct rtrs_clt_con *con = to_clt_con(sess->s.con[cid]); stop_cm(con); + + mutex_lock(&con->con_mutex); destroy_con_cq_qp(con); + mutex_unlock(&con->con_mutex); destroy_cm(con); destroy_con(con); } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index 167acd3c90fc..b8dbd701b3cb 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -72,6 +72,7 @@ struct rtrs_clt_con { struct rtrs_iu *rsp_ius; u32 queue_size; unsigned int cpu; + struct mutex con_mutex; atomic_t io_cnt; int cm_err; }; From patchwork Fri Oct 23 07:43:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852415 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DC3615E6 for ; Fri, 23 Oct 2020 07:44:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C95621D47 for ; Fri, 23 Oct 2020 07:44:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="Ksr4VU5E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375768AbgJWHoC (ORCPT ); Fri, 23 Oct 2020 03:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S375769AbgJWHoB (ORCPT ); Fri, 23 Oct 2020 03:44:01 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28FEEC0613CE for ; Fri, 23 Oct 2020 00:44:00 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id p9so1058824eji.4 for ; Fri, 23 Oct 2020 00:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NjgVVeV7ye/lxK4uc/5lZilh6HVPNP9zhUrFloHljoY=; b=Ksr4VU5EnyUfX2IlPQaXkoQRoH3HyD3WF+G0kXc9AZlV8q9NzmAmxN/sVcS4zCMd3T owygceoGxA6D+2r8X67ZIcsST1ixX4O0lZne+NzlC7wowRYXJ4itdGjvlaxcajb/UAEY kP5sjgwOnJCL7kZgcvTcsJCjkjGlWlw7dgRzXwW7UUxfzF5OP42R0j31fvXohBz+wHZ0 9hskyrt+Pd1XB318aUW+MabgkkLiQoHpH4HXAtaymYBWJe6berRAX/OvOh6ZFe1Gq44O lLbQrfoJQ/mRDaZD5c1ekucPODo9rV6HhdrBEDNC0/0908N07T530L10k/ZD9n2bHw3O eAlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NjgVVeV7ye/lxK4uc/5lZilh6HVPNP9zhUrFloHljoY=; b=rB+JS4xomWM++FueCWrTlT+h7JBm43XSo9M1/ZCS9sy0u2IZfBMaQ/Cu8/2JoE1ZWy QArp1hbjRgmrFHcE6/nZaslKTHVNzGE3YUf9z+sGxapFz0/4n7Epg+yTrFHhkq4uV5qu CZ1vXHJqP381iKiui/ta5pxfW8Ocy5aBY/DQE7AfeoCM1tuXjCw2HJTdpWJD6+D5+ydE kQLpLG0P9EYhxxC2VEd1mvrwQQP0qrdW4WNC+5oK9ZrmOTlAinKV2gDVFleYSmyIKvNq PLMtbYS7EObjICV3PQTphJXSUv04TJ8lWtxUc7BwNkeanah2hiWA/SYh+kMgHXIjsXwS jCYw== X-Gm-Message-State: AOAM5336CgGqaH8AHXsVFPIxebW6tbRBiyzQt6YL0bzNFKIaIqfZ/mcw GrzveRhh6fCcvmjl0Su3Xb2XdYtyZh2/Hw== X-Google-Smtp-Source: ABdhPJxn1jygWe8e5NbQyYVmgVs/AYH3SpD/Jr2wU3HNRdujWIzFPvO7gGCMFzmnFMYiQOp2L9i/sQ== X-Received: by 2002:a17:906:1107:: with SMTP id h7mr706251eja.481.1603439038734; Fri, 23 Oct 2020 00:43:58 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:43:58 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 04/12] RDMA/rtrs-clt: missing error from rtrs_rdma_conn_established Date: Fri, 23 Oct 2020 09:43:45 +0200 Message-Id: <20201023074353.21946-5-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim When rtrs_rdma_conn_established returns error (non-zero value), the error value is stored in con->cm_err and it cannot trigger rtrs_rdma_error_recovery. Finally the error of rtrs_rdma_con_established will be forgot. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 4677e8ed29ae..ffca004625bb 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1831,8 +1831,8 @@ static int rtrs_clt_rdma_cm_handler(struct rdma_cm_id *cm_id, cm_err = rtrs_rdma_route_resolved(con); break; case RDMA_CM_EVENT_ESTABLISHED: - con->cm_err = rtrs_rdma_conn_established(con, ev); - if (likely(!con->cm_err)) { + cm_err = rtrs_rdma_conn_established(con, ev); + if (likely(!cm_err)) { /* * Report success and wake up. Here we abuse state_wq, * i.e. wake up without state change, but we set cm_err. From patchwork Fri Oct 23 07:43:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852413 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D39C76A2 for ; Fri, 23 Oct 2020 07:44:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF1BA21D47 for ; Fri, 23 Oct 2020 07:44:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="BqWS6Yls" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375770AbgJWHoC (ORCPT ); Fri, 23 Oct 2020 03:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S375768AbgJWHoB (ORCPT ); Fri, 23 Oct 2020 03:44:01 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BC89C0613D2 for ; Fri, 23 Oct 2020 00:44:01 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id gs25so1070327ejb.1 for ; Fri, 23 Oct 2020 00:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=diduN3jCpnaYzfrSilCGd45/1ZVjBQlx57tpnHfb60U=; b=BqWS6YlsUUTH9KlBAdrNo3o/5AyCC2ydjA06Cg5GTkWTuDaLi/rfZnAp9MqW4+TUUt /h3T+WgQxQn5XilDWMCXpMjvqCutufHRFUKrN3PMIBa2SNmyPdgkFCHMkO8WrOYVnUzn FGLnel/GacXOaOGKBrcfXond0l/oBfGUdLAF2mkQTIJOIFODdpwMPa90bn8ELXBEOy0k gc1hLfIaqDVShPBkPP41S831FusTvEcEoxmdcTy78lF3tOcfgQvjoc15SxC8KvjCHsvX ++SvGHVaxWvS0gJUSVD9S3AurGOxdZnzGYaSb7w8e58GONIg+yWmebZgA13Q62gKwOvs 09HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=diduN3jCpnaYzfrSilCGd45/1ZVjBQlx57tpnHfb60U=; b=JReBFTIGVj4japGQMFM1IkSVtvDfMqfumScrukwi4FCxAzBBSRJE1KvJKQk/dvQrA5 V9/33k7Wn6q2fT5lJwwEnrHwzPloeMsVjcd/X3RfQV2Mge9OnRI4f1bf6+WPpGrlBHId s20A7OpN5M4FamQ7eYkTFbS3xY1C2BfXhVY8vloEHOjUteBL0DtSaIZiiUUWQZrn1lm4 dSxU7CQRLkOmE5NjJts43dbQbIuj47I8kyCsqFvFdBg/PISURxTxtD18uzcWDAoewOhl 7+osQ6Iw8hIx6smoEzAgFHLuMcLs04p65bAQwWehbJauorTKzT6M4V4JOSi0Ta7mjl3g lUvw== X-Gm-Message-State: AOAM533WP6djAofpY01VLEONhH9255Od/sxgorEWWcrOop3CrlE7Q669 50PCJFmwMXBSLNPuVW3XQ7PnrcKhsR5Tgg== X-Google-Smtp-Source: ABdhPJzcAUtTejlea70AuXFSEYK3JG8swW+BrJyOmTDQuc3VI0N4Olqh3GNKSzbrkxy7kiwslboKpw== X-Received: by 2002:a17:906:76d5:: with SMTP id q21mr757957ejn.415.1603439039639; Fri, 23 Oct 2020 00:43:59 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:43:59 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 05/12] RDMA/rtrs-srv: don't guard the whole __alloc_srv with srv_mutex Date: Fri, 23 Oct 2020 09:43:46 +0200 Message-Id: <20201023074353.21946-6-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang The purpose of srv_mutex is to protect srv_list as in put_srv, so no need to hold it when allocate memory for srv since it could be time consuming. Otherwise if one machine has limited memory, rsrv_close_work could be blocked for a longer time due to the mutex is held by get_or_create_srv since it can't get memory in time. [13327733.807781] INFO: task kworker/1:1:27478 blocked for more than 120 seconds. [13327733.854623] Tainted: G O 4.14.171-1-storage #4.14.171-1.3~deb9 [13327733.902461] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [13327733.953930] kworker/1:1 D 0 27478 2 0x80000000 [13327733.953938] Workqueue: rtrs_server_wq rtrs_srv_close_work [rtrs_server] [13327733.953939] Call Trace: [13327733.953945] ? __schedule+0x38c/0x7e0 [13327733.953946] schedule+0x32/0x80 [13327733.953948] schedule_preempt_disabled+0xa/0x10 [13327733.953949] __mutex_lock.isra.2+0x25e/0x4d0 [13327733.953954] ? put_srv+0x44/0x100 [rtrs_server] [13327733.953958] put_srv+0x44/0x100 [rtrs_server] [13327733.953961] rtrs_srv_close_work+0x16c/0x280 [rtrs_server] [13327733.953966] process_one_work+0x1c5/0x3c0 [13327733.953969] worker_thread+0x47/0x3e0 [13327733.953970] kthread+0xfc/0x130 [13327733.953972] ? trace_event_raw_event_workqueue_execute_start+0xa0/0xa0 [13327733.953973] ? kthread_create_on_node+0x70/0x70 [13327733.953974] ret_from_fork+0x1f/0x30 Let's move all the logics from __find_srv_and_get and __alloc_srv to get_or_create_srv, and remove the two functions. Then it should be safe for multiple processes to access the same srv since it is protected with srv_mutex. And since we don't want to allocate chunks with srv_mutex held, let's check the srv->refcount after get srv because the chunks could not be allocated yet. Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality") Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 86 +++++++++++--------------- 1 file changed, 37 insertions(+), 49 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index d6f93601712e..1cb778aff3c5 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1328,17 +1328,42 @@ static void rtrs_srv_dev_release(struct device *dev) kfree(srv); } -static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx, - const uuid_t *paths_uuid) +static void free_srv(struct rtrs_srv *srv) +{ + int i; + + WARN_ON(refcount_read(&srv->refcount)); + for (i = 0; i < srv->queue_depth; i++) + mempool_free(srv->chunks[i], chunk_pool); + kfree(srv->chunks); + mutex_destroy(&srv->paths_mutex); + mutex_destroy(&srv->paths_ev_mutex); + /* last put to release the srv structure */ + put_device(&srv->dev); +} + +static struct rtrs_srv *get_or_create_srv(struct rtrs_srv_ctx *ctx, + const uuid_t *paths_uuid) { struct rtrs_srv *srv; int i; + mutex_lock(&ctx->srv_mutex); + list_for_each_entry(srv, &ctx->srv_list, ctx_list) { + if (uuid_equal(&srv->paths_uuid, paths_uuid) && + refcount_inc_not_zero(&srv->refcount)) { + mutex_unlock(&ctx->srv_mutex); + return srv; + } + } + + /* need to allocate a new srv */ srv = kzalloc(sizeof(*srv), GFP_KERNEL); - if (!srv) + if (!srv) { + mutex_unlock(&ctx->srv_mutex); return NULL; + } - refcount_set(&srv->refcount, 1); INIT_LIST_HEAD(&srv->paths_list); mutex_init(&srv->paths_mutex); mutex_init(&srv->paths_ev_mutex); @@ -1347,6 +1372,8 @@ static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx, srv->ctx = ctx; device_initialize(&srv->dev); srv->dev.release = rtrs_srv_dev_release; + list_add(&srv->ctx_list, &ctx->srv_list); + mutex_unlock(&ctx->srv_mutex); srv->chunks = kcalloc(srv->queue_depth, sizeof(*srv->chunks), GFP_KERNEL); @@ -1358,7 +1385,7 @@ static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx, if (!srv->chunks[i]) goto err_free_chunks; } - list_add(&srv->ctx_list, &ctx->srv_list); + refcount_set(&srv->refcount, 1); return srv; @@ -1369,52 +1396,9 @@ static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx, err_free_srv: kfree(srv); - return NULL; } -static void free_srv(struct rtrs_srv *srv) -{ - int i; - - WARN_ON(refcount_read(&srv->refcount)); - for (i = 0; i < srv->queue_depth; i++) - mempool_free(srv->chunks[i], chunk_pool); - kfree(srv->chunks); - mutex_destroy(&srv->paths_mutex); - mutex_destroy(&srv->paths_ev_mutex); - /* last put to release the srv structure */ - put_device(&srv->dev); -} - -static inline struct rtrs_srv *__find_srv_and_get(struct rtrs_srv_ctx *ctx, - const uuid_t *paths_uuid) -{ - struct rtrs_srv *srv; - - list_for_each_entry(srv, &ctx->srv_list, ctx_list) { - if (uuid_equal(&srv->paths_uuid, paths_uuid) && - refcount_inc_not_zero(&srv->refcount)) - return srv; - } - - return NULL; -} - -static struct rtrs_srv *get_or_create_srv(struct rtrs_srv_ctx *ctx, - const uuid_t *paths_uuid) -{ - struct rtrs_srv *srv; - - mutex_lock(&ctx->srv_mutex); - srv = __find_srv_and_get(ctx, paths_uuid); - if (!srv) - srv = __alloc_srv(ctx, paths_uuid); - mutex_unlock(&ctx->srv_mutex); - - return srv; -} - static void put_srv(struct rtrs_srv *srv) { if (refcount_dec_and_test(&srv->refcount)) { @@ -1813,7 +1797,11 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, } recon_cnt = le16_to_cpu(msg->recon_cnt); srv = get_or_create_srv(ctx, &msg->paths_uuid); - if (!srv) { + /* + * "refcount == 0" happens if a previous thread calls get_or_create_srv + * allocate srv, but chunks of srv are not allocated yet. + */ + if (!srv || refcount_read(&srv->refcount) == 0) { err = -ENOMEM; goto reject_w_err; } From patchwork Fri Oct 23 07:43:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852419 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F165E15E6 for ; Fri, 23 Oct 2020 07:44:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAFD720936 for ; Fri, 23 Oct 2020 07:44:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="WXvwE9tc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375769AbgJWHoE (ORCPT ); Fri, 23 Oct 2020 03:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374490AbgJWHoD (ORCPT ); Fri, 23 Oct 2020 03:44:03 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01AE6C0613CE for ; Fri, 23 Oct 2020 00:44:02 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id p5so1062233ejj.2 for ; Fri, 23 Oct 2020 00:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JfZtk3pjF4WlFpJWibZh2FBLGDetHSR9s/tKhrXEPr8=; b=WXvwE9tcHGlufbxdJd07cJJn7qvGpGJ8k8lhmivlnr/rDfhGcUDVsVS759dA0FPbzL ol6XdTx4lyYDDyEOTvXpnO0Anmm9IlXCRW8uemuJSPJ5i2J8L+r6pOcoWXPPR51Vsk8I EdEJN8wHca0aHvLaDrx9qYlWhkdNG5aHWk+YHu0unysZTRwt6bDBCWMrY0r7pP6WHX/t leB6St96t70TddstRI/d1OfsgZfVVoWvN9gdhqr5uYwbiMbI9kwDrfJ5RCoFEsSCb66I QvVPgw0AHdQ2j7tQG64Ar/BUhAwYOapsvrKL51up0KrUt0SUYwZSLZS87cvNye6LZ9Ls tEfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JfZtk3pjF4WlFpJWibZh2FBLGDetHSR9s/tKhrXEPr8=; b=rTpEU1lY4Tu8cnrSgH9w5HnThwnl7mJ6H6FfpIjQSn8E3c6gj0wsfGm0okeVKfamNb cGWlBFun13XS9ekZa0OjN9NNDECu8zSt5FOdmzajH8QWGA0Dtaaj5LLqILvuXGcKduq6 Hl7qbtyMLQP1uJRruc2JMgJzcEXZviy4m/+JlWwt9w5gopVjEzV8Hp1JM5NwfNLR+s11 +EDriVizjBHL/ZuD8gkEkN65Ma9RZ3b7OWRprtcTZFc3F1bda6WrWPJcy8w/EX1/sRYX pYwTKO97l6MhdlSDq0466FeJfcl7xrUn2hi9VZ6XFo0t7MDOURxK5BfsQigSu3kB1QRb Z0Ag== X-Gm-Message-State: AOAM531wq5v4IDGca1rnq9H2TGJtaOd3C71xy5uTACWXx3AJQNhJhv45 eRngLRU05xC1L+yGX5msHTILUbzSfFZBnQ== X-Google-Smtp-Source: ABdhPJyK7dW9NhUIx8fzLZofkA5C/rJ3INQfFYnOkWJbLzHbBfyM1U2xbWK/Zf/7yfQNhOdg7aeAXQ== X-Received: by 2002:a17:906:30c8:: with SMTP id b8mr798723ejb.77.1603439040610; Fri, 23 Oct 2020 00:44:00 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:44:00 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 06/12] RDMA/rtrs-srv: fix typo Date: Fri, 23 Oct 2020 09:43:47 +0200 Message-Id: <20201023074353.21946-7-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang It should mean region here. Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality") Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.h b/drivers/infiniband/ulp/rtrs/rtrs-srv.h index 08b0b8a6eebe..9543ae19996c 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.h @@ -62,7 +62,7 @@ struct rtrs_srv_op { /* * server side memory region context, when always_invalidate=Y, we need - * queue_depth of memory regrion to invalidate each memory region. + * queue_depth of memory region to invalidate each memory region. */ struct rtrs_srv_mr { struct ib_mr *mr; From patchwork Fri Oct 23 07:43:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852417 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B939C92C for ; Fri, 23 Oct 2020 07:44:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8435D2192A for ; Fri, 23 Oct 2020 07:44:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="JH4EZey2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375772AbgJWHoD (ORCPT ); Fri, 23 Oct 2020 03:44:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S375769AbgJWHoD (ORCPT ); Fri, 23 Oct 2020 03:44:03 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E079C0613D2 for ; Fri, 23 Oct 2020 00:44:03 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id z5so1043052ejw.7 for ; Fri, 23 Oct 2020 00:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hge50L29ZsVgErfWWa2RPsI6x8iu3oUMD6GehXNGpLI=; b=JH4EZey2njRcJ865np/Ukxo40mhCSsU1h0DA0dIwBnryeYRQSEEiDhNnu3gez98/jb HAGK789iW2F69m1XkIE2TPf1vw8dpwjL9RIEKBl2STjVh+eTcxfieC3DhBcIFQyJyBhF HAKzEI0//gvlcc9Z3qDZwJ1L6TDj50+w6JvivULT3To+X6Q7DaQACBDD2FhlUdLPO/qs Xzl0V8tkIBch0ZU1h/lAI9+/u63m9PYDZ1OLs0qC/cG+7jYMrVg36M48hN0vbWMKWJBi vmADp0fo84u6i5IsPeYp2IBJ5jDFDO1FKDWms916URHTmNqKaafm3xGNWynjtBD9CFTU a6Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hge50L29ZsVgErfWWa2RPsI6x8iu3oUMD6GehXNGpLI=; b=gWmZB5rsVn1xjh3ZCdViOrNqPj3F09snw3PR1Xe6hDJj0Ie2wh7LtdGZNW9uQj7JW7 0QdVBqp8r0FRksaYHFDQqrdv99/avznWIP5C8KEfHieJoYwRrnjy3o7faUGsYGChS4me +cgAAdyLPQi5Z6E9B4bmDrqqKQn3YlWDtMxpERJ42gyz9eQLMC22SXXEcarK/e8NK8ul 45nfmhsza9WU76y+FRmDtP+ayLspBomX90NSYGbfc6tmgxveGlGV6gc7qzlZQ0gG5idR F/l1y6W8Rs0ReZyPcV0c9V1FEw7QVHCQ0t2rVAlvlCCs9pdU+kn7W+aqAwylfUb9xCA+ idtg== X-Gm-Message-State: AOAM533aNy2oZU4sebVI/I+g/cobLpvnukuBZkc5CLCGaheNsXlvf2dq 6K1SyVKAbMSJmciIk/P247NHpCbrBTvF1w== X-Google-Smtp-Source: ABdhPJzbnqcbDNw0mJb3SA/nuB0TpkEbYSMp4o6rlrsgQ597TG0khTc5CjhYaQ8z31+WyQFRoihcog== X-Received: by 2002:a17:907:70cb:: with SMTP id yk11mr755408ejb.122.1603439041550; Fri, 23 Oct 2020 00:44:01 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:44:01 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 07/12] RDMA/rtrs: remove unnecessary argument dir of rtrs_iu_free Date: Fri, 23 Oct 2020 09:43:48 +0200 Message-Id: <20201023074353.21946-8-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim The direction of DMA operation is already in the rtrs_iu Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 14 ++++++-------- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 3 +-- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 14 ++++++-------- drivers/infiniband/ulp/rtrs/rtrs.c | 9 ++++----- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index ffca004625bb..4e5da834034a 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1236,8 +1236,7 @@ static void free_sess_reqs(struct rtrs_clt_sess *sess) if (req->mr) ib_dereg_mr(req->mr); kfree(req->sge); - rtrs_iu_free(req->iu, DMA_TO_DEVICE, - sess->s.dev->ib_dev, 1); + rtrs_iu_free(req->iu, sess->s.dev->ib_dev, 1); } kfree(sess->reqs); sess->reqs = NULL; @@ -1599,8 +1598,7 @@ static void destroy_con_cq_qp(struct rtrs_clt_con *con) lockdep_assert_held(&con->con_mutex); rtrs_cq_qp_destroy(&con->c); if (con->rsp_ius) { - rtrs_iu_free(con->rsp_ius, DMA_FROM_DEVICE, - sess->s.dev->ib_dev, con->queue_size); + rtrs_iu_free(con->rsp_ius, sess->s.dev->ib_dev, con->queue_size); con->rsp_ius = NULL; con->queue_size = 0; } @@ -2245,7 +2243,7 @@ static void rtrs_clt_info_req_done(struct ib_cq *cq, struct ib_wc *wc) struct rtrs_iu *iu; iu = container_of(wc->wr_cqe, struct rtrs_iu, cqe); - rtrs_iu_free(iu, DMA_TO_DEVICE, sess->s.dev->ib_dev, 1); + rtrs_iu_free(iu, sess->s.dev->ib_dev, 1); if (unlikely(wc->status != IB_WC_SUCCESS)) { rtrs_err(sess->clt, "Sess info request send failed: %s\n", @@ -2374,7 +2372,7 @@ static void rtrs_clt_info_rsp_done(struct ib_cq *cq, struct ib_wc *wc) out: rtrs_clt_update_wc_stats(con); - rtrs_iu_free(iu, DMA_FROM_DEVICE, sess->s.dev->ib_dev, 1); + rtrs_iu_free(iu, sess->s.dev->ib_dev, 1); rtrs_clt_change_state(sess, state); } @@ -2436,9 +2434,9 @@ static int rtrs_send_sess_info(struct rtrs_clt_sess *sess) out: if (tx_iu) - rtrs_iu_free(tx_iu, DMA_TO_DEVICE, sess->s.dev->ib_dev, 1); + rtrs_iu_free(tx_iu, sess->s.dev->ib_dev, 1); if (rx_iu) - rtrs_iu_free(rx_iu, DMA_FROM_DEVICE, sess->s.dev->ib_dev, 1); + rtrs_iu_free(rx_iu, sess->s.dev->ib_dev, 1); if (unlikely(err)) /* If we've never taken async path because of malloc problems */ rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING_ERR); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index b8e43dc4d95a..3f2918671dbe 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -287,8 +287,7 @@ struct rtrs_msg_rdma_hdr { struct rtrs_iu *rtrs_iu_alloc(u32 queue_size, size_t size, gfp_t t, struct ib_device *dev, enum dma_data_direction, void (*done)(struct ib_cq *cq, struct ib_wc *wc)); -void rtrs_iu_free(struct rtrs_iu *iu, enum dma_data_direction dir, - struct ib_device *dev, u32 queue_size); +void rtrs_iu_free(struct rtrs_iu *iu, struct ib_device *dev, u32 queue_size); int rtrs_iu_post_recv(struct rtrs_con *con, struct rtrs_iu *iu); int rtrs_iu_post_send(struct rtrs_con *con, struct rtrs_iu *iu, size_t size, struct ib_send_wr *head); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 1cb778aff3c5..42ee3bf7dc52 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -577,8 +577,7 @@ static void unmap_cont_bufs(struct rtrs_srv_sess *sess) struct rtrs_srv_mr *srv_mr; srv_mr = &sess->mrs[i]; - rtrs_iu_free(srv_mr->iu, DMA_TO_DEVICE, - sess->s.dev->ib_dev, 1); + rtrs_iu_free(srv_mr->iu, sess->s.dev->ib_dev, 1); ib_dereg_mr(srv_mr->mr); ib_dma_unmap_sg(sess->s.dev->ib_dev, srv_mr->sgt.sgl, srv_mr->sgt.nents, DMA_BIDIRECTIONAL); @@ -682,8 +681,7 @@ static int map_cont_bufs(struct rtrs_srv_sess *sess) sgt = &srv_mr->sgt; mr = srv_mr->mr; free_iu: - rtrs_iu_free(srv_mr->iu, DMA_TO_DEVICE, - sess->s.dev->ib_dev, 1); + rtrs_iu_free(srv_mr->iu, sess->s.dev->ib_dev, 1); dereg_mr: ib_dereg_mr(mr); unmap_sg: @@ -735,7 +733,7 @@ static void rtrs_srv_info_rsp_done(struct ib_cq *cq, struct ib_wc *wc) struct rtrs_iu *iu; iu = container_of(wc->wr_cqe, struct rtrs_iu, cqe); - rtrs_iu_free(iu, DMA_TO_DEVICE, sess->s.dev->ib_dev, 1); + rtrs_iu_free(iu, sess->s.dev->ib_dev, 1); if (unlikely(wc->status != IB_WC_SUCCESS)) { rtrs_err(s, "Sess info response send failed: %s\n", @@ -861,7 +859,7 @@ static int process_info_req(struct rtrs_srv_con *con, if (unlikely(err)) { rtrs_err(s, "rtrs_iu_post_send(), err: %d\n", err); iu_free: - rtrs_iu_free(tx_iu, DMA_TO_DEVICE, sess->s.dev->ib_dev, 1); + rtrs_iu_free(tx_iu, sess->s.dev->ib_dev, 1); } rwr_free: kfree(rwr); @@ -906,7 +904,7 @@ static void rtrs_srv_info_req_done(struct ib_cq *cq, struct ib_wc *wc) goto close; out: - rtrs_iu_free(iu, DMA_FROM_DEVICE, sess->s.dev->ib_dev, 1); + rtrs_iu_free(iu, sess->s.dev->ib_dev, 1); return; close: close_sess(sess); @@ -929,7 +927,7 @@ static int post_recv_info_req(struct rtrs_srv_con *con) err = rtrs_iu_post_recv(&con->c, rx_iu); if (unlikely(err)) { rtrs_err(s, "rtrs_iu_post_recv(), err: %d\n", err); - rtrs_iu_free(rx_iu, DMA_FROM_DEVICE, sess->s.dev->ib_dev, 1); + rtrs_iu_free(rx_iu, sess->s.dev->ib_dev, 1); return err; } diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index ff1093d6e4bc..48f648f573b6 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -31,6 +31,7 @@ struct rtrs_iu *rtrs_iu_alloc(u32 queue_size, size_t size, gfp_t gfp_mask, return NULL; for (i = 0; i < queue_size; i++) { iu = &ius[i]; + iu->direction = dir; iu->buf = kzalloc(size, gfp_mask); if (!iu->buf) goto err; @@ -41,17 +42,15 @@ struct rtrs_iu *rtrs_iu_alloc(u32 queue_size, size_t size, gfp_t gfp_mask, iu->cqe.done = done; iu->size = size; - iu->direction = dir; } return ius; err: - rtrs_iu_free(ius, dir, dma_dev, i); + rtrs_iu_free(ius, dma_dev, i); return NULL; } EXPORT_SYMBOL_GPL(rtrs_iu_alloc); -void rtrs_iu_free(struct rtrs_iu *ius, enum dma_data_direction dir, - struct ib_device *ibdev, u32 queue_size) +void rtrs_iu_free(struct rtrs_iu *ius, struct ib_device *ibdev, u32 queue_size) { struct rtrs_iu *iu; int i; @@ -61,7 +60,7 @@ void rtrs_iu_free(struct rtrs_iu *ius, enum dma_data_direction dir, for (i = 0; i < queue_size; i++) { iu = &ius[i]; - ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, dir); + ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, iu->direction); kfree(iu->buf); } kfree(ius); From patchwork Fri Oct 23 07:43:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852421 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5F136A2 for ; Fri, 23 Oct 2020 07:44:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 829182177B for ; Fri, 23 Oct 2020 07:44:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="G6xRiZse" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375773AbgJWHoE (ORCPT ); Fri, 23 Oct 2020 03:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374490AbgJWHoE (ORCPT ); Fri, 23 Oct 2020 03:44:04 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8E5C0613CE for ; Fri, 23 Oct 2020 00:44:03 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id dt13so1019358ejb.12 for ; Fri, 23 Oct 2020 00:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hNwL06T9lZbIYJAW3UwxrnMIZQSk9NdDK4p0pWkg0K8=; b=G6xRiZseQCXjBdPkPAKc+M78RRTDsvMAPpASn94IDAXBCtJGQ4tx81ywKDnpBFmccr SFsYxSXxYDKTGc37I50/VXP6t13fMJaoPNdydCmifAgZGJYrIYNZAohygedpUE+PmWoQ PIJgEP8SpRXQ4bLIBzylt/roiO9B/lT7XiTB3Gj50nqAeP5Afr80hb+fb6LRhDRgiCU2 Jd/968qJkPk1Xjq8j/+SNlqpppueER38vz2AhRUGCCjqKCLibdoTCVfL2v2P2WfQkYu3 zXlvyNIT6eFOOqUmyF1EtHbTWXg/GOU9LkTW+9UzGnkjwy0prTAamzCmtHW66uQrnCov CNVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hNwL06T9lZbIYJAW3UwxrnMIZQSk9NdDK4p0pWkg0K8=; b=dtUFwZapqZOYwGehYDJv20I9q5Sc/g8mE4uiN7vvZO58MeDMssU66zsm01oCz/sHQb cQI8fE0wZ6UDqpBvNFVxFupmOr+UopXNGZSJSFLFw+v+2JGdXJaybUIWke/FmuScKb5W GEfcMtVhmIaK06JSKlKbI9+tJFK9hRtHbYmyqtId0cntK3JgxQf+dZZx0YldVQqmOXdi DrdKWor7lOWOizxJEApkmobu04TX0oV0maYvtMQ4VwMssE6RioSA5Pv/OiulIYKai5jo GDRvSsuc/84qoXLJ5xBJAbYB+csL5+jfMwvT0Yyay+eT/UKYfHWpPRdCAm6z4zWKHb7s 9V4g== X-Gm-Message-State: AOAM533VRu1EQcExXhiqU3eU3mVQMsTD3hqhgHPSV8XI7/bJe0e1KECI ekSHofuxr5OF7FO1/+TD/XVuHw5KROGjHA== X-Google-Smtp-Source: ABdhPJwp3mJBNrmkfsSmh9QpPF8KcvmdbDPyknHRLU3qj09ffMCASb5roAfmBKdFJt6KNmgoF/iiqQ== X-Received: by 2002:a17:906:bc98:: with SMTP id lv24mr741770ejb.536.1603439042505; Fri, 23 Oct 2020 00:44:02 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:44:02 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 08/12] RDMA/rtrs-clt: remove duplicated switch-case handling for CM error events Date: Fri, 23 Oct 2020 09:43:49 +0200 Message-Id: <20201023074353.21946-9-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim The events returning the same error value are put together. Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 4e5da834034a..30eda2f355e1 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1843,20 +1843,22 @@ static int rtrs_clt_rdma_cm_handler(struct rdma_cm_id *cm_id, case RDMA_CM_EVENT_REJECTED: cm_err = rtrs_rdma_conn_rejected(con, ev); break; + case RDMA_CM_EVENT_DISCONNECTED: + /* No message for disconnecting */ + cm_err = -ECONNRESET; + break; case RDMA_CM_EVENT_CONNECT_ERROR: case RDMA_CM_EVENT_UNREACHABLE: + case RDMA_CM_EVENT_ADDR_CHANGE: + case RDMA_CM_EVENT_TIMEWAIT_EXIT: rtrs_wrn(s, "CM error event %d\n", ev->event); cm_err = -ECONNRESET; break; case RDMA_CM_EVENT_ADDR_ERROR: case RDMA_CM_EVENT_ROUTE_ERROR: + rtrs_wrn(s, "CM error event %d\n", ev->event); cm_err = -EHOSTUNREACH; break; - case RDMA_CM_EVENT_DISCONNECTED: - case RDMA_CM_EVENT_ADDR_CHANGE: - case RDMA_CM_EVENT_TIMEWAIT_EXIT: - cm_err = -ECONNRESET; - break; case RDMA_CM_EVENT_DEVICE_REMOVAL: /* * Device removal is a special case. Queue close and return 0. From patchwork Fri Oct 23 07:43:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852425 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E562D15E6 for ; Fri, 23 Oct 2020 07:44:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB59C2177B for ; Fri, 23 Oct 2020 07:44:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="DTQU56y2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S374504AbgJWHoG (ORCPT ); Fri, 23 Oct 2020 03:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S375775AbgJWHoG (ORCPT ); Fri, 23 Oct 2020 03:44:06 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 063BFC0613D2 for ; Fri, 23 Oct 2020 00:44:05 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id w25so633059edx.2 for ; Fri, 23 Oct 2020 00:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PQPo3xtXQ3c+ba8K989CK1eFGoKLVGepg0kiLuKLBMM=; b=DTQU56y2e1AQkGQNRCyHt8SwTDM5bWuIMaFEiw1xFuJgi0bczQoiij826xPmKrS54y 5tNBxyiKsMFWKYUHhKxOwe3DwiPMIG7yHX6xq9dsTAtH2ou2z90w0HQHM0ft552Z2eIh QGahuIeRB+56J1AGideP6MTqzh2UkZUuv4jEzXBGJHifbtt+B4LQOQzSHh0dfPqn/rps KMEdosKgVTYE8nRlAAvC77TwHUOlLcC6U+rdVtwMk5w4TuSY6Kb1yQi8NHM561NwUK/7 FNW8LvPl6uY3vy1UEvcKmjQ0AEjL0mgWeHYUipsuRxADxvtDYZi8WdMdqtC7QipruAGC HCMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PQPo3xtXQ3c+ba8K989CK1eFGoKLVGepg0kiLuKLBMM=; b=l8CIXY2LNaqfwuP4zcE4vegzQ9GyIULDdOIWozt0bsWITPOF+peDbutYuulX3Z1mve LI9iQ/MfZE2z9mVT6S6Qe7Jod5JSX+rXdYhwb/9Pii93A3WF6XRRXrNZZ8Naan8oyqbF URONJ877bcPKkx+4iSCJL1qC54OCzmqwYHgKxTLj2GVv+uuApnvJWsvbWfVAJbd1IxHX VOOddelVaD/tyN4BmHZdAQLfUDsu1JQVzxRb2+gnOfjZGjWvel5iIIyrq2sRe/IoAAJW 9A9NF1pDu9hWlDbaWAC/uUQ+UJmbtbKzH2Vo2XtNL0/cbpuNjr/ZnkTMfQ2PbJ7b3hDE TlYQ== X-Gm-Message-State: AOAM532y4Yx5wtcwQFdGQEZ6ICKGb5INLbtGiKAImCh5y9OrA5Haz6Qc pkY6qBm6xRm4uBAwhv3F7ohRsGA/ANGKlg== X-Google-Smtp-Source: ABdhPJzjw/v4Toc5aXweVwTYUw9HdY+6jdgTGSYMoKwkLB8tGw2yEaPx6ScKI4IieEX4zVf4If0OUA== X-Received: by 2002:a50:e447:: with SMTP id e7mr966563edm.263.1603439043482; Fri, 23 Oct 2020 00:44:03 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:44:03 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 09/12] RDMA/rtrs-clt: remove duplicated code Date: Fri, 23 Oct 2020 09:43:50 +0200 Message-Id: <20201023074353.21946-10-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim process_info_rsp checks that sg_cnt is zero twice. Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 30eda2f355e1..1b2821d71b46 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2264,8 +2264,12 @@ static int process_info_rsp(struct rtrs_clt_sess *sess, int i, sgi; sg_cnt = le16_to_cpu(msg->sg_cnt); - if (unlikely(!sg_cnt)) + if (unlikely(!sg_cnt || (sess->queue_depth % sg_cnt))) { + rtrs_err(sess->clt, "Incorrect sg_cnt %d, is not multiple\n", + sg_cnt); return -EINVAL; + } + /* * Check if IB immediate data size is enough to hold the mem_id and * the offset inside the memory chunk. @@ -2278,11 +2282,6 @@ static int process_info_rsp(struct rtrs_clt_sess *sess, MAX_IMM_PAYL_BITS, sg_cnt, sess->chunk_size); return -EINVAL; } - if (unlikely(!sg_cnt || (sess->queue_depth % sg_cnt))) { - rtrs_err(sess->clt, "Incorrect sg_cnt %d, is not multiple\n", - sg_cnt); - return -EINVAL; - } total_len = 0; for (sgi = 0, i = 0; sgi < sg_cnt && i < sess->queue_depth; sgi++) { const struct rtrs_sg_desc *desc = &msg->desc[sgi]; From patchwork Fri Oct 23 07:43:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852423 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 468426A2 for ; Fri, 23 Oct 2020 07:44:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24B932192A for ; Fri, 23 Oct 2020 07:44:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="UG2YNypf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375774AbgJWHoG (ORCPT ); Fri, 23 Oct 2020 03:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374504AbgJWHoG (ORCPT ); Fri, 23 Oct 2020 03:44:06 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E756BC0613CE for ; Fri, 23 Oct 2020 00:44:05 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id z5so1043275ejw.7 for ; Fri, 23 Oct 2020 00:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T3kquoa30tyLSRFx7MemJ0XnJhaHJc5eZ+rWAVL23ME=; b=UG2YNypfJog4EzocyTVZr+BtqojKpY6z5LgWRxLB+15RpDCz5KNcum0MdR5OpwpkzJ cGjb8XSWY7oY5Xc0/fTZfwiW1oB3WNGfRUoEaRG9GcMWYWbtR9A9bnaLWhHoX35Z6xm8 HeL0AybevD4Qw1fNL533nlOykSyP5pwjVjsljjhcTbZPnXFcq6C7NjAsKWvni1xZav/Z dXeQRbvjgqMGIO6iHOsNrK1gGoXGbYdViexAA9ZXvLWd0f5mBOLrS7LfU980WsxmLFH/ Vu8N2C84/8yHafvqeYmNI+mfONVExdV/moJdyGw8WmeH1fe4WjbmED2HiwGDW19slLca 5j0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T3kquoa30tyLSRFx7MemJ0XnJhaHJc5eZ+rWAVL23ME=; b=sgEZLnWWsbOCILr5ALZMAqp1S1aPKNghyYUGcuEFJ7jagqKTjLZNDDeVIqPTbfD6rv Bpr8T6Jhc0icQxBBcqJRId2VJusajK45VlwwKqgvUji9TgQdEkuIzWitc9wpK6UUKzdv 26Zh/6hUp3R3tenBNq9+gG1qvVilRXUR8U8gKdSkeMrx0MusRhJYwH0xxls6knokOGXI ZFrcnlF5dydrhOrLEvkeeX/NhmoKAvuCNIqCFJ1WmTKm2Bb3QivI1o/bZ5L3i9oawx8v bEdCHvDdBEIH4yqNTwuGKX2PRxXQ25l9nczG7kG0dYOK9X17nV1s9S8hUoYVjBHEW15D JG+A== X-Gm-Message-State: AOAM530RK6Xbx4MhkGYIHEhLnasqtkLGE3BKQKvlPvlYe57KmEptIIPg bnfMTb82AreS+yntBnu4es+zwjMLqzTXzg== X-Google-Smtp-Source: ABdhPJwcpD26zEFwBFAXjqY8L5g/PebwdcGWcHUBMzW02cM9BX2G8yEz/K9SLjVguNPxv2KtjPDo7Q== X-Received: by 2002:a17:906:7fd7:: with SMTP id r23mr712953ejs.310.1603439044502; Fri, 23 Oct 2020 00:44:04 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:44:04 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 10/12] RDMA/rtrs-srv: kill rtrs_srv_change_state_get_old Date: Fri, 23 Oct 2020 09:43:51 +0200 Message-Id: <20201023074353.21946-11-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang This function isn't needed since no caller checks the old_state of sess. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 42ee3bf7dc52..c42fd470c4eb 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -113,28 +113,18 @@ static bool __rtrs_srv_change_state(struct rtrs_srv_sess *sess, return changed; } -static bool rtrs_srv_change_state_get_old(struct rtrs_srv_sess *sess, - enum rtrs_srv_state new_state, - enum rtrs_srv_state *old_state) +static bool rtrs_srv_change_state(struct rtrs_srv_sess *sess, + enum rtrs_srv_state new_state) { bool changed; spin_lock_irq(&sess->state_lock); - *old_state = sess->state; changed = __rtrs_srv_change_state(sess, new_state); spin_unlock_irq(&sess->state_lock); return changed; } -static bool rtrs_srv_change_state(struct rtrs_srv_sess *sess, - enum rtrs_srv_state new_state) -{ - enum rtrs_srv_state old_state; - - return rtrs_srv_change_state_get_old(sess, new_state, &old_state); -} - static void free_id(struct rtrs_srv_op *id) { if (!id) @@ -471,10 +461,7 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id, void close_sess(struct rtrs_srv_sess *sess) { - enum rtrs_srv_state old_state; - - if (rtrs_srv_change_state_get_old(sess, RTRS_SRV_CLOSING, - &old_state)) + if (rtrs_srv_change_state(sess, RTRS_SRV_CLOSING)) queue_work(rtrs_wq, &sess->close_work); WARN_ON(sess->state != RTRS_SRV_CLOSING); } From patchwork Fri Oct 23 07:43:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852427 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAFA06A2 for ; Fri, 23 Oct 2020 07:44:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A3B82192A for ; Fri, 23 Oct 2020 07:44:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="gNadxjyA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375777AbgJWHoH (ORCPT ); Fri, 23 Oct 2020 03:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S375775AbgJWHoH (ORCPT ); Fri, 23 Oct 2020 03:44:07 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09AD0C0613D2 for ; Fri, 23 Oct 2020 00:44:07 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id w23so633632edl.0 for ; Fri, 23 Oct 2020 00:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N98xLNwIrHPVMGn4TFLYhEJS7NXRDPuaQTkSD4Kdyco=; b=gNadxjyAJ/SAUFEN/n2FoOEfFGW7zJLUWUktpPazNrl1HtrRxN1PxQz3CRXj6q+0dK xCLeib6AWV84VXDVj9n8JqY5stJ7bYVrTfisFZ470jSxiXfYpbrchWsg3fluqVzt3HOO vecxRI7aecInlF9ZbwRJlIP1tB0hb3fQQlvYx7+agEh9EqgWNpxhqgbxhqc6WKGeWAS7 tn6jkmSAiOnV+SLdXcGKB+GGfc5ARGppc76m1axPsSfoplLp6CGIQkqDscrocTRs923l +T9x/PMPvcHWNERgUf80P6HhWEXSsJXgf5w4SXtooOmmjhbVyR9Jx1YDQ04qqRkzCdKa NzkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N98xLNwIrHPVMGn4TFLYhEJS7NXRDPuaQTkSD4Kdyco=; b=WQZ9AlakO92AdrDnKXiaxljDGKz5cHdOmWdkVWGYybkECzHFEb/32drs3/qF0FwpUC e9njf4pp85vO0IvbUHN8SRp2GCZK7tXOZCVMeCW94TQRlod/obfVdXQDzZ52b79AnWp0 E9JV7OovrrRamInTC8WsVM2O5qO+6jwGULKfohH6YjCAp7FvE1H6TydWUZQa7s0rQZK3 oN/vIOMR6MHh9ohNQuvUpslUkLGiRBUUs+oI9T5OswU+AZcK9zyZGaZLAbl+I2/mAviV QxeFQrw5hMC0deZZdYVqtoexlYExNeLZTvpwoRPGgSp2aqNlFuyWkAN3HANjgn9zhJmz fE/A== X-Gm-Message-State: AOAM530GBwpLP3Qupy3WXDGE9DKqCr71Wj/cVI/M7TDbE46Nj/WYNwy/ XiV9BY3KQfMFe2RI5J22GouTrqkbK01Pmg== X-Google-Smtp-Source: ABdhPJyrr+2FP262gZTTNn093G9iHJ6qw4gcfR27XdRYtXhDPUit9PaZlHiC58+2gQ6hgeKu3E2RYA== X-Received: by 2002:a50:b023:: with SMTP id i32mr908249edd.377.1603439045509; Fri, 23 Oct 2020 00:44:05 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:44:05 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 11/12] RDMA/rtrs: introduce rtrs_post_send Date: Fri, 23 Oct 2020 09:43:52 +0200 Message-Id: <20201023074353.21946-12-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Since the three functions share the similar logic, let's introduce one common function for it. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs.c | 52 +++++++++++------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 48f648f573b6..2e3a849e0a77 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -104,6 +104,22 @@ int rtrs_post_recv_empty(struct rtrs_con *con, struct ib_cqe *cqe) } EXPORT_SYMBOL_GPL(rtrs_post_recv_empty); +static int rtrs_post_send(struct ib_qp *qp, struct ib_send_wr *head, + struct ib_send_wr *wr) +{ + if (head) { + struct ib_send_wr *tail = head; + + while (tail->next) + tail = tail->next; + tail->next = wr; + } else { + head = wr; + } + + return ib_post_send(qp, head, NULL); +} + int rtrs_iu_post_send(struct rtrs_con *con, struct rtrs_iu *iu, size_t size, struct ib_send_wr *head) { @@ -126,17 +142,7 @@ int rtrs_iu_post_send(struct rtrs_con *con, struct rtrs_iu *iu, size_t size, .send_flags = IB_SEND_SIGNALED, }; - if (head) { - struct ib_send_wr *tail = head; - - while (tail->next) - tail = tail->next; - tail->next = ≀ - } else { - head = ≀ - } - - return ib_post_send(con->qp, head, NULL); + return rtrs_post_send(con->qp, head, &wr); } EXPORT_SYMBOL_GPL(rtrs_iu_post_send); @@ -168,17 +174,7 @@ int rtrs_iu_post_rdma_write_imm(struct rtrs_con *con, struct rtrs_iu *iu, if (WARN_ON(sge[i].length == 0)) return -EINVAL; - if (head) { - struct ib_send_wr *tail = head; - - while (tail->next) - tail = tail->next; - tail->next = &wr.wr; - } else { - head = &wr.wr; - } - - return ib_post_send(con->qp, head, NULL); + return rtrs_post_send(con->qp, head, &wr.wr); } EXPORT_SYMBOL_GPL(rtrs_iu_post_rdma_write_imm); @@ -195,17 +191,7 @@ int rtrs_post_rdma_write_imm_empty(struct rtrs_con *con, struct ib_cqe *cqe, .ex.imm_data = cpu_to_be32(imm_data), }; - if (head) { - struct ib_send_wr *tail = head; - - while (tail->next) - tail = tail->next; - tail->next = ≀ - } else { - head = ≀ - } - - return ib_post_send(con->qp, head, NULL); + return rtrs_post_send(con->qp, head, &wr); } EXPORT_SYMBOL_GPL(rtrs_post_rdma_write_imm_empty); From patchwork Fri Oct 23 07:43:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11852429 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93D4E6A2 for ; Fri, 23 Oct 2020 07:44:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6ED412192A for ; Fri, 23 Oct 2020 07:44:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="EvpUltxW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S375778AbgJWHoI (ORCPT ); Fri, 23 Oct 2020 03:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S375775AbgJWHoI (ORCPT ); Fri, 23 Oct 2020 03:44:08 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12402C0613CE for ; Fri, 23 Oct 2020 00:44:08 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id qh17so1047001ejb.6 for ; Fri, 23 Oct 2020 00:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MSVlZYGl3MWtTRqU1euC5XK0zC3yaVL2aUUV00m8iRw=; b=EvpUltxW553RjPcT6JDcm71PEg0Dj5DOFbTEqzyyJLdbJZBK3bLmiofbgdyxr0E2Bu 8tatyXG8GVh2yhwuxCy31N0AyZ7nL6xyIiW+ClTZgs31HfGgP+xFNJG/QGbuE4x5f1OK /4jJjlni0Jv0PILAY5RIPeqwSU7HRWU0eUyrFwMmJAaDOii6KFbGkI2tlYOLTV9vwXbY clvlnmLo412VZawLW9kaE883XjEN3AGFCon9JSFT1WwkpuNY8TkdJUDYbY2m7dGAA7b1 Zz/gnpNlJu+0xeEY1eSdfUzKrcd00Phoncp59RYfBGUZ+Y23Ilump81YlZR2id/662Wn 0ezA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MSVlZYGl3MWtTRqU1euC5XK0zC3yaVL2aUUV00m8iRw=; b=WL1yDxcKw0qRd/JAH9uzf/71yM6WEMtepKeP940svoxJsCTgZClieCIYmxBpgy/WWI TG5GkrbUPy859yrm8uXEga+GBDdEJQ15UH3J01mnpSK2xphbab/GuOxfoczN+59ZQ3Ji IJaLwOz0Jk199vhpXszQPnZ8CVqy6WVA4zExyZ63hFmLswnfkzARykDlCCgz6t2eXGFh voWdc9SOMhFtqD4VWuGToLrxwB0GSQRjnd7jQa8ITHvEh4ESS5TjOhMc11bm9Hm8ade/ 7lgUVK0/ZGkk+zdEedn0Qy7b3YBL6JEfh89uws7kKIhDR6xmGU+Fx8w6IYe4RkjbHBp7 InzA== X-Gm-Message-State: AOAM533v8+r9oooBNpZGNt9D6WushwEBD6S5chwhj+rOa5FM3jIZpMen AwxOfLADq7nNjmxN0beASPoCr8K8eqinSg== X-Google-Smtp-Source: ABdhPJx9qyrCCUXHax25RROmYlduEYpVoujbkzW4ze+2KLky9Fz5wlVeptV+sel+srCkr4JMO+2TZg== X-Received: by 2002:a17:906:aec1:: with SMTP id me1mr768531ejb.225.1603439046601; Fri, 23 Oct 2020 00:44:06 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:49b9:3000:d18a:ee7b:bff9:e374]) by smtp.gmail.com with ESMTPSA id op24sm337928ejb.56.2020.10.23.00.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 00:44:06 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 12/12] RDMA/rtrs-clt: remove 'addr' from rtrs_clt_add_path_to_arr Date: Fri, 23 Oct 2020 09:43:53 +0200 Message-Id: <20201023074353.21946-13-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> References: <20201023074353.21946-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Remove the argument since it is not used in the function. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 1b2821d71b46..9d359c8f2f81 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2161,8 +2161,7 @@ static void rtrs_clt_remove_path_from_arr(struct rtrs_clt_sess *sess) mutex_unlock(&clt->paths_mutex); } -static void rtrs_clt_add_path_to_arr(struct rtrs_clt_sess *sess, - struct rtrs_addr *addr) +static void rtrs_clt_add_path_to_arr(struct rtrs_clt_sess *sess) { struct rtrs_clt *clt = sess->clt; @@ -2937,7 +2936,7 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt, * IO will never grab it. Also it is very important to add * path before init, since init fires LINK_CONNECTED event. */ - rtrs_clt_add_path_to_arr(sess, addr); + rtrs_clt_add_path_to_arr(sess); err = init_sess(sess); if (err)