Received: by 10.192.165.148 with SMTP id m20csp3986168imm; Mon, 23 Apr 2018 16:34:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx484PbEupjEI8K+pTlcbOP4TmFih2Y2ounDnv2xIHsxomZDUEz8SuNTe25DGVvyL2ht5rkj/ X-Received: by 2002:a17:902:407:: with SMTP id 7-v6mr22618649ple.47.1524526461619; Mon, 23 Apr 2018 16:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524526461; cv=none; d=google.com; s=arc-20160816; b=eLJyo7nOcfde1P4G9Iwj+hCl36EiwttsfSBMMfm9uHj8VmFeH7w6a0d6mH6tv7oTxf +RhUB+6/AUnx6WKO/aj2nQhQ5Q7hscOmszg8vf9lHsQ7U0uZdtAcJJvNkm2nFxhP6Qhc Fv9slP28dUNoX+GgPIwg4wNGOY7ujUWuTQwoXnOUsq9sdyio8v2p1ZK6DjuSFtq8lQGN wG1nAdSQu1IowJMGLmuDOUUBf+V8EHOuYrbf+b+TnxgExdSopewOefSv/N6ntySA/adb rLlrvEJMlrHjdb9jkv9N/U7z6SMgY6p7PVpAcubC2rAzKGPXZNLzJLK6bhoFVgZUYprX DOqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=6gDyW7wJ+Q74rf/SLbppxJPCFzsc4PR/AOlHnrihwsk=; b=ww+q1qSxB+ypg2qL43Jz0eK1dnQSmgB07nF2hLcP2/ZxaiDqPxblshq6nC1m2Dp+Uo 9IX3e9CzEq53FC9CSmzMZjH4WbJOC8a4+e749Tbf8kAIWG5vjg/faebqOjsIEOhc0Gtk ZHXPcE3fTIAAQay7SumrIgzDu58yKf6OeTzLV3CQQYTGxHUchxQOhqWepdExt68uoNt6 7vyaE5DbwQk1LJRmg13stP07kWqtc6BRpGFpfukRWLQM0T1xzK7altsj8foaZH+VFWpL 0Yn3yeMSCdbmB2QpgDADNhFvA3Sy1UpVoxYfhrIhO9rIV7vZwHoatigbpbvH5CJVKfPy zafg== 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 y186si12305326pfb.284.2018.04.23.16.34.07; Mon, 23 Apr 2018 16:34:21 -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 S932801AbeDWXcc (ORCPT + 99 others); Mon, 23 Apr 2018 19:32:32 -0400 Received: from ale.deltatee.com ([207.54.116.67]:41930 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932649AbeDWXbF (ORCPT ); Mon, 23 Apr 2018 19:31:05 -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 1fAkvB-0006J7-Om; Mon, 23 Apr 2018 17:31:00 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1fAkv3-0005bg-LC; Mon, 23 Apr 2018 17:30:49 -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 , Jens Axboe , 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?= , Logan Gunthorpe Date: Mon, 23 Apr 2018 17:30:40 -0600 Message-Id: <20180423233046.21476-9-logang@deltatee.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180423233046.21476-1-logang@deltatee.com> References: <20180423233046.21476-1-logang@deltatee.com> 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, axboe@kernel.dk, 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, 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=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.1 Subject: [PATCH v4 08/14] 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 pci_p2pmem_[un]map_sg() functions 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 --- drivers/infiniband/core/rw.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c index c8963e91f92a..f495e8a7f8ac 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,11 @@ 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); + if (is_pci_p2pdma_page(sg_page(sg))) + pci_p2pdma_unmap_sg(qp->pd->device->dma_device, sg, + sg_cnt, dir); + else + ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir); } EXPORT_SYMBOL(rdma_rw_ctx_destroy); -- 2.11.0