From patchwork Thu Aug 18 10:53:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12946922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67128C32772 for ; Thu, 18 Aug 2022 10:54:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236396AbiHRKyB (ORCPT ); Thu, 18 Aug 2022 06:54:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238659AbiHRKyA (ORCPT ); Thu, 18 Aug 2022 06:54:00 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B086A642FB for ; Thu, 18 Aug 2022 03:53:59 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id ay39-20020a05600c1e2700b003a5503a80cfso721098wmb.2 for ; Thu, 18 Aug 2022 03:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=OsmktRt7vr5Z0MzfjZFKBnyCNRYzs2uMPc3Rn0B92wY=; b=I3zegDH8Ff4UwUn2xOKtiMCKosjRSSW6xet72nuXANbm+lcFunGvg2U6D9bng7IIka uoOfeqJsgfFJ54Iguwjfrbe7KO8b+9iMMw0fXSZVQGRXwVH7q4rRPWE7m3DLTJcDS+xd wWTwT/9lrrJ4ISLDSmKJ6zdWfxyD5j9zbmrxVU0vETtISDeVj0hjIb5fBhRatLdEZdLq RoGFlxbzG9pbd/80fdmRoV9Nm+CETze1ksD22kFANVEPn39CuJazXeEdccoSBRPvMeap qG37Q5pHOTYrnA2HM3zfYs+q/jBRmrlhHDOtaSCddAPrRzoO0BTwD4gg50WkI4gWCJsR 3saw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=OsmktRt7vr5Z0MzfjZFKBnyCNRYzs2uMPc3Rn0B92wY=; b=cpXj6wa9g5n/77uzedGf+TCraRhxBTe15S/zc1TflruBwixalOXXTVJ7eJCof6bEwG +JIQto21IDDYtV6IMru+/CLsMs3jBvMAmYQfLJshKSkOFH+nP3tq8zkydSIHIEcoWhYa HlmLnpx+wRISoGaJA++VRqCENSLluBG2Kt+3E+U/Q6bhhee++SMHLQwgSi0dC+Qm6Cmv gAdiMjCKS52Nx1Mg/akSBb/AlJ/XzRCO0KRx9kPAD6gNu5q7APog3tqOJxQ1WB1DtnxH o3x9YVg86er5DyLzWglX4t4y65kPPtmNMboKp7bRwTS+8exlvxyDUJ3z8EPYokYjNltz +pZw== X-Gm-Message-State: ACgBeo0CkEQ0lnULVUou09rhpSD6LSDYDyMppeXYFTvUumpEUhDv52Hd tW3JTb+UtYF8S7LYG8zaQljFDhQhNlEyaw== X-Google-Smtp-Source: AA6agR7OLPJTMS8oMV7XHoPoKjSjbt7zhI1Ns37b2fTCdCvKZgvtO9GPtLjyGVxNk7T+tNiHZsAf9g== X-Received: by 2002:a05:600c:34c1:b0:3a5:e065:9b46 with SMTP id d1-20020a05600c34c100b003a5e0659b46mr1535800wmq.30.1660820038290; Thu, 18 Aug 2022 03:53:58 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id n3-20020a05600c3b8300b003a54fffa809sm1920751wms.17.2022.08.18.03.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 03:53:57 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: leon@kernel.org, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Aleksei Marov Subject: [PATCH for-next 1/3] RDMA/rtrs-clt: Output sg index when warning on Date: Thu, 18 Aug 2022 12:53:53 +0200 Message-Id: <20220818105355.110344-2-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220818105355.110344-1-haris.iqbal@ionos.com> References: <20220818105355.110344-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang Output the sg index, so it's a bit easier for debug. Signed-off-by: Jack Wang Reviewed-by: Aleksei Marov --- drivers/infiniband/ulp/rtrs/rtrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 60fa0b0160f4..ed324b47d93a 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -175,7 +175,7 @@ int rtrs_iu_post_rdma_write_imm(struct rtrs_con *con, struct rtrs_iu *iu, * length error */ for (i = 0; i < num_sge; i++) - if (WARN_ON(sge[i].length == 0)) + if (WARN_ONCE(sge[i].length == 0, "sg %d is zero length\n", i)) return -EINVAL; return rtrs_post_send(con->qp, head, &wr.wr, tail); From patchwork Thu Aug 18 10:53:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12946923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFD7AC00140 for ; Thu, 18 Aug 2022 10:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238659AbiHRKyC (ORCPT ); Thu, 18 Aug 2022 06:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238963AbiHRKyB (ORCPT ); Thu, 18 Aug 2022 06:54:01 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81F2B6CD18 for ; Thu, 18 Aug 2022 03:54:00 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id m10-20020a05600c3b0a00b003a603fc3f81so736542wms.0 for ; Thu, 18 Aug 2022 03:54:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=og4NRVF3kojiVFewfuePBbw/uUDzMIlDN9CpjxEcs40=; b=U7wSoOU7OVFDLzzowGjwClwIUCt+XqgcJkQpCLd7EpIwWlEhQNEK7PaNaI5/rYkiD+ 8izZX6zESFu8X//TQq1uLWpCXcDP2Ku1WhrgQYDHzdKa6nS5NbT+dur2W0bfprmPVM+B acG3gw2KpjP5dHYUGQNhDOtcJ4NoeufXcccjXKSJ/Hj6YvKNdICTJcHXyAK0qHmMZokZ OBZSHaZX1/JY5DGT+bNFgfLUGo0M+G7GKMdYAjOivzKY9CPu1S6IHXDtAYDe24rCRPEC JPWyTFXiFxHqwugxOchmW4jVlnhPi0AOeARgnbsLbAcpIiFTsudKUUGXla6zEaTaCwla 813w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=og4NRVF3kojiVFewfuePBbw/uUDzMIlDN9CpjxEcs40=; b=LtslZXojZLB4YXe4LEX4qGve1aeVNsvtYYsChYM+OexsNrrXCFvQCopV/bnQfGL1eQ J/IpqCSBE8c34fhCuFHMbsCvRbemBbgicD6S5qovudzwXhf+nQVW2r5nhd8P9c2TJWB/ PUAdca3TEH8+7OXVHmlXzfuXyjLhzje8f8zBBinWdLG5vvWb394Y/ldUhYFeWIlGmsW0 a92o903di27qy3o1/u9979x3zneYmdrC/2UI2ngVrGr4Ps3SHIkrUi+WRBdRD2n1NrCj QLkdNFuwy6GV1Fs7HXT4HxUgfvz2N8x96AVaFcHJeS3qJ6a56zdAVu22finCxe39Imay dTig== X-Gm-Message-State: ACgBeo0HTwKFV1vj2SznREMKxX1Dmf53loaCgmLRqGCc9Oq4BLuY3qos 30/eGEx+n1dKfb9NF9nog2jlVmW2/TlaLg== X-Google-Smtp-Source: AA6agR4xaPjXDMqGApwHswgXOP/BIC66eCd3j2pKKrfjssQI/cP64KNp59eLFFIowoi6HUxwyk/cfg== X-Received: by 2002:a7b:cb55:0:b0:3a5:41a:829c with SMTP id v21-20020a7bcb55000000b003a5041a829cmr4799216wmj.153.1660820039018; Thu, 18 Aug 2022 03:53:59 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id n3-20020a05600c3b8300b003a54fffa809sm1920751wms.17.2022.08.18.03.53.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 03:53:58 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: leon@kernel.org, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Aleksei Marov Subject: [PATCH for-next 2/3] RDMA/rtrs-clt: Use the right sg_cnt after ib_dma_map_sg Date: Thu, 18 Aug 2022 12:53:54 +0200 Message-Id: <20220818105355.110344-3-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220818105355.110344-1-haris.iqbal@ionos.com> References: <20220818105355.110344-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang When iommu is enabled, we hit warnings like this: WARNING: at rtrs/rtrs.c:178 rtrs_iu_post_rdma_write_imm+0x9b/0x110 rtrs warn on one sge entry length is 0, which is unexpected. The problem is ib_dma_map_sg augments the SGL into a 'dma mapped SGL'. This process may change the number of entries and the lengths of each entry. Code that touches dma_address is iterating over the 'dma mapped SGL' and must use dma_nents which returned from ib_dma_map_sg(). So pass the count return from ib_dma_map_sg. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Jack Wang Reviewed-by: Aleksei Marov --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 5219bb10777a..5d0df186e937 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1007,7 +1007,8 @@ rtrs_clt_get_copy_req(struct rtrs_clt_path *alive_path, static int rtrs_post_rdma_write_sg(struct rtrs_clt_con *con, struct rtrs_clt_io_req *req, struct rtrs_rbuf *rbuf, bool fr_en, - u32 size, u32 imm, struct ib_send_wr *wr, + u32 count, u32 size, u32 imm, + struct ib_send_wr *wr, struct ib_send_wr *tail) { struct rtrs_clt_path *clt_path = to_clt_path(con->c.path); @@ -1027,12 +1028,12 @@ static int rtrs_post_rdma_write_sg(struct rtrs_clt_con *con, num_sge = 2; ptail = tail; } else { - for_each_sg(req->sglist, sg, req->sg_cnt, i) { + for_each_sg(req->sglist, sg, count, i) { sge[i].addr = sg_dma_address(sg); sge[i].length = sg_dma_len(sg); sge[i].lkey = clt_path->s.dev->ib_pd->local_dma_lkey; } - num_sge = 1 + req->sg_cnt; + num_sge = 1 + count; } sge[i].addr = req->iu->dma_addr; sge[i].length = size; @@ -1145,7 +1146,7 @@ static int rtrs_clt_write_req(struct rtrs_clt_io_req *req) */ rtrs_clt_update_all_stats(req, WRITE); - ret = rtrs_post_rdma_write_sg(req->con, req, rbuf, fr_en, + ret = rtrs_post_rdma_write_sg(req->con, req, rbuf, fr_en, count, req->usr_len + sizeof(*msg), imm, wr, &inv_wr); if (ret) { From patchwork Thu Aug 18 10:53:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12946924 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC06EC32772 for ; Thu, 18 Aug 2022 10:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243923AbiHRKyD (ORCPT ); Thu, 18 Aug 2022 06:54:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238963AbiHRKyC (ORCPT ); Thu, 18 Aug 2022 06:54:02 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9F627E018 for ; Thu, 18 Aug 2022 03:54:01 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id h5so477401wru.7 for ; Thu, 18 Aug 2022 03:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=fr2v3RSLAAFVGU4ZnToOw6WKbJPi95JAWN3CM4OQ5QI=; b=aQ+0Bpy+94hyWqnCtnOlpzOel5V3/dpBPB2Gvcko/DEm980eT8/5WdJS11khPU5eW2 6lYzb5+DDiYh02WpTpjVXD5GqdgAXT+sBCrR5fjkDHVcaaAWl3e2Rz13fKubG94gyVhZ Kw1BaGFHVWjKpii7r1xpY20xPfk8o/Q+RnZovS2KjwQTGwIVaokRFEisXFHQHCoCcCcz Gd6KTVKUFHgg14yw0IscfhxOKEvFnjTQBq2DpmYXm9p3cjF2fm3kkOuzZNZZ2mfN3wLT d5RMPDddrlSrBNgrKxiDcbaIs8RKmQLfGE8M9dkp1m1aas1QVsmd1E5Y17eWmt1ess55 R6Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=fr2v3RSLAAFVGU4ZnToOw6WKbJPi95JAWN3CM4OQ5QI=; b=pwuyC1ynDIwWZv96keE8l8RNcXkDkG2JKPmZhYwTHvtnOqeHd42H4cLHSwcwztgAx2 3h/4vu0YH1/5p8x/gbvoVavZnf7+YlidbGVDitmt1ZoPOZqQKByKHrrw5sjylf2PZ2yS sywuH5E7R21+hrf6HpSalNDKWm5bZd+yhByBQ7NosoTWGmO/YOklso+DY6IJVRKTRLLG NL1VSjdl4Q9LI4w7XG7TEDVi/yPJ/I8CdeCa9eRsqgMmHwkZ7ArcXOcLqIVfhKj0UPSs olKIesmI+5hFxbUnjhfpQGf0TQ6iZ8lH42rJBP92CuJcVJQlwkTJ1iCCSnkn8c6OnDjd m1Lw== X-Gm-Message-State: ACgBeo2z9lVFFMsI/YD627afUgdcI4Ud8ALxl03NY2Ks7bPvOqueNsz/ UPglMB/kVjK1puY+CVkjmV9lvvXigsRjzw== X-Google-Smtp-Source: AA6agR57/DSOHqKM96I6sNPTWGqVzHQaaKit6qoSuY7m/a/QWsGS1LOGYPLyBT7reffje1eU1NMgjg== X-Received: by 2002:a5d:640f:0:b0:220:e5a7:f5e7 with SMTP id z15-20020a5d640f000000b00220e5a7f5e7mr1276122wru.314.1660820040214; Thu, 18 Aug 2022 03:54:00 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id n3-20020a05600c3b8300b003a54fffa809sm1920751wms.17.2022.08.18.03.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 03:53:59 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: leon@kernel.org, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Aleksei Marov Subject: [PATCH for-next 3/3] RDMA/rtrs-srv: Pass the correct number of entries for dma mapped SGL Date: Thu, 18 Aug 2022 12:53:55 +0200 Message-Id: <20220818105355.110344-4-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220818105355.110344-1-haris.iqbal@ionos.com> References: <20220818105355.110344-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang ib_dma_map_sg() augments the SGL into a 'dma mapped SGL'. This process may change the number of entries and the lengths of each entry. Code that touches dma_address is iterating over the 'dma mapped SGL' and must use dma_nents which returned from ib_dma_map_sg(). We should use the return count from ib_dma_map_sg for futher usage. Fixes: 9cb837480424e ("RDMA/rtrs: server: main functionality") Signed-off-by: Jack Wang Reviewed-by: Aleksei Marov --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 22e6f991946c..aa259b4c6f89 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -593,7 +593,7 @@ static int map_cont_bufs(struct rtrs_srv_path *srv_path) struct sg_table *sgt = &srv_mr->sgt; struct scatterlist *s; struct ib_mr *mr; - int nr, chunks; + int nr, nr_sgt, chunks; chunks = chunks_per_mr * mri; if (!always_invalidate) @@ -608,19 +608,19 @@ static int map_cont_bufs(struct rtrs_srv_path *srv_path) sg_set_page(s, srv->chunks[chunks + i], max_chunk_size, 0); - nr = ib_dma_map_sg(srv_path->s.dev->ib_dev, sgt->sgl, + nr_sgt = ib_dma_map_sg(srv_path->s.dev->ib_dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL); - if (nr < sgt->nents) { - err = nr < 0 ? nr : -EINVAL; + if (!nr_sgt) { + err = -EINVAL; goto free_sg; } mr = ib_alloc_mr(srv_path->s.dev->ib_pd, IB_MR_TYPE_MEM_REG, - sgt->nents); + nr_sgt); if (IS_ERR(mr)) { err = PTR_ERR(mr); goto unmap_sg; } - nr = ib_map_mr_sg(mr, sgt->sgl, sgt->nents, + nr = ib_map_mr_sg(mr, sgt->sgl, nr_sgt, NULL, max_chunk_size); if (nr < 0 || nr < sgt->nents) { err = nr < 0 ? nr : -EINVAL; @@ -639,7 +639,7 @@ static int map_cont_bufs(struct rtrs_srv_path *srv_path) } } /* Eventually dma addr for each chunk can be cached */ - for_each_sg(sgt->sgl, s, sgt->orig_nents, i) + for_each_sg(sgt->sgl, s, nr_sgt, i) srv_path->dma_addr[chunks + i] = sg_dma_address(s); ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey));