Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6822630rwn; Tue, 13 Sep 2022 09:26:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5mH1HaLu941vkZWcFRO5x2W3rEs1v1dkkpTt3ZK/srUTFtwt72D+1T63i8NyCucnBg5BjG X-Received: by 2002:a17:907:84a:b0:733:735:2b1a with SMTP id ww10-20020a170907084a00b0073307352b1amr22394785ejb.290.1663086360910; Tue, 13 Sep 2022 09:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086360; cv=none; d=google.com; s=arc-20160816; b=iti1ToWcOe9p0NFvvpil5XggRbV/4WxNrVqiu9dgVZyMIJrlgxOx789rKTVW8Qn3X5 y/TwTnTtsWQnFEuxRgMFyUSNRvPo7JEuKAPc3Zm3S2zRGPj3YWjROhWLfpL1UsxL0zcK cUyPukPOy4Y/7lR6uV2FsgazaDq0Ej+bps+vTNtZ9Hl1eLk6nXRhNYPjHbFbQGiiEC/Q RkR5fjzP5vhS0U5s7Vz1b4b9X3ElCnoCJj7qfgasj4M67QVhiaIWAVaKSAHcznVSgB4v 1kcpBfvqjsaKWsDcfePbB9FOk33r5awIVVLi+tpCxNL6evv/6fBNty9814lM8k0iBD9i 0k2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bXPA4gj5ztXGya/KhqtOzCJy1KQmbOU/WawhgEmD6lY=; b=zuN1eOeyQC/WkIqeOh6sxOEFl8fa7KM1MJle5RC/utLk3IzR4QGR8x/hFam838zBmn qSZDvwDz/dGkxiyt+Fdwwt1/upk7qoamfi8wE2nePCDFXq8wVoH0kczkkJfMs0nah749 2NlytCe03nICK7kXEa0NK27shZzbr8mwb67e22fsPtTaRn8X55rXV6Co/dr2kiivLUIE Y+3xuMTs3HwipDOc6xmnxhPXUoShuu/+3vof/TABna6fP8TtcEtvLvp6K8cjwofLsvMr KFKu0uD9Pr6WAtyeExjY+RFu4dzYXwewCMLzE8TyYz5HWaR0XnGqy0eutUkgOU+O8mni 3IjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FXgTordC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fj4-20020a1709069c8400b0074084f48b41si10494419ejc.998.2022.09.13.09.25.31; Tue, 13 Sep 2022 09:26:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FXgTordC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234032AbiIMOck (ORCPT + 99 others); Tue, 13 Sep 2022 10:32:40 -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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.com 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/ulp/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_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); @@ -1031,12 +1032,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; @@ -1149,7 +1150,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) { -- 2.35.1