Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2266059imm; Thu, 27 Sep 2018 09:57:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ki8RwPYArYLnSoBgYP3yu1pr+aKEjLWcb73WLEp/oDkpIFRFvwd9JWr988Vw9Lk5d5GFL X-Received: by 2002:a17:902:6102:: with SMTP id t2-v6mr12014153plj.278.1538067426250; Thu, 27 Sep 2018 09:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538067426; cv=none; d=google.com; s=arc-20160816; b=AkunN+MZXdK6a4h+obTkSrIBhYKrN+3Vfd9KqjfjpRXEEaLaLaE84pQBzi5rjntlJO 6cfr4bP5R9zhEMl1YSUfcJi6XgAGLTIy7ZnZTI1R9bfsA77FQU3reWu30mLs1bUPryvq 5YNYVtvOVXF6gA+y0ks1DRKH5FYXyDKoY0+H1qGFSw8gu4kw7IutwvjACBmr6cZygmkl 9ovs7sBRY6fIFjSb8tu1NtIn/ZfSZiIavmU0F/BGjyGB8FXoY9M+R2oN3yjmifuMGN3a 96/N8d+Q0o2heZTV3B786U4A9hA7myB5WxATNcYTVrYLcaMKT+/mDahDaWtDDO/oIecf vIVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=KIQTmMX9o3Aei9QtQuyS1K9aIZW4GDiLMdPcT64Sl+s=; b=UoMs39LwC3VWA0OKVqWOqT45mXiebUwPfxg/dnP0o8TJy/JEUX91vASGGh4m3xsY0I tdKl+Os6Y7vRhem86Xb2Q8UDGjSWrOaQiks8aNFHyZinWmL4pjykkZoRxmvhQmn35Vng FMYbEB4r7mVGuNRhPC9mFu7hLIbPz7iUITE7nUnr+XcIHtohdRKrAvomrLsh2Q9b+rEy wcS+UseffkXCpZmtxNoXv6UE7jPQDF40eAz9bDfkpvQSWlFqxyB95AOGq+VMZ1h+DeuV bqOraoCZ6CoSNLTRE3CsQYGsB1Xy0k9/LD3VhKhGDPmIdtaQXDLm+RAOPbV/cWn2Azct IuNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x185-v6si2531620pfb.306.2018.09.27.09.56.43; Thu, 27 Sep 2018 09:57:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728493AbeI0XNn (ORCPT + 99 others); Thu, 27 Sep 2018 19:13:43 -0400 Received: from ale.deltatee.com ([207.54.116.67]:58402 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728382AbeI0XNm (ORCPT ); Thu, 27 Sep 2018 19:13:42 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5ZYZ-0003f8-Ms; Thu, 27 Sep 2018 10:54:31 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1g5ZYU-0001Oc-9o; Thu, 27 Sep 2018 10:54:22 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, linux-nvdimm@lists.01.org, linux-block@vger.kernel.org Cc: Stephen Bates , Christoph Hellwig , Keith Busch , Sagi Grimberg , Bjorn Helgaas , Jason Gunthorpe , Max Gurtovoy , Dan Williams , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Benjamin Herrenschmidt , Alex Williamson , =?UTF-8?q?Christian=20K=C3=B6nig?= , Jens Axboe , Logan Gunthorpe Date: Thu, 27 Sep 2018 10:54:15 -0600 Message-Id: <20180927165420.5290-9-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927165420.5290-1-logang@deltatee.com> References: <20180927165420.5290-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-rdma@vger.kernel.org, linux-block@vger.kernel.org, sbates@raithlin.com, hch@lst.de, sagi@grimberg.me, bhelgaas@google.com, jgg@mellanox.com, maxg@mellanox.com, keith.busch@intel.com, dan.j.williams@intel.com, benh@kernel.crashing.org, jglisse@redhat.com, alex.williamson@redhat.com, christian.koenig@amd.com, axboe@kernel.dk, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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 autolearn=ham autolearn_force=no version=3.4.1 Subject: [PATCH v8 08/13] IB/core: Ensure we map P2P memory correctly in rdma_rw_ctx_[init|destroy]() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to use PCI P2P memory the pci_p2pmem_map_sg() function must be called to map the correct PCI bus address. To do this, check the first page in the scatter list to see if it is P2P memory or not. At the moment, scatter lists that contain P2P memory must be homogeneous so if the first page is P2P the entire SGL should be P2P. Signed-off-by: Logan Gunthorpe Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- drivers/infiniband/core/rw.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c index 683e6d11a564..d22c4a2ebac6 100644 --- a/drivers/infiniband/core/rw.c +++ b/drivers/infiniband/core/rw.c @@ -12,6 +12,7 @@ */ #include #include +#include #include #include @@ -280,7 +281,11 @@ int rdma_rw_ctx_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num, struct ib_device *dev = qp->pd->device; int ret; - ret = ib_dma_map_sg(dev, sg, sg_cnt, dir); + if (is_pci_p2pdma_page(sg_page(sg))) + ret = pci_p2pdma_map_sg(dev->dma_device, sg, sg_cnt, dir); + else + ret = ib_dma_map_sg(dev, sg, sg_cnt, dir); + if (!ret) return -ENOMEM; sg_cnt = ret; @@ -602,7 +607,9 @@ void rdma_rw_ctx_destroy(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num, break; } - ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir); + /* P2PDMA contexts do not need to be unmapped */ + if (!is_pci_p2pdma_page(sg_page(sg))) + ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir); } EXPORT_SYMBOL(rdma_rw_ctx_destroy); -- 2.19.0