Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3647601pxb; Wed, 13 Oct 2021 10:03:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYVA2bbJdCqFncA309xErEqnKGlmpTXXl+yoNieHPNCvRrMhBwIOO2wOU4oDUEMFopzrCF X-Received: by 2002:a17:906:154c:: with SMTP id c12mr519328ejd.76.1634144588808; Wed, 13 Oct 2021 10:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634144588; cv=none; d=google.com; s=arc-20160816; b=C2hHycyo5MnhRCb+DUNiwJ5cges6VJQ2ieN31ohArRm6i/NTjP/WiY1LNG3U2WQdmc jVMkI+Rgbwk0405slqRCBk4r512rd44MdE8LfrsdbnoQvveEKoLf5VZXGR6S18tDzAnJ N353ujkM1Xn+nfCUirFu37T6sOjGP5Zj6BlThmm5A1MRn2hOVddmGCnNE3bp8MmldxVk WAwu3OS7sgt14FWQjfbJQBoqZk9iO/UfANF8znBXV04SOF/dtwhEE2xME49OYGbB31JP fIXxZRRXUBNzTJ6f8HhuUh1EqVCu97QPhOq+ZBZDTIsCidM2z2m5AZnmfNDOetCSpffe OmUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :message-id:date:cc:to:from:dkim-signature; bh=tbPvbDzsZtbOGJDbhM8sXn4yknGSvZ1Pz9705wkhiMo=; b=G9lWJOLnxqpzcG+/L7kjoUj6frlYWfTwAEJayYYe8w+NQ6AoJrq14Z8OBHOJocoiI3 tU1rhzJrTsuVgyTEeJZx384Lb7HGR41S/dc+k8NDCepuf0xLTt0jDKArl0a5WF4vuGD6 2+zmY0iqF8HHryk173lBHcCeNaP0HNv7RocUd3LkhDM6EaQmEycXDqu18OwwyRIxqaGG 5MMZ9LXl4y64NQ8xjBdLVVGbpdiBWIu5HawbtphfeWIGq8Ngy4i4RZdEEkx36UOO9Ydk LRZeBP8SFZbj63/fpq5m662Rb2uadfk2ksYVwTAOpzWFyDBt1i42r3JUgmURYbc36Q1V ZaFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Gg9q5h0Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si183323ejm.510.2021.10.13.10.02.33; Wed, 13 Oct 2021 10:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Gg9q5h0Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237528AbhJMRCC (ORCPT + 99 others); Wed, 13 Oct 2021 13:02:02 -0400 Received: from ale.deltatee.com ([204.191.154.188]:44928 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234468AbhJMRCB (ORCPT ); Wed, 13 Oct 2021 13:02:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:Message-Id:Date:Cc:To:From :references:content-disposition:in-reply-to; bh=tbPvbDzsZtbOGJDbhM8sXn4yknGSvZ1Pz9705wkhiMo=; b=Gg9q5h0QFSZKRXndWPZYqcqoMz QHOSMHc3c5gwvsl9T0cBPKYQSRYHlOj6y39lhIxvG7SChy1KLAXbCSw4rUdfaAoSRsAOP6aIw4rZn uC1gaWMuFHbxWs+tP8EzEMBanLfiRTd8xdlVT+ePyLRq2Sz1CNTILOOrqeE3pET7V8ogd9NwGv4mu MA0uzD585kqpnPBK2iFv3BRAerpaOHeRFmjD411IOZiFa7R+Udg42SgDcfTdg4/YSYeUNgSaZHjuY oTljd/5gsGG/5IeA8JBBLWY+rVOoC6TqjlzKo3RX7VOTFvngoPBt/cTFCGHUuOyFhmvWqY7hvpNZ1 RX89G+WA==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mahbg-0000yP-Uu; Wed, 13 Oct 2021 10:59:57 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1mahbf-000NNH-VT; Wed, 13 Oct 2021 10:59:56 -0600 From: Logan Gunthorpe To: linux-rdma@vger.kernel.org, Jason Gunthorpe Cc: linux-kernel@vger.kernel.org, Doug Ledford , Logan Gunthorpe , Bart Van Assche Date: Wed, 13 Oct 2021 10:59:42 -0600 Message-Id: <20211013165942.89806-1-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, dledford@redhat.com, logang@deltatee.com, bvanassche@acm.org X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Subject: [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ib_dma_map_sgtable_attrs() should be mapping the sgls and setting nents but the ib_uses_virt_dma() path falls back to ib_dma_virt_map_sg() which will not set the nents in the sgtable. Check the return value (per the map_sg calling convention) and set sgt->nents appropriately on success. Link: https://lore.kernel.org/all/996fa723-18ef-d35b-c565-c9cb9dc2d5e1@acm.org/T/#u Reported-by: Bart Van Assche Signed-off-by: Logan Gunthorpe Tested-by: Bart Van Assche --- include/rdma/ib_verbs.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 4b50d9a3018a..4ba642fc8a19 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -4097,8 +4097,13 @@ static inline int ib_dma_map_sgtable_attrs(struct ib_device *dev, enum dma_data_direction direction, unsigned long dma_attrs) { + int nents; + if (ib_uses_virt_dma(dev)) { - ib_dma_virt_map_sg(dev, sgt->sgl, sgt->orig_nents); + nents = ib_dma_virt_map_sg(dev, sgt->sgl, sgt->orig_nents); + if (!nents) + return -EIO; + sgt->nents = nents; return 0; } return dma_map_sgtable(dev->dma_device, sgt, direction, dma_attrs); base-commit: 2a152512a155aaf27c3e67834ffafaed9525a7b5 -- 2.30.2