From nobody Sun Sep 14 22:53:34 2025 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 8B66EC54EE9 for ; Tue, 13 Sep 2022 14:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233801AbiIMOcl (ORCPT ); Tue, 13 Sep 2022 10:32:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234022AbiIMObf (ORCPT ); Tue, 13 Sep 2022 10:31:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDB22642E7; Tue, 13 Sep 2022 07:19:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E0857B80FAC; Tue, 13 Sep 2022 14:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48C4FC4347C; Tue, 13 Sep 2022 14:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078702; bh=FfKZSeAKBmbF/IVmgbQkN7LB0RTe/5cI7GDXbScWuAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXgTordCdY+CRpypNO9MHHFeUblAhiwSgejXXVbQpAUcYQjaVoRo+dq9GEV+O/FaI HFZaCsIBvx1EC6E+yZknyQyQfFXFe7HUA0LbjPmne3LpbNL77iqVbOg3if7Mnyjizk gq1QtQ1EyaTSUNwipxxF8AEYAZ/GXYpCr+RqwOJA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Wang , Aleksei Marov , Leon Romanovsky , Sasha Levin Subject: [PATCH 5.15 050/121] RDMA/rtrs-clt: Use the right sg_cnt after ib_dma_map_sg Date: Tue, 13 Sep 2022 16:04:01 +0200 Message-Id: <20220913140359.507633593@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jack Wang [ Upstream commit b66905e04dc714825aa6cffb950e281b46bbeafe ] 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") Link: https://lore.kernel.org/r/20220818105355.110344-3-haris.iqbal@ionos.c= om Signed-off-by: Jack Wang Reviewed-by: Aleksei Marov Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- 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/ul= p/rtrs/rtrs-clt.c index 9edbb309b96c0..c644617725a88 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1011,7 +1011,8 @@ rtrs_clt_get_copy_req(struct rtrs_clt_path *alive_pat= h, 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 =3D to_clt_path(con->c.path); @@ -1031,12 +1032,12 @@ static int rtrs_post_rdma_write_sg(struct rtrs_clt_= con *con, num_sge =3D 2; ptail =3D tail; } else { - for_each_sg(req->sglist, sg, req->sg_cnt, i) { + for_each_sg(req->sglist, sg, count, i) { sge[i].addr =3D sg_dma_address(sg); sge[i].length =3D sg_dma_len(sg); sge[i].lkey =3D clt_path->s.dev->ib_pd->local_dma_lkey; } - num_sge =3D 1 + req->sg_cnt; + num_sge =3D 1 + count; } sge[i].addr =3D req->iu->dma_addr; sge[i].length =3D size; @@ -1149,7 +1150,7 @@ static int rtrs_clt_write_req(struct rtrs_clt_io_req = *req) */ rtrs_clt_update_all_stats(req, WRITE); =20 - ret =3D rtrs_post_rdma_write_sg(req->con, req, rbuf, fr_en, + ret =3D rtrs_post_rdma_write_sg(req->con, req, rbuf, fr_en, count, req->usr_len + sizeof(*msg), imm, wr, &inv_wr); if (ret) { --=20 2.35.1